Math trig intrinsics and compiler options

gustav trede gustav.trede at gmail.com
Wed Aug 5 02:19:18 PDT 2009


2009/7/16 Christian Thalinger <Christian.Thalinger at sun.com>

> Azeem Jiva wrote:
> > Joe,
> >   Gustav sent me an email asking for help with the intrinsification of
> > the trig functions and a suggestion I gave him was to not call
> > fsin/fcos/ftan since those instructions are microcoded on Intel/AMD
> > hardware and very slow.  Slower than the call to
> > sharedRuntimeTrig.cpp, and in all cases it's best to stay away from
> > the hardware instructions.
>
> I just did some micro-benchmarking on an Intel Core2 Duo and in the
> range of [0,2pi) inlining the hardware instructions is slightly faster
> (about 2.5%).  Limiting the range to [0,pi/4) (means no runtime calls)
> hardware instructions are 1.5x faster.
>
> I think we should keep the current approach.
>
> -- Christian
>


Neither linux nor the windows platform has compiler opts enabled, only
solaris does, it seems when this was evaluated many years ago no other
platform had working compilers.
That fact alone is likely to make the fsin,fcos path faster then the C
version for the +-PI/4 range for those platforms.

Its some work to check the current status for the different
platforms/compilers regarding if they are still producing bad code with opts
or not,
its however reasonable to expect the compilers to improve over the years.

Regarding the proposed patch, sharedRuntimeTrig.cpp usage for the entire
input range without external rounding:
I compare with 3 input,output pairs that has leaked from the JCK, and vs the
current Math impl for many input,output pairs and i don't manage to detect
any differences.

There is consistent performance improvement for all input ranges, i get up
to 40% improvement for intel core2 on solaris.

Its hard for me to know if there are some corner cases that do require the
external rounding in order to stay within the spec, thats the reason i asked
for help here.


-- 
regards
 gustav trede
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/hotspot-dev/attachments/20090805/f61ad3db/attachment.html 


More information about the hotspot-dev mailing list