How can compensation values be effectively combined in parallel Kahan summation?

  • Thread starter Thread starter williamshipman
  • Start date Start date
  • Tags Tags
    Parallel Summation
Click For Summary

Discussion Overview

The discussion revolves around the effective combination of compensation values in parallel Kahan summation, particularly in the context of summing a large set of 32-bit floating point numbers. Participants explore methods for integrating multiple sum/compensation pairs and address the implications of weighting these sums before combining them.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Debate/contested

Main Points Raised

  • One participant describes their approach of adding compensation values directly and seeks advice on its validity.
  • Another participant suggests returning both "sum" and "c" from each parallel branch and using Kahan summation for the final combination of sums and compensations.
  • A participant seeks clarification on whether the proposed method for handling weighted sums is appropriate, emphasizing the need to consider floating point approximations.
  • A later reply introduces the concept of double-single precision math as a potential solution but notes the increased computational cost associated with multiplication and division operations.

Areas of Agreement / Disagreement

Participants express differing views on the best method for combining sums and compensations, and there is no consensus on the handling of weighted sums. The discussion remains unresolved regarding the optimal approach for these calculations.

Contextual Notes

Participants mention limitations related to floating point approximations and the computational complexity of using higher precision methods, which may affect the feasibility of proposed solutions.

williamshipman
Messages
24
Reaction score
0
Hi PF,

I am working on a parallel reduction code to sum up approximately 1 million 32-bit floating point numbers. The serial part running on each processor uses Kahan summation, no problems there. My problem is that this produces several sum/compensation pairs that now need to be added together. How should this be handled, as I am unable to find helpful literature in the databases my library subscribes to? At the moment I am just adding the two compensation values and treating that as the new compensation value for one of the two numbers to be added.

Secondly, what is the correct way to handle a situation where the two sums must be weighted before summing them? At the moment if I have two Kahan summation results (sum1,compensation1) and (sum2,compensation2) I would proceed as follows: (sum,compensation) = kahan((sum1*w1,compensation1*w1), (sum2*w2,compensation2*w2)) where w1 and w2 are the weights and kahan() is the kahan summation from the paragraph above.

Any advice would be greatly appreciated.
 
Technology news on Phys.org
With the notation of http://en.wikipedia.org/wiki/Kahan_summation_algorithm , I guess the best method would be to return both "sum" and "c" from each parallel branch, and then in the final step add all the sum's and c's using Kahan summation.

The second question depends whether you are happy with the floating point approximation ##w(a+b) = (wa) + (wb)##. In general that is not true (for example you can easily invent examples where one result gives an overflow or underflow, but the other does not) but whether it matters to you depends on much more information than is in your OP.
 
  • Like
Likes   Reactions: 1 person
Hi AlephZero,

If I understand you properly, you're suggesting that I do the following for question 1:
  1. Kahan summation of sum1, sum2 up to sumN, giving an ##s## and ##c## value.
  2. Kahan summation of compensation1 up to compensationN, giving an ##s## and ##c## value.
At the end of this, I would come out with a sum of all the sums and its compensation term, a sum of all the previous compensation values, and its compensation term. Did I follow that correctly?

Regarding question 2, I think you misunderstood me. I am trying to calculate ##w_1 a + w_2 b##, i.e. two different weights and ##a## and ##b## are both results from previous Kahan summations.
 
To answer my original question, the correct way to handle my problem seems to be to use what is known as double-single precision math. See http://crd-legacy.lbl.gov/~dhbailey/mpdist/ for Fortran code for a double-single and double-double precision libraries. Unfortunately, once one gets to multiplication and division operations, which I need a lot of, the amount of operations becomes quite large, making it pointless for me to pursue double-single precision in place of plain double precision.
 

Similar threads

  • · Replies 11 ·
Replies
11
Views
5K
  • · Replies 4 ·
Replies
4
Views
2K
Replies
4
Views
2K
Replies
3
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 0 ·
Replies
0
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
9
Views
8K
  • · Replies 7 ·
Replies
7
Views
5K