[Numpy-discussion] FFTW bindings now implement numpy.fft interface
Sun Feb 17 13:36:50 CST 2013
On Sun, 2013-02-17 at 12:38 -0500, Neal Becker wrote:
> The 1st example says:
> >>> import pyfftw
> >>> import numpy
> >>> a = pyfftw.n_byte_align_empty(128, 16, 'complex128')
> >>> a[:] = numpy.random.randn(128) + 1j*numpy.random.randn(128)
> >>> b = pyfftw.interfaces.numpy_fft.fft(a)
> I don't see why I need to specify the alignment. The fftw library has
> function to allocate aligned arrays that are allocated optimally. Why
> pyfft.n_byte_align_empty just align things correctly without me having
> to tell
> it the alignment?
No very good reason. When I started it was simply easier to have numpy
handle the memory management, which is what is still used, and that
precluded using FFTW's memory manager. It was all written when FFTW
didn't support AVX and so basically 16-byte alignment was all that was
needed. Extending to support 32-byte alignment was done in this
framework because I deemed there were more important things to work on.
It is possible to achieve the same result by replacing the alignment
argument with pyfft.simd_alignment, which acquires the optimum alignment
by inspecting the CPU (on x86/amd64). This isn't obvious from the
tutorial, which is a deficiency borne of limited time.
Why didn't I write a function that does that for you? I'm sure I had a
good reason at the time ;)
Consider this a 0.9.1 feature (i'll add an issue now).
More information about the NumPy-Discussion