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

Brian Burkhalter brian.burkhalter at oracle.com
Wed Apr 13 22:08:42 UTC 2016


Hi Joe,

On Apr 13, 2016, at 3:02 PM, Joseph D. Darcy <joe.darcy at oracle.com> wrote:

> On 4/13/2016 12:43 PM, Brian Burkhalter wrote:
>> 
>> 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()?”
> 
> On naming, there are a few candidates. As background, I'll note that the naming in java.lang.Math at times follows the C-style naming ("cos" rather than "cosine"), but that methods we've added more recently outside of the traditional C math.h have followed more Java-style conventions. FWIW, C99 calls this "fma".
> 
> So, "fma()" is a possible choice, certainly concise, but I don't think many people would find it very suggestive as to what it does, at least not with the current familiarity with fused multiply-add.
> 
> In the IEEE 754 2008 standard, the operation is spelled out as "fusedMultiplyAdd", but that is a bit long.
> 
> The "multiply accumulate" term is how I first heard of the operation and there is some other usage of it (https://en.wikipedia.org/wiki/Multiply%E2%80%93accumulate_operation), but "fused multiply add" is also an accurate description.

Yes, I saw this latter as well. It is the mention of the accumulator there which made me think that multiply-add is more apt.

> As part of favoring "simplicity over speed," I intentionally wrote the code in a way that tried to follow the structure of the specification in a straightforward manner. […] For this initial implementation, I think this kind of simplicity is desirable. Longer term, I wouldn't be surprised if this implementation was retired out to be a reference implementation for additional regression tests.

Well that is a good point: if the eventual target is an intrinsic or other accelerated implementation then this probably does not matter that much.

Brian


More information about the core-libs-dev mailing list