aherbert opened a new pull request, #228: URL: https://github.com/apache/commons-numbers/pull/228
When the JVM reports hardware FMA support (HotSpot `UseFMA`) and `Math.fma` is accessible and checked to be fused, the round-off of a product `x * y` is computed with a single FMA instead of the Dekker two-product (splitting both factors, about 16 flops). This applies to `DD`, `DDMath`, `Sum` and `Norm`. Results are identical to the software implementation within its documented range. Java 8, non-HotSpot VMs and CPUs without FMA use the existing code. JMH benchmarks on x86-64 and aarch64 show consistent speed-ups with FMA for all operations that use the product round-off. The runtime is reduced to 0.4–0.9 of the software implementation. Full results are in the JIRA ticket [NUMBERS-220](https://issues.apache.org/jira/browse/NUMBERS-220). Detecting FMA reads the HotSpot flag through the management API, a one-off cost of about 10–20 ms on the first `DD` product. Setting the system property `org.apache.commons.numbers.core.DD.fma=false` disables FMA use and the detection. When FMA is not used, JMH benchmarks show the performance of 1.4 is equal to 1.3 within measurement error. Disclaimer: I wrote the `DD` changes, based on a proof-of-concept by Claude Code (Anthropic) for the detection of hardware FMA. Claude Code wrote the JMH benchmark changes, which I reviewed, and the scripts to run and tabulate the benchmarks. It also wrote and ran the start-up and branch prediction measurements, and diagnosed two JIT regressions found during development. This description was drafted by Claude Code. The commits are marked Generated-by: Claude Code. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
