On Sat, May 3, 2025, at 4:42 PM, Kristoffer Ström wrote: > Just because it has not been mentioned before, Floating Point Units on > CPUs are complex beasts that can carry state and other fun stuff. > > I believe most common instructions like addition and multiplication > should be deterministic, but trigonometric functions might not be > reproducible across different cpus. Or even across different > FPU-initialization code. > > But i'm way off my expertise in this, so if someone knows more i'd love > to be corrected.
I don't know a whole lot about this myself, but Racket comes with a utility to test if your floating-point implementation conforms to IEEE 754: https://docs.racket-lang.org/math/utils.html#%28part._utils~3afpu-test%29 Using Guix, you can run a few minutes' worth of testing (on my machine) using: guix shell racket -- racket -e '(require math/utils) (test-floating-point 100000)' Use a bigger argument to run even more random tests of each function. You will see lots of logging output by default: as long as the last line of output is '(), there are no errors. I also recommend the article "Practically Accurate Floating-Point Math" for understanding floating-point issues: https://jeapostrophe.github.io/home/static/tm-cise2014.pdf
