OT : Approximate / fast math libraries ?

Alan Cox alan at lxorguk.ukuu.org.uk
Sat Sep 1 14:41:33 UTC 2007


On Sat, 1 Sep 2007 11:28:28 +0100
Chris Jones <jonesc at hep.phy.cam.ac.uk> wrote:

> 
> > Another poster mentioned that pentiums
> > have hardware instructions for trig functions.
> > If you are using them, there isn't much hope for speed up.
> 
> Out of interest, whats needs to be done to use these, some gcc flag ? My 
> profiling suggests that atan2(x,y) is taking ~ 50% of some method speed. Yes, 
> the methods is already fast, but still is this reasonable if hardware 
> instructions are being used. Is there some way I can check to see exactly 
> what is used ?

You can use the binutils tools to disassemble the code if you want, or
gdb to trace the instructions and step them (stepi) one at a time.

The Intel hardware FP is pretty fast especially on the later processors
and there's probably not a lot you can do to beat it. The AMD processors
have some limited low precision trig functions in the 3DNow extensions
designed for fast 3D gaming (before the cards started doing all the
work ;))

Failing that small lookup tables are about the only option although if
your precision is high the cache miss cost rapidly exceeds the gain from
avoiding the FP math.

Alan




More information about the fedora-list mailing list