Faster Math ?

Andrew Haley aph at redhat.com
Tue Nov 14 17:30:27 UTC 2017


On 09/11/17 09:00, Laurent Bourgès wrote:

> The Marlin renderer (JEP265) uses few Math functions: sqrt, cbrt, acos...
> 
> Could you check if the current JDK uses C2 intrinsics or libfdm (native /
> JNI overhead?) and tell me if such functions are already highly optimized
> in jdk9 or 10 ?
> 
> Some people have implemented their own fast Math like Apache Commons Math
> or JaFaMa libraries that are 10x faster for acos / cbrt.

I'm not seeing that with Apache Commons Math.  I'm seeing this:

Benchmark                   Mode  Cnt   Score   Error  Units
MathBenchmark.fastMathCbrt  avgt    5  33.199 ? 0.122  ns/op
MathBenchmark.mathCbrt      avgt    5  43.124 ? 0.162  ns/op
MathBenchmark.fastMathAcos  avgt    5  85.985 ? 4.586  ns/op
MathBenchmark.mathAcos      avgt    5  28.326 ? 0.044  ns/op

It's nice, but it certainly isn't 10x.

-- 
Andrew Haley
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671


More information about the core-libs-dev mailing list