RFR: 8284493: Improve computeNextExponential tail performance and accuracy [v20]

GuySteele duke at openjdk.org
Fri May 12 21:00:53 UTC 2023


On Fri, 12 May 2023 20:41:32 GMT, Chris Hennick <duke at openjdk.org> wrote:

>> This PR improves both the worst-case performance of `nextExponential` and `nextGaussian` and the distribution of output at the tails. It fixes the following imperfections:
>> 
>> * Repeatedly adding DoubleZigguratTables.exponentialX0 to extra causes a rounding error to accumulate at the tail of the distribution (probably starting around `2*exponentialX0 == 0x1.e46eff20739afp3 ~ 15.1`); this PR fixes that by tracking the multiple of exponentialX0 as a long. (This distortion is worst when `x > 0x1.0p56` since in that case, a rounding error means `extra + x == extra`.
>> * Reduces several equations using `Math.fma`. (This will almost certainly improve performance, and may or may not improve output distribution.)
>> * Uses the newly-extracted `computeWinsorizedNextExponential` function to prevent `nextGaussian` from going into the `nextExponential` tail twice.
>
> Chris Hennick has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - Merge remote-tracking branch 'origin/patch-1' into patch-1
>  - Optimize: move some code out of the fast path

Latest change looks good. I noted the improvement to the comment beginning "We didn't use the upper part of U1 after all".

-------------

PR Comment: https://git.openjdk.org/jdk/pull/8131#issuecomment-1546292204


More information about the core-libs-dev mailing list