Unable to copyMem back to host Copy filled matrix back to host

Hello.

I got an error at last operation, cudaMemcpy.

My program work as follow:

  1. Allocate matrix for host and device.

  2. Allocate space for pseudo random number generator (PRNG) //I imitate from matrix allocation.

  3. Launch setup_kernel by passing the state matrix.

  4. Fill the matrix in the device.

  5. Copy result back to host.

Result from prgram.

sarit@AH64D:~/AH64D$ ./a.out

============CPU===============

0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 

1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 

2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 

3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 

4.0 5.0 6.0 7.0 8.0 9.0 10.0 11.0 

5.0 6.0 7.0 8.0 9.0 10.0 11.0 12.0 

6.0 7.0 8.0 9.0 10.0 11.0 12.0 13.0 

7.0 8.0 9.0 10.0 11.0 12.0 13.0 14.0 Error at 2Dcurand.cu:123

I wonder, I must missing something, but I can not figure out.

Regards.
2Dcurand.cu (3.5 KB)

The Problem is with your memory allocation.

It is not

It should be

Thank you so much for your response.

I am about to give up and try CPU PRNG copy to GPU which is a sluggish and waste of flop.

:]