3 ms·
Stuff like Kahan summation breaks horribly with -ffast-math, because if you assume that sum is associative the error term, which is ((s+x)-s)-x, simplifies to z
by bonzini 6y ago
Stuff like Kahan summation breaks horribly with -ffast-math, because if you assume that sum is associative the error term, which is ((s+x)-s)-x, simplifies to zero.
https://en.m.wikipedia.org/wiki/Kahan_summation_algorithm https://en.m.wikipedia.org/wiki/Kahan_summation_algorithm
- all-fakes 6y agoYeah, that's the obvious counterexample, but that's why I said "more often than not". The statement I was questioning was that fast-math is "normally not more correct."
- kevin_thibedeau 6y agoThat's where you dust off volatile.
- nestorD 6y agoSadly true. That's the only portable way I found to implement something akind to a Kahan sum so that no compiler / flag would destroy it.