Re: Sin & Cos speed worries



Hi

I look after the parallel computing for a company here which does
electromagnetic inversion for geophysical problems - moderately trig
intensive. My thoughts on your problem (and yes, I know you didn't ask
for advice but I'm providing it anyway, ignore the rest of the email if
you want to):

-- until you have a working code and a profile of its execution then
any time you spend optimising the sin cos and sqrt is time wasted --
you simply don't know what the choke points in the code are until
you've profiled it;
-- learn your compiler really really really well, make sure you try all
the options which might have an impact on execution speed; the rate of
return on optimisation effort is far higher for flag-twiddling than it
is for rewriting code;
-- since you're working on dual-core CPUs make sure that the
computation is evenly spread across the 2 cores;
-- if you want to press ahead and optimise blindly, or if you have the
evidence that these functions are the bottlenecks, you have to give up
on the idea that you can write a general purpose routine which will (a)
give you better performance than the out-of-the-box versions AND (b)
give you the same accuracy and robustness; which takes you neatly on to
the next point ...
-- far better idea is to look around for numerical libraries for your
platform (eg NAG, IMSL), get an evaluation copy and test; then do some
more testing, and some more; if you can convince yourself and your lead
programmer that the library routines are faster than the native ones
then buy the library;
-- I don't know your hardware very well, but on our AMD Opterons we use
the AMD-supplied vector trig functions for a lot of work, and they
provide useful speed-up under most circumstances, but not all; does
whoever makes the processors in a Mac provide their own numeric
libraries ?
-- I would look very hard at the advice to use a look-up table rather
than compute the values you need -- this threatens to transform your
program from CPU-bound to memory-access-bound, which is usually a huge
penalty in performance on modern systems;

Regards
Mark Westwood


rgootee@xxxxxxxxx wrote:
I have recently started work on a project that is VERY focused the
execution time of the algorithms. The lead programmer on said project
has said to minimize "sin,cos,and square-roots" to keep the execution
time low.

Unfortunetly some of the algorithms that my group has developed are
extremely sin and cosine intensive. To compensate, one of the algorithm
designers attempted to use "small angle approximations" or basically
just the first three entries of a Taylor series expansion.

When I tested the Taylor series code, against the "math.h sin"
function, it seemed that the "sin" function was faster! I basically
just did a loop over about 100000 random values (the same value for
each method, defined in an array) bounded between 0 - pi and calculated
the overall time.

Does anyone know how "math.h" 's "sin" function is calculated, and a
source to go along with the knowledge? From word of mouth I think it
uses a combination of a lookup table and Taylor expansion.

If its of any help, I am on a dual-G5 running OSX, and I can post the
code as well.

.



Relevant Pages

  • Re: Sin & Cos speed worries
    ... electromagnetic inversion for geophysical problems - moderately trig ... -- until you have a working code and a profile of its execution then ... -- far better idea is to look around for numerical libraries for your ... extremely sin and cosine intensive. ...
    (sci.math.num-analysis)
  • Re: Thoughts on JS library to help with event driven paradigms
    ... only of scheduling the execution after a delay. ... for complicated event-driven systems unless they are thoroughly object- ... other libraries. ... added a bind function that mimics the new Function.prototype.bind to ...
    (comp.lang.javascript)
  • Re: Ads on IBM-MAIN
    ... I don't know who Gerard Postpischil is, but I agree with his post. ... It finds three copies of module ABC, derives the proper TTR for the second copy, and reads that into storage for execution (I have a subroutine to load modules that are neither in overlay nor scatter load); your program never sees this execution. ... In general, any IDENTIFY can confuse source libraries, as the name need not be unique. ...
    (bit.listserv.ibm-main)
  • Re: z/OS static linking
    ... linked" load module and it appears to function just as well. ... We have a sub-routine called SUBR (yes, ... people would abuse deployment by statically linking third party libraries. ... Poor control over deployment and execution environment ...
    (comp.lang.cobol)
  • Re: Is it OK to own a Canadian?
    ... not, & if not why not?, bearing in mind G-d has informed you of his ... he knows the mind of God, why on earth would you think I would claim ... Shooting is not a halachic method of execution. ... ***They criticize and punish sin as much as anyone. ...
    (soc.culture.jewish.moderated)