RFR 8214761 : Bug in parallel Kahan summation implementation

Chris Dennis chris.w.dennis at gmail.com
Thu Aug 27 14:52:07 UTC 2020


Bump...

I've run in to this while running tests that check computation results against the expected bounds of a Kahan summation. Any chance that this gets picked up in the near future?

Thanks,

Chris

On 12/13/18, 6:16 PM, "core-libs-dev on behalf of Ivan Gerasimov" <core-libs-dev-bounces at openjdk.java.net on behalf of ivan.gerasimov at oracle.com> wrote:

    Gentle ping.


    On 12/9/18 7:37 PM, Ivan Gerasimov wrote:
    > Hello!
    >
    > DoubleSummaryStatistics takes advantage of Kahan summation algorithm 
    > to reduce the error of the total sum.
    >
    > Internally it maintains a field double sumCompensation, which keeps 
    > lower bits (which were rounded off) of the last addition.
    >
    > Note, that the compensation has to be subtracted from the result to 
    > add those bits back:
    >
    >  166     private void sumWithCompensation(double value) {
    >  167         double tmp = value - sumCompensation;
    >  168         double velvel = sum + tmp; // Little wolf of rounding error
    >  169         sumCompensation = (velvel - sum) - tmp;
    >  170         sum = velvel;
    >  171     }
    >
    > At the line 169, tmp normally has more lower bits than (velvel - sum).
    >
    > However, when two DoubleSummaryStatistics objects are combined, this 
    > compensation part is *added* to the total, which may result in a less 
    > accurate result.
    >
    > The same bug is replicated in DoubleStreams.
    >
    > Would you please help review the fix?
    >
    > BUGURL: https://bugs.openjdk.java.net/browse/JDK-8214761
    > WEBREV: http://cr.openjdk.java.net/~igerasim/8214761/00/webrev/
    >

    -- 
    With kind regards,
    Ivan Gerasimov



More information about the core-libs-dev mailing list