Re:Beware of fast-math
by adgjlsfhk1 on Friday November 12, 2021 @01:16PM
(#29202669)
Note that this is only true in theory. In practice, there are still some bugs here that will hopefully be fixed by julia 1.8
- `fma(a, b, c)` is exact but may be slow: it uses intrinsics if available and falls back to a slow software emulation when they're not
- `muladd(a, b, c)` uses the fastest possibly inexact implementation of `a*b + c` available, which is FMA intrinsics if available or just doing separate `*` and `+` operations if they're not
That gives the user control over what they need—precision or speed. If you're writing code that needs the extra precision, use the `fma` function but if you just want to compute `a*b + c` as fast as possible, with or without extra precision, then use `muladd`.