• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: sin() optimization on PowerPC and Intel
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sin() optimization on PowerPC and Intel


  • Subject: Re: sin() optimization on PowerPC and Intel
  • From: Ian Ollmann <email@hidden>
  • Date: Tue, 27 Jun 2006 12:36:01 -0700

 I heard that on Intels the sin() function is actually
implemented in CPU instructions, and that is why it works so fast.
Is this true?

Currently on MacOS X for Intel, the various libm (math library) sine and cosine functions are routed through sinl and cosl, which do in fact currently already use the fsin Intel instruction. While the Intel instruction is reasonably speedy, we think we can actually do better in software and will attempt to do so in the future. We are also looking at doing argument reductions with an infinitely precise PI. When/if that happens, expect that the results returned from sine and cosine (and tangent) will change for very large inputs. They are currently increasingly inaccurate the farther you get from zero.


There are some things you can try right now. You can try vForce in Accelerate.framework. This has vectorize sine and cosine functions if you can set up your data to provide an array of inputs and receive an array of sines/cosines. There is even a function that will produce both sine and cosine from a single array of inputs. Look for vvsinf (), vvcosf() and vvsincosf().

http://developer.apple.com/documentation/Performance/Reference/ vecLibRefUpdate/Articles/vecLib.html

Another thing you can do if you need the sines and cosines at uniform intervals around the unit circle is calculate the first sine/cos pair and then rotate those using a small Euler matrix to get the rest:

	http://mathworld.wolfram.com/RotationMatrix.html

If you include <TargetConditionals.h> you can use TARGET_CPU_X86 or TARGET_CPU_PPC.

A lower level thing you can do that requires no headers is use the following:


#if defined( __ppc__ ) || defined( __ppc64__ )
	//do the ppc thing
#elif defined( __i386__ )
	//do the i386 thing
#else
	#error I don't know what thing to do
#endif

Ian
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: sin() optimization on PowerPC and Intel
      • From: Artemiy Pavlov <email@hidden>
  • Prev by Date: Re: sin() optimization on PowerPC and Intel
  • Next by Date: Re: sin() optimization on PowerPC and Intel
  • Previous by thread: Re: sin() optimization on PowerPC and Intel
  • Next by thread: Re: sin() optimization on PowerPC and Intel
  • Index(es):
    • Date
    • Thread