c - cudaMemcpy not responding when copying from device -


I have written the CUDA code for Monte Carlo simulation. I basically have a number of particles and some operations display. To calculate the density in each of my 3D grids, I have an array (on device) where I specify a cell ID for each particle, it is done through the CUDA. I then want to copy the device memory to host the density and the values ​​to be written in the file.

However, when my code is running, cudaMemcpy is not responding and after the statement the code has not been executed. I am worried that I have done something wrong while allocating Array and I will be happy if someone can tell my mistake.

The important part of the code here is:

  size_t sizeInt = dim * numParticles * sizeof (int); ... int * h_cellIndex = NULL; // host err = cudaHostAlloc ((zero **) and h_cellIndex, sizeInt, 0); // int * h_cellIndex = (int *) malloc (sizeInt); & Lt; - Either it did not work either ... int * d_cellIndex = NULL; // device err = cudaMalloc ((zero **) and d_cellIndex, sizeInt); ... // simulation starts ... printf ("copy \ n"); CudaMemcpy (h_cellIndex, d_cellIndex, sizeInt, cudaMemcpyDeviceToHost); Printf ("Copyed \ n");   

As an output, I see printed on the "copy" command line. I

What could be a problem?

Thank you in advance!

I think your simulation is still going on. The kernel's voice is asynchronous, so I think That your kernel is trapped in. Just to call after the colonel's voice, add a call to cudaDeviceSynchronize () and see if it's blocking it instead.

In fact, the kernel is not allowed to return any value, their return value can only be zero , because they are asynchronous and any errors in the kernel next call Synchronize them by: Calling in Stream 0 , a call in a same stream or a clear synchronization.

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -