Hello, I measured the execution time of a 2^20 point FFT in MATLAB. It takes 703ms do do one 2^20 point complex FFT in MATLAB. If I do a 2^20 complex FFT in C it takes 3.3 seconds. How come it takes 4 times longer in C compared to in MATLAB? Has anyone compared the Intel Math Kernel Library (MKL) FFT with MATLAB in terms of execution time? Thanks for any replies.
Execution times of FFT in MATLAB vs complex FFT in C
Started by ●May 29, 2004
Reply by ●May 29, 20042004-05-29
"Anders" <andbuv@yahoo.com> wrote in message news:871e4cdf.0405291203.61512885@posting.google.com...> Hello, > > I measured the execution time of a 2^20 point FFT in MATLAB. > It takes 703ms do do one 2^20 point complex FFT in MATLAB. > If I do a 2^20 complex FFT in C it takes 3.3 seconds. > > How come it takes 4 times longer in C compared to in MATLAB?The FFT in matlab is essentially a highly opimized DLL (written by Mathworks) call. I suspect the C function is not nearly as optimized. Try using the fftw libraries and compare performance.> > Has anyone compared the Intel Math Kernel Library (MKL) > FFT with MATLAB in terms of execution time? > > Thanks for any replies.
Reply by ●May 29, 20042004-05-29
> Has anyone compared the Intel Math Kernel Library (MKL) > FFT with MATLAB in terms of execution time?Hello, I've written a relatively efficient radix 2 fft engine for a commercial voice quality measurement product (while I was working) which largely modelled the one in Numerical Recipe. Then a customer of that product demanded many folds of increase in processing speed. So I replaced my fft with the one in MKL ie using Intel's signal processing library. The performance was 5 folds increased in performance. (Funny thing that customer was Intel!) I did some research. Apparently, most people find integrating the fft in Intel's library in general does indeed give 5 times of speed enhancement. So I wasn't the only one who discovered this miracle. I think the speed gained using Intel library are 2 folds. 1/ The engineers there write very good and efficient code. 2/ The library is MMX enhanced. I think the latter is important. I suspect the fft in matlab is optimized for intergrating in their kernel, so explained the speed. I wonder if anyone see the same amount of speed performance using Intel's library with AMD's processor (which is also MMX compatible). FD
Reply by ●May 30, 20042004-05-30
Anders wrote:> > Hello, > > I measured the execution time of a 2^20 point FFT in MATLAB. > It takes 703ms do do one 2^20 point complex FFT in MATLAB. > If I do a 2^20 complex FFT in C it takes 3.3 seconds. > > How come it takes 4 times longer in C compared to in MATLAB?You probably have a poor C implementation of the FFT. Have you tried FFTW: http://www.fftw.org/> Has anyone compared the Intel Math Kernel Library (MKL) > FFT with MATLAB in terms of execution time?No, nor have I compared FFTW. Erik -- +-----------------------------------------------------------+ Erik de Castro Lopo nospam@mega-nerd.com (Yes it's valid) +-----------------------------------------------------------+ A good debugger is no substitue for a good test suite.
Reply by ●May 30, 20042004-05-30
In article <2hso3iFgvtatU1@uni-berlin.de>, "Bhaskar Thiagarajan" <bhaskart@deja.com> wrote:> "Anders" <andbuv@yahoo.com> wrote in message > news:871e4cdf.0405291203.61512885@posting.google.com... > > Hello, > > > > I measured the execution time of a 2^20 point FFT in MATLAB. > > It takes 703ms do do one 2^20 point complex FFT in MATLAB. > > If I do a 2^20 complex FFT in C it takes 3.3 seconds. > > > > How come it takes 4 times longer in C compared to in MATLAB? > The FFT in matlab is essentially a highly opimized DLL (written by > Mathworks) call. > I suspect the C function is not nearly as optimized. Try using the fftw > libraries and compare performance.Matlab *uses* FFTW. Ken P. -- Remove _me_ for e-mail address
Reply by ●May 30, 20042004-05-30
Anders wrote:> Hello, > > I measured the execution time of a 2^20 point FFT in MATLAB. > It takes 703ms do do one 2^20 point complex FFT in MATLAB. > If I do a 2^20 complex FFT in C it takes 3.3 seconds. > > How come it takes 4 times longer in C compared to in MATLAB? > > Has anyone compared the Intel Math Kernel Library (MKL) > FFT with MATLAB in terms of execution time? > > Thanks for any replies.If I were MatLab I would write (or find, or buy -- there's other posts about MathWorks using FFTW) a custom assembly language routine. On a Pentium I'd use MMX, which if I'm not mistaken means that I'd convert the vector to fixed-point, do my math, then convert back. I would expect a significant (50% to 300%) improvement just from using hand-optimized assembly, more yet from using MMX. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com