[PyCUDA] question re complex pow
Andreas Kloeckner
lists at informa.tiker.net
Sun Jan 30 14:42:06 PST 2011
Hi Lev,
On Sun, 2 Jan 2011 17:45:46 -0500, Lev Givon <lev at columbia.edu> wrote:
> I recently attempted to run the following code with CUDA 3.2 and
> Pycuda 0.94.2 on a Quadro NVS 290 installed on a Linux x86_64 system:
>
> import pycuda.gpuarray as gpuarray
> import pycuda.driver as drv
> import pycuda.autoinit
> import numpy as np
>
> from pycuda.compiler import SourceModule
> func_mod = SourceModule("""
> #include <pycuda/pycuda-complex.hpp>
> #define TYPE pycuda::complex<float>
>
> __global__ void func(TYPE *a, TYPE *b, int N)
> {
> int idx = threadIdx.x;
> if (idx < N)
> b[idx] = pow(a[idx], 2);
> }
> """)
>
> func = func_mod.get_function("func")
>
> N = 10
> a = np.complex64(np.random.rand(N)+np.random.rand(N)*1j)
> b = np.complex64(np.zeros(N))
>
> func(drv.In(a), drv.Out(b), np.uint32(N), block=(512,1,1))
> print 'in: ', a
> print 'out (cuda): ', b
> print 'out (np): ', a**2
This should be fixed in git. Note that you should include
<pycuda-complex.hpp>, not <pycuda/pycuda-complex.hpp>.
Thanks for the report,
Andreas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.tiker.net/pipermail/pycuda/attachments/20110130/51a48e96/attachment.pgp>
More information about the PyCUDA
mailing list