Skip to content

Review: Tight and Rigorous Error Bounds for Basic Building Blocks of Double-Word Arithmetic

Citation

  • Joldes, M., Muller, J.-M., & Popescu, V. (2017). Tight and rigorous error bounds for basic building blocks of double-word arithmetic. ACM Transactions on Mathematical Software, 44(2), Article 15res, 1–27.
  • DOI

Abstract

We analyze several classical basic building blocks of double-word arithmetic (frequently called "double-double arithmetic" in the literature): the addition of a double-word number and a floating-point number, the addition of two double-word numbers, the multiplication of a double-word number by a floating-point number, the multiplication of two double-word numbers, the division of a double-word number by a floating-point number, and the division of two double-word numbers. For multiplication and division we get better relative error bounds than the ones previously published. For addition of two double-word numbers, we show that the previously published bound was incorrect, and we provide a new relative error bound. We introduce new algorithms for division. We also give examples that illustrate the tightness of our bounds.


A double-word number is the unevaluated sum of two floating-point numbers. The paper notes that double-word arithmetic "is not similar to a conventional, IEEE 754-like, floating-point arithmetic with twice the precision", and that many of its algorithms "have been published without a proof, or with error bounds that are sometimes loose, sometimes fuzzy ... and sometimes unsure" (p. 2). Its purpose is to give rigorous relative error bounds, in units of \(u = 2^{-p}\), where \(p\) is the precision of the underlying format. All results assume radix 2, rounding to nearest, and an unlimited exponent range; they apply to real arithmetic "provided that underflow and overflow do not occur" (p. 2).

The error-free transforms

Three algorithms are the building blocks (pp. 3–4). Fast2Sum (Algorithm 1, from Dekker 1971) returns the sum and its error in three operations when \(e_a \ge e_b\), which holds when \(|a| \ge |b|\). 2Sum (Algorithm 2, from Knuth and Møller) needs six operations and no condition. Fast2Mult (Algorithm 3) returns the product and its error in two operations with a fused multiply-add; the paper calls any algorithm that does this, Dekker's or Fast2Mult, 2Prod. The error of a product is a floating-point number only when \(e_a + e_b \ge e_{min} + p - 1\) (p. 3).

The paper states that "in all the algorithms presented below, a call to 2Sum can be replaced by a test and a call to Fast2Sum without changing the error bounds" (p. 3).

The bounds

The algorithms that Hifuku's float-float library follows, and their bounds:

algorithm what it computes bound where
AccurateDWPlusDW (Algorithm 6) double-word + double-word \(3u^2/(1 - 4u) < 3u^2 + 13u^3\) for \(p \ge 6\) Theorem 3.1, p. 7
DWTimesFP2 (Algorithm 8) double-word × floating-point \(3u^2\) Theorem 4.2, p. 12
DWTimesDW1 (Algorithm 10) double-word × double-word, no fma \(7u^2/(1 + u)^2 < 7u^2\) Theorem 5.1, p. 13
DWTimesDW2 (Algorithm 11) double-word × double-word, with fma \((6u^2 + u^3/2)/(1 + u)^2 < 6u^2\) Theorem 5.3, p. 15

AccurateDWPlusDW is two 2Sums, one rounded addition, a Fast2Sum, another rounded addition and a second Fast2Sum (p. 7). The bound published for it before was \(2 \cdot 2^{-106}\) in binary64, and the paper shows that it is incorrect with an input whose relative error is \(2.24999999999999956 \ldots \times 2^{-106}\) (p. 7). DWTimesDW1 is Dekker's mul2: a 2Prod of the high parts, the two cross products rounded and added, the sum added to the error of the 2Prod, and a Fast2Sum (p. 13). DWTimesDW2 merges one cross product into an fma (p. 15).

The paper also reports the largest errors found in its tests. For DWTimesDW1 in binary32 (\(p = 24\)), the largest was \(4.947 \times 2^{-48}\), below the bound of \(7u^2 = 7 \times 2^{-48}\) (p. 15).

Relevance to Hifuku

Hifuku's WGSL kernels carry float-float values: double-word numbers over float32, so \(p = 24\) and \(u = 2^{-24}\).

  • ff_add is AccurateDWPlusDW, with its two 2Sums replaced by Fast2Sum after a comparison, which the paper allows without a change to the bound (p. 3). Its bound is Theorem 3.1.
  • ff_mul is DWTimesDW1 as written. A WGSL compiler may contract a multiplication and an addition into an fma, which turns it into DWTimesDW2. Its bound is therefore the larger of Theorems 5.1 and 5.3, as improved by Muller and Rideau (2022).
  • ff_mul_f is DWTimesFP2, with the bound of Theorem 4.2.
  • The domain of 2Prod is the condition on page 3: the error of a product is representable only when the exponents of the factors are large enough. The library states it as a lower bound on \(|ab|\).

The bounds assume correct rounding and no reassociation. The paper does not consider a compiler that regroups operations, which the WGSL specification permits. The library's tests run chains of these operations on the device and check them against the bounds, which detects a compiler that removes an error term.