Skip to content

Commit 2a28ee7

Browse files
committed
disable non-IEEE 754 math
1 parent ad0ebc1 commit 2a28ee7

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ all_args="$all_args -Wformat=2"
413413
all_args="$all_args -Wno-format-nonliteral"
414414
all_args="$all_args -Wno-parentheses"
415415
all_args="$all_args -fvisibility=hidden -fvisibility-inlines-hidden"
416-
all_args="$all_args -fno-math-errno -fno-trapping-math"
416+
all_args="$all_args -fno-math-errno -fno-trapping-math -fno-fast-math -ffp-contract=off"
417417
# 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
418418
# TODO: check no-plt compiler option
419419
all_args="$all_args -fpic"

shared/libebm/interpretable_numerics.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1379,6 +1379,9 @@ static double Mean(const size_t cSamples,
13791379
// https://stackoverflow.com/questions/895929/how-do-i-determine-the-standard-deviation-stddev-of-a-set-of-values
13801380
// https://www.johndcook.com/blog/standard_deviation/
13811381

1382+
// do not put multiple floating point operations in the same statement since that can be optimized
1383+
// https://clang.llvm.org/docs/UsersManual.html
1384+
13821385
double factor = 1.0;
13831386
double mean;
13841387
size_t cNaN;
@@ -1440,7 +1443,8 @@ static double Mean(const size_t cSamples,
14401443
// if all the weights are zero, then weigh them all equally
14411444
ratio = double{1} / static_cast<double>(cNormal);
14421445
}
1443-
mean += numerator * ratio;
1446+
const double multiple = numerator * ratio;
1447+
mean += multiple;
14441448
}
14451449
if(nullptr != pWeight) {
14461450
++pWeight;

0 commit comments

Comments
 (0)