代码:
Octree_t* tarr = (Octree*)malloc(nodes * sizeof(Octree_t));
//nodearray[2]->test = 42;
for (int i = 0; i < cnodes; i++)
{
tarr[i] = *nodearray[i];
}
//printf(" test: %d\n",tarr[2].test); //returns 42
cudaError_t err;
Octree_t* gpu_nodearray;
//allocate storage on gpu
err = cudaMalloc( &gpu_nodearray, cnodes * sizeof(Octree_t) != cudaSuccess );
if ( err != cudaSuccess)
{
printf("1: %s\n", cudaGetErrorString(err));
return;
}
err = cudaMemcpy(gpu_nodearray, tarr, cnodes * sizeof(Octree_t), cudaMemcpyHostToDevice);
if ( err != cudaSuccess)
{
printf("3: %s\n", cudaGetErrorString(err));
return;
}
它编译得很好但是当我运行它时,它返回“3:无效参数”。显然cudaMempy有问题。我已经在这里看了类似的帖子,我找不到我犯的错误。
感谢您的帮助。
答案 0 :(得分:0)
该行
err = cudaMalloc( &gpu_nodearray, cnodes * sizeof(Octree_t) != cudaSuccess );
应该是
err = cudaMalloc( &gpu_nodearray, cnodes * sizeof(Octree_t));