Could the compiler invalidate twoSum ?
nestordemeure opened this issue · comments
Hello,
It is usually said that aggressive compilation might invalidate twoSum.
In libeft, the only guard against this phenomenon that I could find is a pragma GCC
to avoid O3 compilation, is this enough ?
It might be : even gcc -Ofast -ffast-math
was not able to invalidate a similar implementation of this EFT on my machine. I will try the Intel compiler as soon as I get my hand on it...
Cordially,
Nestor Demeure
You are right: aggressive compiler optimizations can invalidate twoSum
.
At the time when I implemented the original version of libeft
, the pragmas were enough for the gcc
version I was using. Since then, I have seen cases where gcc -O3
or gcc -O2
made optimizations which would invalidate twoSum
.
A more robust implementation has been introduced in commit 74e4097, which uses intrinsics for all sensitive FP operations in twoSum
, twoProd
and split
. With this version (currently accessible in the dev
branch), twoSum
and twoProd
seem to remain valid, even with aggressive compiler optimizations (-O3
, -Ofast
or -ffast-math
for gcc
).
branch dev
has now been merged into master
.