Very fast log implementation with adjustable accuracy
Gerald Friedland
fractor@icsi.berkeley.edu
Tue Jun 26 18:20:00 GMT 2007
Dear list,
I have never posted here before, so I don't know if am writing to the
right place. The GNU C library PROJECT file says that you are
interested in "optimized versions for some functions" (point 8) and
hints to this address.
A colleague and I were optimizing a machine learning algorithm and
found the bottleneck to be the computation of the log(). We wanted to
have a hardware-independent solution and found that using the
-ffast-math compiler flag and/or using the logf() function did not
solve the problem. A lower-degree Taylor approximation "fastlog2()" as
proposed at
http://www.flipcode.com/cgi-bin/fcarticles.cgi?show=63828
was not accurate enough for us.
Thinking about the problem, we found a different solution. It improves
in speed over fastlog2() while being several orders of magnitude more
accurate.
We describe it in a technical report that can be found here:
http://www.icsi.berkeley.edu/pubs/techreports/TR-07-002.pdf
We created a small package that contains the 20-line algorithm and a
small benchmark application. It can be found here:
http://www.icsi.berkeley.edu/~fractor/icsilog.tar.gz
Is this something you might find useful to integrate into the GNU C
library so that it is generally available?
Gerald
--
Dr. Gerald Friedland
International Computer Science Institute
1947 Center Street, Suite 600
CA-94704 Berkeley, USA
Office: +1/510/666-2980
Mobile: +1/510/529-6514
http://www.gerald-friedland.org
More information about the Libc-alpha
mailing list