Reputation: 4903
I'm trying to copy 2D array from CPU to GPU.From host side i'm sending base pointer of 2D array,P is number of elements in one dimension
int *d_a;
cudaMalloc(d_a,P*P*sizeof(int));
copyKernelHostToDevice((int(*)[P])d_a,(int(*)[P])hAligned_a);
copyKernelHostToDevice((int(*)[P])d_b,(int(*)[P])hAligned_b);
inline void copyKernelHostToDevice(int (*A)[P],int (*B)[P]){
for(int i=0;i<P;i++)
cutilSafeCall(cudaMemcpyAsync(A[i],B[i],P*sizeof(int),cudaMemcpyHostToDevice));
}
but above code is giving me runtime error
cudaSafeCall() Runtime API error 11: invalid argument.
Am I missing something? P is significantly large...arnd 2048
Upvotes: 0
Views: 1781
Reputation: 72348
It looks like d_a
isn't a valid device pointer, because your cudaMalloc
call looks to be incorrect. It should be something like this:
int *d_a;
cudaMalloc((void **)&d_a,P*P*sizeof(int));
Upvotes: 1