From e79d63ed5681187d15ea5fc048da4687cae8ac49 Mon Sep 17 00:00:00 2001 From: Riley Murray Date: Wed, 11 Sep 2024 22:14:53 -0400 Subject: [PATCH] turn off compiler optimizations in box-muller. Change default error threshold for weights_to_cdf. Add missing include in sparse_skops.hh --- RandBLAS/random_gen.hh | 2 ++ RandBLAS/sparse_skops.hh | 1 + RandBLAS/util.hh | 6 +++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/RandBLAS/random_gen.hh b/RandBLAS/random_gen.hh index f502e981..2247ea52 100644 --- a/RandBLAS/random_gen.hh +++ b/RandBLAS/random_gen.hh @@ -74,7 +74,9 @@ static inline void sincospi(double x, double *s, double *c) { #include #include // NOTE: we do not support Random123's AES or ARS generators. +#pragma clang optimize off #include +#pragma clang optimize on #include /// our extensions to random123 diff --git a/RandBLAS/sparse_skops.hh b/RandBLAS/sparse_skops.hh index a946ec08..1bd320cb 100644 --- a/RandBLAS/sparse_skops.hh +++ b/RandBLAS/sparse_skops.hh @@ -40,6 +40,7 @@ #include #include #include +#include #define MAX(a, b) (((a) < (b)) ? (b) : (a)) #define MIN(a, b) (((a) < (b)) ? (a) : (b)) diff --git a/RandBLAS/util.hh b/RandBLAS/util.hh index 3cd6b7a1..6cfd02ea 100644 --- a/RandBLAS/util.hh +++ b/RandBLAS/util.hh @@ -328,6 +328,10 @@ void transpose_square(T* A, int64_t n, int64_t lda) { return; } +template +T sqrt_epsilon() { + return std::sqrt(std::numeric_limits::epsilon()); +} // ============================================================================= /// \fn weights_to_cdf(int64_t n, T* w, T error_if_below = -std::numeric_limits::epsilon()) @@ -344,7 +348,7 @@ void transpose_square(T* A, int64_t n, int64_t lda) { /// On exit, \math{w} is a CDF suitable for use with sample_indices_iid. /// template -void weights_to_cdf(int64_t n, T* w, T error_if_below = -std::numeric_limits::epsilon()) { +void weights_to_cdf(int64_t n, T* w, T error_if_below = -sqrt_epsilon()) { T sum = 0.0; for (int64_t i = 0; i < n; ++i) { T val = w[i];