Hi Killian,
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.autoinit
import pycuda.gpuarray as gpuarray
import numpy as np
import scikits.cuda.fft as fft
A=np.array([[1,2],[3,4],[5,6]],np.float64)
B=gpuarray.to_gpu(A)
C=gpuarray.empty((3,2),np.complex128)
plan=fft.Plan((3,2),np.float64,np.complex128)
fft.fft(B,C,plan)
C

returns
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.
Yiyin

On 3/19/2011 7:35 PM, killian koepsell wrote:
Hi,

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)
to
   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.

Thanks,
   Kilian

_______________________________________________
PyCUDA mailing list
PyCUDA@tiker.net
http://lists.tiker.net/listinfo/pycuda


_______________________________________________
PyCUDA mailing list
PyCUDA@tiker.net
http://lists.tiker.net/listinfo/pycuda

Reply via email to