Math trig intrinsics and compiler options

gustav trede gustav.trede at
Sun Aug 9 12:04:09 PDT 2009

Hello ,

I have some questions regarding java impl of the fdlibm code.

What methods if any needs to be declared as strictfp, i assume where its
needed its for both math and strictmath ?
I currently do not need to use it to get results to exactly match
strictmath, but perhaps thats 'luck' and it will break on other cpu or
platforms  and to rely on that its a known jdk impl we run on with its
characteristics is not a safe.

Should StrictMath itself contain the massive implementations or delegate,
replacing the native calls with a single line ?

The algorithm specific doc per method for fdlibm would be nice to conserve ,
that would be natural to have as method jdoc in a delegate class.
Or how do you want it done ?

Regarding conformance testing, i try to do the best i can considering no JCK
access and that im not an expert the the math used in the algorithms.
I carefully lookup all crossover values for the different algorithm paths in
the code, +- 100 million ulps around each value  along with  more silly
tests like around each possible 2 exponent for double.
for tan, cos , sin  the results matches the current strictmath exactly, I
have not tested the rest of the methods yet.

Im still trying to figure out best impl for cos, sin, tan due to that as
soon as you dont do  simple loop tests but something more real life based,
the different code paths is inlined and it becomes slow large blob of it.

The performance boost is massive compared to the current jdk impl on solaris
(and thats the fasted platform for jdk trig impl) , 21 vs 97 cycles for sin
+-pi/4 on intel core2 , but its not nice when its not stable , can currently
differ with a factor of up to 2 on some cases for certain input ranges..
So will work on stabilizing as high as possible real world performance by
comparing different approaches.

-------------- next part --------------
An HTML attachment was scrubbed...

More information about the hotspot-dev mailing list