[SciPy-dev] patches for Intel MKL fft support (complex only)

John Travers jtravs at gmail.com
Wed Sep 20 12:25:20 CDT 2006


Hi all,

Attached are two patches that combined will enable support for the use
of Intel MKL fft library calls in scipy.fftpack. At the moment only
complex transforms zfft and zfftnd and their inverses are supported.
Convolution and real transforms are in progress.

The motivation for this work is that the MKL fft's are considerably
faster than fftw.
The benchmarks below show a speedup of between 0x and 2x (and probably
more for arrays larger than 8192) which is certainly significant for
my work ( approx 30% speed up of my code when using MKL vs fftw.

The first patch: mkl_fft_numpy.patch, is against numpy to enable
selection of MKL for the fft library in system_info.py of
numpy.distutils. I'm not sure if this is implemented correctly as
system_info.py seems a little bit mysterious to me. It does however
work! (on my system). If possible it selects MKL over fftw/djbfft etc.
as MKL is faster, but still uses fftw for the real data tarnsforms at
the moment.

The second patch:  mkl_fft_scipy.patch, is against scipy and modifies
Lib/fftpack/src fftpack.h zfft.c zfftnd.c, to give complete support
for the complex transforms, following the spirit of the previous
contents of those files.

When applied and rebuilt all tests pass on my GNU/Linux based x86_64
intel system using gcc and intel ifort.

I hope someone will take the time to commit and test these patches on
their systems.

Thanks,
John Travers

Just as a teaser some comparison benchmarks are added below:

>>>> With MKL (note real data versions are not implemented).

=================================================
      |    real input     |   complex input
-------------------------------------------------
 size |  scipy  |  numpy  |  scipy  |  numpy
-------------------------------------------------
  100 |    0.20 |    0.17 |    0.15 |    0.14  (secs for 7000 calls)
 1000 |    0.13 |    0.18 |    0.09 |    0.15  (secs for 2000 calls)
  256 |    0.31 |    0.23 |    0.17 |    0.20  (secs for 10000 calls)
  512 |    0.31 |    0.38 |    0.20 |    0.31  (secs for 10000 calls)
 1024 |    0.05 |    0.07 |    0.03 |    0.05  (secs for 1000 calls)
 2048 |    0.09 |    0.12 |    0.05 |    0.11  (secs for 1000 calls)
 4096 |    0.07 |    0.11 |    0.04 |    0.11  (secs for 500 calls)
 8192 |    0.15 |    0.27 |    0.10 |    0.26  (secs for 500 calls)

>>>> With fftw2

Fast Fourier Transform
=================================================
      |    real input     |   complex input
-------------------------------------------------
 size |  scipy  |  numpy  |  scipy  |  numpy
-------------------------------------------------
  100 |    0.19 |    0.16 |    0.15 |    0.13  (secs for 7000 calls)
 1000 |    0.13 |    0.18 |    0.13 |    0.16  (secs for 2000 calls)
  256 |    0.31 |    0.27 |    0.25 |    0.23  (secs for 10000 calls)
  512 |    0.37 |    0.44 |    0.32 |    0.32  (secs for 10000 calls)
 1024 |    0.05 |    0.06 |    0.05 |    0.06  (secs for 1000 calls)
 2048 |    0.08 |    0.12 |    0.09 |    0.11  (secs for 1000 calls)
 4096 |    0.07 |    0.12 |    0.09 |    0.10  (secs for 500 calls)
 8192 |    0.15 |    0.27 |    0.18 |    0.25  (secs for 500 calls)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mkl_fft_numpy.patch
Type: application/octet-stream
Size: 1193 bytes
Desc: not available
Url : http://projects.scipy.org/pipermail/scipy-dev/attachments/20060920/5e00c8f8/attachment.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mkl_fft_scipy.patch
Type: application/octet-stream
Size: 7830 bytes
Desc: not available
Url : http://projects.scipy.org/pipermail/scipy-dev/attachments/20060920/5e00c8f8/attachment-0001.obj 


More information about the Scipy-dev mailing list