2011-08-27

fast double precision exponential function with SSE

I make a fast double precision exponential function using SSE2.

fmath.hpp (https://github.com/herumi/fmath, fast approximate float function fmath)





benchmark of fmath::expd
CPUOScompilerstd::expfmath::expdone element for fmath::expd_v(array version)
Xeon X5650 2.67GHz64-bit Linuxgcc 4.6.0128.8927.3817.84
i7-2600 3.4GHz64-bit Linuxgcc 4.4.569.1112.108.25
i7-2600 3.4GHz64-bit Windows 7VC1036.3314.377.08

The function double fmath::expd(double) defined in fmath.hpp is about five time faster than std::exp of gcc-4.6 on 64-bit Linux and about two point five faster than that of Visual Studio 2010 on 64-bit Windows.

The error of rms (Root Mean Square) for 1000000 points generated from standard normal distribution is about 1.117645e-16.

The source code for benchmark is fastexp.cpp, which requires Xbyak.

I write some results for various environments in the comment of the header of fastexp.cpp.

Moreover, fmath.hpp provies fmath::exp(float) and fmath::log(float).
These functions are also 2~5 times faster than those of standard library.

Let's try it if you want speed.

No comments: