HackerPapers

arXiv:1505.05571math.NA

Fast exact summation using small and large superaccumulators

Radford M. Neal

Abstract

I present two new methods for exactly summing a set of floating-point numbers, and then correctly rounding to the nearest floating-point number. Higher accuracy than simple summation (rounding after each addition) is important in many applications, such as finding the sample mean of data. Exact summation also guarantees identical results with parallel and serial implementations, since the exact sum is independent of order. The new methods use variations on the concept of a "superaccumulator" - a large fixed-point number that can exactly represent the sum of any reasonable number of floating-point values. One method uses a "small" superaccumulator with sixty-seven 64-bit chunks, each with 32-bit overlap with the next chunk, allowing carry propagation to be done infrequently. The small superaccumulator is used alone when summing a small number of terms. For big summations, a "large" superaccumulator is used as well. It consists of 4096 64-bit chunks, one for every possible combination of exponent bits and sign bit, plus counts of when each chunk needs to be transferred to the small superaccumulator. To add a term to the large superaccumulator, only a single chunk and its associated count need to be updated, which takes very few instructions if carefully implemented. On modern 64-bit processors, exactly summing a large array using this combination of large and small superaccumulators takes less than twice the time of simple, inexact, ordered summation, with a serial implementation. A parallel implementation using a small number of processor cores can be expected to perform exact summation of large arrays at a speed that reaches the limit imposed by memory bandwidth. Some common methods that attempt to improve accuracy without being exact may therefore be pointless, at least for large summations, since they are slower than computing the sum exactly.

arXiv comments
Journal reference
DOI
Subjects
math.NANumerical Analysis cs.DCDistributed, Parallel, and Cluster Computing stat.COComputation (Statistics)

On Hacker News

Linked by 3 identifiable commenters in 4 comments across 4 threads, from Mar 2019 to Nov 2024. Found in 1 HN submission from Jan 2017 to Jan 2017. Open submission discussions.

Comments linking this paper, per year.

Discussed in comments4 threads

    • Indeed, this approach is known as a superaccumulator [1] and faster overall than the Kahan summation for a large amount of numbers. I don't exactly know the currently accepted threshold but 10,000 numbers should be conservative enough for that. [1]…

      lifthrasiirView on HNParent context

  1. Taming floating-point sums 1 comment
    • Exact addition using accumulators has progressed since the work of Zhu and Hayes in 2010. See my paper at https://arxiv.org/abs/1505.05571 (repository at https://gitlab.com/radfordneal/xsum), which is used in the Julia xsum package…

      radford-nealView on HNParent context

  2. Things we learned about sums 1 comment
    • While Kahan summation is more accurate than naive summation, it still does not produce the precise result (the true sum rounded to the final precision). It is not too costly to do the summation exactly. Several algorithms for this have been developed. You can read about mine at…

      radford-nealView on HNParent context

    • It's an interesting connection. Any finite collection of real values (represented in floating-point or otherwise) has a definite correct sum. If you're constrained to the floating-point to represent that value, you should ideally round the true value to the closest float and…

      StefanKarpinskiView on HNParent context

Submitted to Hacker News

Connected through shared HN threads, not inferred similarity or a recommendation.