mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8214761: Bug in parallel Kahan summation implementation
Reviewed-by: darcy
This commit is contained in:
parent
7fff22afe7
commit
dd871819a0
5 changed files with 235 additions and 10 deletions
|
@ -156,7 +156,9 @@ public class DoubleSummaryStatistics implements DoubleConsumer {
|
|||
count += other.count;
|
||||
simpleSum += other.simpleSum;
|
||||
sumWithCompensation(other.sum);
|
||||
sumWithCompensation(other.sumCompensation);
|
||||
|
||||
// Subtract compensation bits
|
||||
sumWithCompensation(-other.sumCompensation);
|
||||
min = Math.min(min, other.min);
|
||||
max = Math.max(max, other.max);
|
||||
}
|
||||
|
@ -241,7 +243,7 @@ public class DoubleSummaryStatistics implements DoubleConsumer {
|
|||
*/
|
||||
public final double getSum() {
|
||||
// Better error bounds to add both terms as the final sum
|
||||
double tmp = sum + sumCompensation;
|
||||
double tmp = sum - sumCompensation;
|
||||
if (Double.isNaN(tmp) && Double.isInfinite(simpleSum))
|
||||
// If the compensated sum is spuriously NaN from
|
||||
// accumulating one or more same-signed infinite values,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue