3 ms·
> It is much more frequent for -ffast-math to generate bigger errors than to benefit from an accidental cancellation of the errors. In my experience underflows
by bjourne 2y ago
> It is much more frequent for -ffast-math to generate bigger errors than to benefit from an accidental cancellation of the errors.
In my experience underflows are very uncommon and indicate that you're doing something wrong, whereas fp contractions are extremely common. So I disagree with you.
- mbauman 2y agofp contract isn't a uniform "decrease in error" either, though. As a simple example, it introduces error in the straightforward: a*b - a*b
- adrian_b 2y agoI agree that using fused multiply-add in almost all cases improves the accuracy of the results. Nevertheless, I consider that a compiler option that gives you good FMA, but only together with bad behavior at underflows, is something exceedingly stupid. FMA is a standard operation, while ignoring underflows is rightly prohibited by the floating-point standard. There should never have been a compiler option that mixes standard operations with non-standard operations. In C or C++, you can use the "fma" function to get FMA where desired. This is more awkward, but it is safe. Any better solution requires a change in the programming language. For instance, it could be required that adjacent * and + must always be contracted into an FMA, unless separated by parentheses. This would allow the programmer to select between FMA and FMUL+FADD, as desired. FMA has appeared in 1990 (in IBM POWER) and it has been the greatest advance in floating-point computation after the introduction of Intel 8087 in 1980 (which has resulted in the IEEE standard a few years later). It is weird that 34 years later, most, if not all, programming languages do not handle well the generation of FMA operations.