11 июля 2011, 08:33 от Andreas Kloeckner <[email protected]>: > Dear Алексей, > > On Fri, 08 Jul 2011 10:33:04 +0400, Алексей Гурин wrote: > > 06 июля 2011, 07:17 от Алексей Гурин: > > > >> When i try to pass double precision argument in this code > >> > >> ########################## > >> import pycuda.autoinit > >> import pycuda.driver as drv > >> import numpy as np > >> from pycuda.compiler import SourceModule > >> > >> mod = SourceModule(""" > >> __global__ void someFunc(double *array,double var,int N) > >> { > >> int i = blockIdx.x*blockDim.x + threadIdx.x; > >> if (i < N) > >> { > >> array[i] = var; > >> } > >> } > >> """,arch="sm_13") > >>(snip) > >> ########################## > >> > >> i get incorrect output > >> > >> [ 2.12204896e-310 2.12204896e-310 2.12204896e-310 ..., > >> 2.12204896e-310 2.12204896e-310 2.12204896e-310] > >> > >> when expected > >> > >> [ 10. 10. 10. ..., 10. 10. 10.] > >> > >> i tried this on pycuda 2011.1.1 and pycuda 2011.1.2 on GeForce GTX > > > > i solved it somehow. When i pass arguments of different sizes like > > double = 8 bytes, int = 4 bytes and pointer to double = 4 bytes, size > > in bytes of all args before double must be a multiple of 8 > > > > for example: > > double*,double,int - incorrect result > > double*,int,double - correct > > double*,int,int,double - incorrect > > > > if i put all 8 byte arguments before 4 byte ones it also works > > correctly > > What kind of system are you on? (OS, Bitness, ...) What seems to be the > case is that Python's struct module and nvcc disagree about alignment on > your system. That's nasty. Unfortunately, I can't seem to provoke a > similar bug on my 64-bit Linux system. > > Andreas
i'm on Ubuntu linux 11.04 32-bit using CUDA 4.0.17. _______________________________________________ PyCUDA mailing list [email protected] http://lists.tiker.net/listinfo/pycuda
