performance of real_fft with fftpacklite.c
Hello, does anyone know why the performance of FFT.real with fftpacklite.c is so unballanced for n=2**i and different values of i? My example is: ======================================================================= from Numeric import array,Float from FFT import real_fft from time import time i=1 while i<20: n = 2**long(i) a=array(range(long(1),n),Float) anfang = time() b = real_fft(a) ende=time() print "i=", i, " time: ", ende-anfang i+=1 ======================================================================= and the result shows (on a Pentium-III-700 under Linux): ================================================================= i= 1 time: 0.000182032585144 i= 2 time: 0.000133991241455 i= 3 time: 0.00012195110321 i= 4 time: 0.000123977661133 i= 5 time: 0.000131964683533 i= 6 time: 0.000155925750732 i= 7 time: 0.000362992286682 i= 8 time: 0.000240921974182 i= 9 time: 0.000506043434143 i= 10 time: 0.00064492225647 i= 11 time: 0.00177395343781 i= 12 time: 0.0025269985199 i= 13 time: 0.886229038239 i= 14 time: 0.0219050645828 i= 15 time: 0.0808279514313 i= 16 time: 0.327404975891 i= 17 time: 482.979220986 i= 18 time: 0.803207993507 i= 19 time: 7782.23972797 ================================================================= when I am using an array a of length 2**19 and giving the command b=real_fft(a,n=2**long(20)) the time drops from over two hours CPU-time to about 1.5 seconds. I know that fftpacklite.c is not specially optimized, but isn't a FFT method with vectors lenghts that are powers of 2 be supposed to show a more predictible run-time behavior? Could perhaps anyone point me to a free FFTPACK FORTRAN package for Linux with g77 that performs better than the default package? Any hint would be greatly appreciated. Best regards, Bernd Rinn P.S.: Please CC to Bernd.Rinn@uni-konstanz.de since I am not a member of the list. -- Bernd Rinn Fakultät für Physik Universität Konstanz Tel. 07531/88-3812, e-mail: Bernd.Rinn@uni-konstanz.de PGP-Fingerprint: 1F AC 31 64 FF EF A9 67 6E 0D 4C 26 0B E7 ED 5C
Bernd Rinn wrote:
Hello,
does anyone know why the performance of FFT.real with fftpacklite.c is so unballanced for n=2**i and different values of i? My example is:
Hi, The problem is that your routine gives arrays of length 2**n-1 not 2**n! So for the arrays where the CPU time is huge, you are FFTing a length that is a prime number (or at least not easily factorable). FFTPACK has to do a brute force DFT instead of a FFT! (Ah, the beauty of n*log(n)...) You can see that this is the case by printing the lengths of the arrays: ------------------------------- from Numeric import array,Float from FFT import real_fft from time import time i=1 while i<20: n = 2**long(i) a=array(range(long(1),n),Float) print len(a) i=i+1 ------------------------------- What you should try instead is the following: ------------------------------- from Numeric import arange,Float from FFT import real_fft from time import time i=1 while i<20: n = 2**i a=arange(n, typecode=Float) anfang = time() b = real_fft(a) ende=time() print "i=", i, " time: ", ende-anfang i=i+1 ------------------------------- Which gives the following run-times on my Pentium 450 under Linux: i= 1 time: 0.000313997268677 i= 2 time: 0.000239014625549 i= 3 time: 0.000229954719543 i= 4 time: 0.000240087509155 i= 5 time: 0.000240087509155 i= 6 time: 0.000257968902588 i= 7 time: 0.000322103500366 i= 8 time: 0.000348091125488 i= 9 time: 0.000599980354309 i= 10 time: 0.000900983810425 i= 11 time: 0.0018150806427 i= 12 time: 0.00341892242432 i= 13 time: 0.00806891918182 i= 14 time: 0.0169370174408 i= 15 time: 0.038006067276 i= 16 time: 0.0883399248123 i= 17 time: 0.199723005295 i= 18 time: 0.661148071289 i= 19 time: 0.976199030876 Hope this helps, Scott -- Scott M. Ransom Address: Harvard-Smithsonian CfA Phone: (617) 495-4142 60 Garden St. MS 10 email: ransom@cfa.harvard.edu Cambridge, MA 02138 GPG Fingerprint: 06A9 9553 78BE 16DB 407B FFCA 9BFA B6FF FFD3 2989
participants (2)
-
Bernd Rinn
-
Scott Ransom