First, it needs to be clarified that C-like order is row-major,
Fortran-like order is column-major.
There is a higher level function in scikits.cuda.fft that you can use.
The inputs there are row-major GPUarrays. Here is a simple example:
import pycuda.gpuarray as gpuarray
import numpy as np
import scikits.cuda.fft as fft
array([[ 21.+0.j , -3.+0.j ],
[ -6.+3.46410162j, 0.+0.j ],
[ -6.-3.46410162j, 0.+0.j ]])
which is the correct answer.
Note that CUFFT library assumes row major order for 2D or 3D transforms.
On 3/19/2011 7:35 PM, killian koepsell wrote:
I came across the following problem: I was using cufft (using the
ctypes wrapper provided in scikits.cuda)
which returns results in form of pycuda.gpuarrays. However, since the
arrays on the GPU seem to have Fortran (row-major)
ordering and the default ordering for numpy arrays is C
(column-major), the array entries appear to be mixed up.
The problem could be fixed by changing the get method of the gpuarray
class (line 111 in gpuarray.py) from
ary = numpy.empty(self.shape, self.dtype)
ary = numpy.empty(self.shape, self.dtype, order="F")
However, I am new to using pycuda, and I am not sure if C ordering is
assumed in other places. Maybe, somebody can
comment on how to best assure compatibility with the cufft library.
PyCUDA mailing list