Optimizing sums of products (dot products)

In the extreme, you can get nearly any floating point value just by choosing different orderings when summing this one list of 2046 floats.

These “ffast” or “funsafe” flags just make programs impossible to reason about. It frequently means you get different answers for the same operation, causing all sorts of surprises and broken invariants. x might equal y in one context but be less than it in another.

@simonbyrne has a good writeup here:

https://simonbyrne.github.io/notes/fastmath/

4 Likes