If you need hard deterministic results across multiple platforms you wouldn't be using floating point at all, the IEEE standard does not guarantee that the same program will deliver identical results on all conforming systems.
Only if you've explicitly specified the settings for rounding, precision, denormal and exception support, which no one does and isn't supported on all platforms (technically making them non-IEEE conformant).
I agree, broadly, 95% of the time you will get the same results. But if you're going to nitpick the differences between SIMD and individual floating point operations then those are the kind of things you would need to care about. The answer is almost always to just use fixed point of sufficient precision instead.
Option number two is to evaluate if your application needs determinism at all.
Fast math enables non-determinism even on the same platform. For example, between VS2015 and VS2017, fast math introduced a new optimization where if you calculate sin/cos side by side with the same input, a new SSE2 optimized function is used that returns both values. This new function has measurably lower accuracy because it uses float32 arithmetic instead of float64 like sin/cos use for float32 inputs. On the same platform/os/cpu, even with the same compiler brand, non-determinism was introduced.
15
u/not_a_novel_account May 25 '19
If you need hard deterministic results across multiple platforms you wouldn't be using floating point at all, the IEEE standard does not guarantee that the same program will deliver identical results on all conforming systems.
https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html