Repeatability in a Floating-Point Reduction

Floating-point additions can round differently under different groupings. Worker scheduling or chunk boundaries can expose that difference.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Trace a cancellation case
  2. State the required guarantee
  3. Compare two legal groupings in finite precision
  4. Fix a reduction order when reproducibility requires it

Trace a cancellation case

Adding \(10^{16}\), \(1\), and \(-10^{16}\) in ordinary binary64 can give zero when the first pair rounds to \(10^{16}\). Combining the large opposite terms first instead leaves one. See binary rounding.

State the required guarantee

A reproducible result may need a fixed order or an algorithm with appropriate precision. Numerical tolerances express an allowed difference when exact reproducibility is unnecessary.[1]

Compare two legal groupings in finite precision

In ordinary binary64, with large value \(10^{16}\), adding one can round back to that large value. Summing \(10^{16},-10^{16},1\) in the written left-to-right order gives one. Grouping the last two first can give zero. See small terms in a sum.

(10^16 + (-10^16)) + 1 → 1
10^16 + ((-10^16) + 1) → 0 under stated rounding
Exact real sum is one

Fix a reduction order when reproducibility requires it

Deterministic grouping controls variation for a fixed implementation and environment. It does not guarantee maximal accuracy. Compare against a higher-precision reference and a documented tolerance.

References

  1. OpenMP Architecture Review Board, OpenMP API Specifications ↩