i’ve been struggling lately on how to deal with assigning and retrieving 2d array CPU <-> GPU.

with lots of help from ‘cudesnick’ <== Thank You.

i now know manipulating multi-dimensional arrays using GPU…

with that, my next test is the following.

i’d like to ( sort of ) initialize 2d array using kernel.

assume that i know how to retrieve 2d array from device (please read through my other conversations, specially, with ‘cudesnick’)

i did the following and got “Cuda error: kernel invocation: invalid configuration arguments.”

can i not directly transfer **c to kernel?

many thanks in advance again.

=============================

**global** void MatAdd(int **c)

{

int i = threadIdx.x;

int j = threadIdx.y;

c[i][j] = 1000;

}

#define X 400

#define Y 300

main(){

…

int **c_d;

CUDA_SAFE_CALL( cudaMalloc((void **)&c_d, X*sizeof(int *)) );

```
dim3 dimBlock(X,Y);
MatAdd<<<1,dimBlock>>>(c_d);
// block until the device has completed
cudaThreadSynchronize();
// check if kernel execution generated an error
// Check for any CUDA errors
checkCUDAError("kernel invocation");
```

…

}