Problem Description:
CUDA: Return device not ready error when using Cudaeventelapsedtime
Emphasize that I am using Google big God to search the structure Oh!
Http://stackoverflow.com/questions/6551121/cuda-cudaeventelapsedtime-returns-device-not-ready-error
My own environment is using the Tesla C2070 GPU, and I don't know why this problem occurs, but it is possible to solve the problem on the Internet.
The scheme is as follows:
1 cudaerror_t err;2 cudaevent_t start, stop;3Cudaeventcreate (&start);4Cudaeventcreate (&stop);5Err = Cudaeventrecord (Start,0);6F (Err! =cudasuccess) {7printf ("\ n \ 1. Error:%s\n\n", cudageterrorstring (err));8Exit1);9 }Ten //Actual code One cudathreadsynchronize (); AErr = Cudaeventrecord (Stop,0); - if(Err! =cudasuccess) { -printf ("\n\n2. Error:%s\n\n", cudageterrorstring (err)); theExit1); - } -Err = Cudaeventelapsedtime (&Elapsed_time, start, stop); -F (Err! =cudasuccess) { +printf ("\ n \ 3. Error:%s\n\n", cudageterrorstring (err)); -Exit1); +}
The above code is adjusted as follows:
Swap 11 lines of code and 12 lines of code for the position.
That's OK!
However, if the GPU is other structures such as the Fermi architecture, there is no need to modify the reason unknown!
Device not ready Cuda