4 ms·
> Unsafe optimizations should not be done, such as automatically using FMA, I agree with most of what you said, but automatic use of FMA is not an unsafe optim
by nwallin 3y ago
> Unsafe optimizations should not be done, such as automatically using FMA,
I agree with most of what you said, but automatic use of FMA is not an unsafe optimization. If FMA breaks your code, your code was always broken in the first place.
- jcranmer 3y agoFMA can cause some guarantees about vector arithmetic to break (you end up computing different precisions for different vector components), so it's not 100% a safe optimization.
- titzer 3y agoNo. Changing the rounding behavior of floating point code is not generally OK. Numerical algorithms are often extremely carefully written and it is totally unpredictable what adding more precision can do. For example, adding more precision can actually make some algorithms diverge, or take many more iterations to converge, because when designing an algorithm with higher-level knowledge, the rounding behavior can be exploited on purpose. Automatic FMA is absolutely an unsafe optimization. Don't do it unless software requests it.
- theodorethomas 3y agoIt is unsafe if the code was written by a numerical expert who understood the ISO/IEC 60559:2020 standard. Not many of those, so in all probability your garbage code continues to be garbage (but faster) with FMA.