Math trig intrinsics and compiler options
gustav trede
gustav.trede at gmail.com
Thu Jul 16 08:49:48 PDT 2009
2009/7/16 gustav trede <gustav.trede at gmail.com>
>
>
> 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
>>
>
>
on opensolaris 118 x64 core2 with the patch applied i get 44 cycles as
cost per Math cos , sin on average, including the loop overhead for the 0
to PI/4 range .
what cost do you get with fcos , fsin in this test ? :
private void dotest(final double start, final double end){
final int innerIter = 150000;
final int iter = 5000;
double ret = 0;
long t1= System.nanoTime();
for (int i=0;i<iter;i++)
ret+=trigcalc(start, end, innerIter);
double tsmall= ((System.nanoTime()-t1)/(2.0d*iter*innerIter));
double Mpersec = ((int)(100000 / tsmall))/100d;
System.out.println(""+start+" to "+end+" : "+ Mpersec+"
millions/sec , ret:"+ret);
}
private double trigcalc(final double start, final double end, final int
innerIter){
double ret = 0;
double delta = (end-start)/innerIter;
for (double i=start;i<end;i+=delta ){
ret += Math.sin(i)+Math.cos(i);
}
return ret;
}
--
regards
gustav trede
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/hotspot-dev/attachments/20090716/0c50bdc9/attachment.html
More information about the hotspot-dev
mailing list