JDK 9 RFR of JDK-4851642: Add fused mac to Java math library

Brian Burkhalter brian.burkhalter at oracle.com
Wed Apr 13 19:43:21 UTC 2016


Joe / Dmitry,

On Apr 12, 2016, at 5:21 PM, joe darcy <joe.darcy at oracle.com> wrote:

> Please review the changes for
> 
>    JDK-4851642: Add fused mac to Java math library
>    http://cr.openjdk.java.net/~darcy/4851642.0/
> 
> Fused mac (multiply-accumulate) is a ternary floating-point operation which accepts three inputs, a, b, c, and computes
> 
>    a * b + c
> 
> with a single rounding error rather than the usual two rounding errors (a first for the multiply, a second one for the add).

A couple of points of curiosity. Firstly, is this not “fused multiply-add” rather than “fused multiply-accumulate?” Secondly, why the choice of name “fusedMac()” instead of the common “fma()” or the longer but perhaps clearer “fusedMultiplyAdd()?”

A picayune javadoc point: in the unordered lists <ul></ul> should “</li>” be used to close the list items?

On Apr 13, 2016, at 5:41 AM, Dmitry Nadezhin <dmitry.nadezhin at gmail.com> wrote:

I concur with Dmitry’s points. With respect to the second one,

> 2) Lines Math:1508-1525 could be simpler:
> ====
>    double result = a * b + c;
>    return Double.isNaN(result) && Double.isFinite(a) && Double.isFinite(b)
> ? c : result;
> ====

not trusting this to my own visual inspection, I wrote nested loops to run a, b, and c over

        double[] values = new double[] {
            -0.0, 0.0, +0.0, -42.0, 42.0,
            -Double.MAX_VALUE, Double.MAX_VALUE,
            Double.NaN, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY
        };

and there is no difference between the webrev and Dmitry’s suggestion above for the cases where

	!Double.isFinite(a) || !Double.isFinite(b) || !Double.isFinite(c) == true

Brian


More information about the core-libs-dev mailing list