CUDA – Get Error From Kernel Call

When a kernel encounters an error it does not notify the runtime of any errors. One has to explicitly query the last error that occurred, if any.
Below is an example of how to do this.

// call the kernel
SomeKernel<<<n,m>>>(); 

// wait for the kernel to finish executing before continuing
cudaThreadSynchronize();   

// check for error
cudaError_t error = cudaGetLastError();
string lastError = cudaGetErrorString(error);
Was my post helpful? :)
Leave a Comment

Notify via Email Only if someone replies to My Comment