3 ms·
Interesting test cases for FMA are pretty easy to characterize, since it's a simple linear function up to rounding. The obvious edge cases include zero/infinity
by stephencanon 2y ago
Interesting test cases for FMA are pretty easy to characterize, since it's a simple linear function up to rounding. The obvious edge cases include zero/infinity/nan arithmetic, cases where the product would overflow or underflow but the final result does not, and cases where the produce has finite overflow/underflow but the addend is an exact infinity or zero which hides it. After those, cases with significant cancellation (e.g. fma(1+e, 1-e, -1)) are interesting, as well as cases that fall exactly on or very close to rounding boundaries (these can be constructed via integer arithmetic fairly easily).
fma is also interesting because it can produce results very close to the underflow boundary (add/subtract/divide/sqrt cannot do this, so one sometimes unearths bugs specific to fma, occasionally even hardware bugs), so those are well worth exercising. For subnormal results, double-rounding happens in a different bit position, so it's important to exercise those cases. One also wants to exercise cases where the product underflows by a huge amount, but the final result does not, because people sometimes write implementations based on integer arithmetic that will incur out-of-range shift counts that may not be correctly handled and invoke UB in C or C++.