Skip to content

Commit

Permalink
turn off compiler optimizations in box-muller. Change default error t…
Browse files Browse the repository at this point in the history
…hreshold for weights_to_cdf. Add missing include in sparse_skops.hh
  • Loading branch information
rileyjmurray committed Sep 12, 2024
1 parent 7280c0f commit e79d63e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions RandBLAS/random_gen.hh
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ static inline void sincospi(double x, double *s, double *c) {
#include <Random123/philox.h>
#include <Random123/threefry.h>
// NOTE: we do not support Random123's AES or ARS generators.
#pragma clang optimize off
#include <Random123/boxmuller.hpp>
#pragma clang optimize on
#include <Random123/uniform.hpp>

/// our extensions to random123
Expand Down
1 change: 1 addition & 0 deletions RandBLAS/sparse_skops.hh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <unordered_map>

#define MAX(a, b) (((a) < (b)) ? (b) : (a))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
Expand Down
6 changes: 5 additions & 1 deletion RandBLAS/util.hh
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,10 @@ void transpose_square(T* A, int64_t n, int64_t lda) {
return;
}

template <typename T>
T sqrt_epsilon() {
return std::sqrt(std::numeric_limits<T>::epsilon());
}

// =============================================================================
/// \fn weights_to_cdf(int64_t n, T* w, T error_if_below = -std::numeric_limits<T>::epsilon())
Expand All @@ -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 <typename T>
void weights_to_cdf(int64_t n, T* w, T error_if_below = -std::numeric_limits<T>::epsilon()) {
void weights_to_cdf(int64_t n, T* w, T error_if_below = -sqrt_epsilon<T>()) {
T sum = 0.0;
for (int64_t i = 0; i < n; ++i) {
T val = w[i];
Expand Down

0 comments on commit e79d63e

Please sign in to comment.