Hey,
Most functions in the Math class are intrinsic (
http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/file/tip/src/share/vm/classfile/vmSymbols.hpp#l664
) and will use native instructions where available. You can also test
this yourself using jitwatch. There is no native call overhead.
The standard library does not currently include less accurate but faster
Math functions, maybe someone else can answer if that is something to be
considered.
- Jonas Konrad
On 11/09/2017 10:00 AM, Laurent Bourgès wrote:
Hi,
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 wonder if I should implement my own cbrt function (cubics) in pure java
as I do not need the highest accuracy but SPEED.
Would it sound possible to have a JDK FastMath public API (lots faster but
less accurate?)
Do you know if recent CPU (intel?) have dedicated instructions for such
math operations ?
Why not use it instead?
Maybe that's part of the new Vectorization API (panama) ?
Cheers,
Laurent Bourges