The @fastmath macro
The @fastmath macro is a tool that can be used to loosen the constraints of IEEE floating point operations in order to achieve greater performance. The macro replaces a fixed set of about 50 mathematical operations with faster implementations. In doing so, it can rearrange the order of evaluation to something which is mathematically equivalent, but that would not be the same for discrete floating point numbers due to rounding effects. It can also replace some intrinsic operations with their faster variants that do not check for NaN or Infinity. This results in faster execution, but with a corresponding reduction in accuracy. This option is similar to the -ffast-math option in the Clang or GCC compilers.
For example, consider ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access