Post

Why is #golang now a non-deterministic language with the 1.27 FMA changes? Pure Go code producing different output on different platforms. Avoiding that is why I *moved* to Go.

0 reposts2 likes

I wonder if there should be a test mode that randomize let's say the lowest 3 bits after any float operation. FMA is the visible tip of the iceberg, there are edge cases where some CPUs just implement IEEE754 at partial precision on some costly operations.

Sadly for perfect portability the only solution is fixed point math or software floats. Or maybe types like archfloat.x86, archfloat.riscv, .. that make sure to portably implement floats according to one exact ISA.

People have been pretty good at IEEE math for a few decades now. In scalar code at least, the widely-understood default mode for doing FP looks like Java's strictfp, with the only glitches at (1) multiply-and-add and (2) conversions. We owe a lot to Java for this.

All the minor-bit differences that people run into involve changing the number of roundings. Plain multiply, then add, rounds once after the multiply, once after the add, while "fused" multiply-and-add elides the first rounding. Converting between mantissa lengths also adds an additional rounding.