Skip to content

Commit

Permalink
disable non-IEEE 754 math
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbkoch committed Jan 15, 2025
1 parent ad0ebc1 commit 2a28ee7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ all_args="$all_args -Wformat=2"
all_args="$all_args -Wno-format-nonliteral"
all_args="$all_args -Wno-parentheses"
all_args="$all_args -fvisibility=hidden -fvisibility-inlines-hidden"
all_args="$all_args -fno-math-errno -fno-trapping-math"
all_args="$all_args -fno-math-errno -fno-trapping-math -fno-fast-math -ffp-contract=off"
# TODO: once we have highly efficient tightly looped code, try no -fpic and see if that makes better code. The compiler can save a register in this case. See https://akkadia.org/drepper/dsohowto.pdf
# TODO: check no-plt compiler option
all_args="$all_args -fpic"
Expand Down
6 changes: 5 additions & 1 deletion shared/libebm/interpretable_numerics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1379,6 +1379,9 @@ static double Mean(const size_t cSamples,
// https://stackoverflow.com/questions/895929/how-do-i-determine-the-standard-deviation-stddev-of-a-set-of-values
// https://www.johndcook.com/blog/standard_deviation/

// do not put multiple floating point operations in the same statement since that can be optimized
// https://clang.llvm.org/docs/UsersManual.html

double factor = 1.0;
double mean;
size_t cNaN;
Expand Down Expand Up @@ -1440,7 +1443,8 @@ static double Mean(const size_t cSamples,
// if all the weights are zero, then weigh them all equally
ratio = double{1} / static_cast<double>(cNormal);
}
mean += numerator * ratio;
const double multiple = numerator * ratio;
mean += multiple;
}
if(nullptr != pWeight) {
++pWeight;
Expand Down

0 comments on commit 2a28ee7

Please sign in to comment.