Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fast atan2




Ben Weiss <email@hidden> wrote:

http://www.shellandslate.com/computermath101.html
Ben

Thanks. I tried it, and (after some translation for gcc) found that the atan2 replacement has good accuracy but is little if any faster than the library atan2.

Hmm... well, thank you for giving it a try. The benchmarks for this code were done four years ago, with CodeWarrior under OS9, and it was tuned for the early G4, which may account for your speed observations. (Library atan2 has no doubt improved as well.) Are you on G4 or G5, and single or double precision?

I compared OS X 10.3.6 atan2( y, x ) with the single version of your function atan2r_.
In converting your CW code to gcc, one line caused many cold beers and hot coffees to be consumed:
real32* asbuf = (real32*)(address(atanbuf_) + ind);
before an (int) cast emerged as a correct conversion:
real32* asbuf = (real32*)((int)&atanbuf_ + ind);


My test suite of {y,x} values included all 8 octants.
gcc flags were -force_cpusubtype_ALL -lmx -O3 -mcpu=G5 -mtune=G5.

atan2r_ is very accurate and measurably faster than atan2:
  atan2r_   |error| = 0.000000
  atan2     elapse : 0.96 s
  atan2r_   elapse : 0.73 s
but I need a speedup of at least 2.

Robert P.

_______________________________________________
Do not post admin requests to the list. They will be ignored.
PerfOptimization-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/perfoptimization-dev/email@hidden

This email sent to email@hidden
References: 
 >Re: Fast atan2 (From: Robert Purves <email@hidden>)
 >Re: Fast atan2 (From: Shaun Wexler <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.