从主机获取变量时的奇怪值

时间:2015-05-29 13:19:05

标签: python numpy pycuda

我的内核如下所示:

# 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',
           )

这是我的主持人计划

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()

当我打印结果时,我有一些奇怪的值,而

像这样:

[42949672970 42949672970 42949672970 ...,           0           0
           0]

但是当我检查内核中的打印值时似乎很好

0 个答案:

没有答案