Math trig intrinsics and compiler options
gustav trede
gustav.trede at gmail.com
Wed Jul 15 07:07:54 PDT 2009
2009/7/15 Christian Thalinger <Christian.Thalinger at sun.com>
> gustav trede wrote:
> > Hello,
> >
> > Azeem Jiva told me an easy way to improve trig performance.
> > Changing the intrinsics to use an existing but faster path gives me a
> > boost of roughly 40% for the Math cos and sin on solaris x64.
> >
> >
> > library_call.cpp
> >
> > bool LibraryCallKit::inline_math_
> > native(vmIntrinsics::ID id) {
> > switch (id) {
> >
> > case vmIntrinsics::_dcos: return Matcher::has_match_rule(Op_CosD) ?
> > runtime_math(OptoRuntime::Math_D_D_Type(), CAST_FROM_FN_PTR(address,
> > SharedRuntime::dcos), "COS") : false;
> > case vmIntrinsics::_dsin: return Matcher::has_match_rule(Op_SinD) ?
> > runtime_math(OptoRuntime::Math_D_D_Type(), CAST_FROM_FN_PTR(address,
> > SharedRuntime::dsin), "SIN") : false;
> > case vmIntrinsics::_dtan: return Matcher::has_match_rule(Op_TanD) ?
> > runtime_math(OptoRuntime::Math_D_D_Type(), CAST_FROM_FN_PTR(address,
> > SharedRuntime::dtan), "TAN") : false;
> > case vmIntrinsics::_dlog: return Matcher::has_match_rule(Op_LogD) ?
> > runtime_math(OptoRuntime::Math_D_D_Type(), CAST_FROM_FN_PTR(address,
> > SharedRuntime::dlog), "LOG") : false;
> > case vmIntrinsics::_dlog10: return Matcher::has_match_rule(Op_Log10D)
> > ? runtime_math(OptoRuntime::Math_D_D_Type(), CAST_FROM_FN_PTR(address,
> > SharedRuntime::dlog10), "LOG10") : false;
> >
> >
> > Is there any potential problem with such a patch ?
>
> I'm not sure I understand this "patch". Why should the code above be
> faster than the current code in HotSpot, which tries to inline the
> trigonometric functions? Maybe the speedup you're seeing is because of
> the missing fast/slow path check and you are always using the slow path
> because of rounding? Just a guess...
>
> -- Christian
>
Thats how i interpret the difference too, and correct me if im wrong but
the rounding is only needed for the strictmath to get its platform
independent exact results and not for Math ?.
when testing with the input ranges that matches the different code paths
(PI/4 , 3PI/4, 2^19*(pi/2)) with 1 minute runtime per test i get consistent
improvement of roughly (40%, 100%, 32% ) for Math.sin and similar for cos.
--
regards
gustav trede
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/hotspot-dev/attachments/20090715/c5393f41/attachment.html
More information about the hotspot-dev
mailing list