[Numpy-discussion] Single-Precision FFT

Robert Kern robert.kern at gmail.com
Thu May 24 14:14:41 EDT 2007


Benjamin M. Schwartz wrote:
> I am working on two programs using NumPy for the OLPC project.  In both cases
> the performance is limited by the FFT. The OLPC machine uses a AMD Geode CPU,
> which is generally slow, but especially bad at double-precision floating point.
> It would be a major improvement if we could compile NumPy to use complex64 for
> FFTs instead of complex128, and might even increase the probability of NumPy
> being provided as a learning tool to millions of children.
> 
> I know that FFTW can be compiled to run in single precision.  What would it take
> to make NumPy use a single-precision FFT library?
> 
> If absolutely necessary, it might be possible to ship a patched version of
> NumPy, but any other solution would be preferable.  A compile-time configuration
> option in NumPy would be ideal.

I'd prefer not to put in such an option. Options are bad. It means that the same
program will give different results on different machines depending on how the
person compiled numpy.

Instead, you might want to consider porting the fftpack_lite module in numpy to
use single precision (fairly easy) and distribute it separately. That's probably
the fastest approach, but it's a bit isolating.

An approach that takes a little bit more work, but is probably better in the
long run is to help us provide *both* single-precision and double-precision
FFTs. This would involve copying fftpack.c, renaming the functions and
re-#defining Treal to be "float" instead of "double", then modifying the
functions in fftpack_litemodule.c to use either the single-precision or the
double-precision functions depending on the type of the input (or possibly a
keyword argument; there is a small issue of backwards compatibility, here).

Which approach would you like to take?

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco



More information about the NumPy-Discussion mailing list