python - strange values when get the variable from the host -
i have kernel below:
# compile device.cu mod = sourcemodule(''' #include<stdio.h> __global__ void test(unsigned int* tab, unsigned int compteurinit) { unsigned int gid = threadidx.x + blockdim.x * (threadidx.y + blockdim.y * (blockidx.x + blockidx.y * griddim.x)); tab[gid] = compteurinit; printf("%d ",tab[gid]); }''', nvcc='/opt/cuda65/bin/nvcc', )
and here host program
kern = mod.get_function("test") xgrid = 256 ygrid = 1 xblock = 256 yblock = 1 etat=np.zeros(xblock * yblock * xgrid * ygrid,dtype=np.uint) etat_gpu= gpuarray.to_gpu(etat) kern(etat_gpu,np.uint(10),block=(xblock,yblock,1),grid=(xgrid,ygrid,1)) print etat_gpu.get()
when print result have got strange values whereas
like this:
[42949672970 42949672970 42949672970 ..., 0 0 0]
but when check printed value in kernel seems good
Comments
Post a Comment