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



Well, same problem 2 and 3, but not necessarily 1. I don't think you'd need to conform to every last IEEE rounding rule if it's the "fast" version.


On Jan 20, 2005, at 5:35 PM, Ian Ollmann wrote:


On Jan 20, 2005, at 4:26 PM, John Stiles wrote:



Why doesn't Apple offer sinf/cosf/atan2f/etc? These could provide faster and less accurate results.

same problem.

Ian


On Jan 20, 2005, at 4:27 PM, Ian Ollmann wrote:



On Jan 20, 2005, at 3:52 PM, Shaun Wexler wrote:




On Jan 20, 2005, at 12:53 PM, Ian Ollmann wrote:


Alrighty, once the compiler is defeated, we see that the speed improvement is there:

ollmia:/tmp iano$ gcc -O3 main4.c -Wmost
ollmia:/tmp iano$ ./a.out
best libm   time for 1000 calls: 0.000113 seconds (801939)
best cheesy time for 1000 calls: 0.000017 seconds (800454)



My vectorized version of atan2 that I wrote for MacFOH performs the full rectangular-to-polar conversion, including UNWRAPPED normalized phase and magnitude in decibels, and profiles 30x faster than (float)atan2(y,x) with floats. The atan2f "cheesy" portion of the vectorized code is 24x faster than libm.



It probably should be mentioned at this point (before the inquest starts) that the reason why libm is the way it is is several fold:


1) libm is required to deliver correct results (not sorta correct) including edge cases, with the correct rounding mode, exceptions, etc.
This is expensive because it involves configuring the FPSCR and often quite a bit of branching to deal with edge cases not covered by the general purpose algorithm.
2) libm is required to take a single set of arguments and return a single result.
Read: not enough data -> not enough work to do -> pipeline bubbles
3) libm is sitting behind a dylb stub
..and in certain cases also triggers PIC


So, in summary, it is the way it is because it is required to be so by standards. It is a straw man, set up to be knocked over.

Ian



_______________________________________________
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






_______________________________________________
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

_______________________________________________ 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: 
 >Fast atan2 (From: Robert Purves <email@hidden>)
 >Re: Fast atan2 (From: rick <email@hidden>)
 >Re: Fast atan2 (From: Ian Ollmann <email@hidden>)
 >Re: Fast atan2 (From: Ian Ollmann <email@hidden>)
 >Re: Fast atan2 (From: Ian Ollmann <email@hidden>)
 >Re: Fast atan2 (From: Shaun Wexler <email@hidden>)
 >Re: Fast atan2 (From: Ian Ollmann <email@hidden>)
 >Re: Fast atan2 (From: John Stiles <email@hidden>)
 >Re: Fast atan2 (From: Ian Ollmann <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.