22

When I call a kernel with ill-set parameters (e.g. more than 512 threads per block) or when the operations inside it require more than what my device has to offer (e.g. too many registers) the kernel is simply not executed. There is no exception or return value to indicate what happened though.

I'd like to know if there's a way to verify if a kernel was executed or not.

karlphillip
  • 92,053
  • 36
  • 243
  • 426
Renan
  • 1,910
  • 4
  • 22
  • 36

2 Answers2

34

try this

kernel<<<blocks, threads>>>(params);
cudaError_t err = cudaGetLastError();
if (err != cudaSuccess) 
    printf("Error: %s\n", cudaGetErrorString(err));

This should give you a detailed error about what went wrong.

EDIT: Here's a more detailed answer about how to properly check errors in CUDA:

Community
  • 1
  • 1
Pavan Yalamanchili
  • 12,021
  • 2
  • 35
  • 55
2

Also you could print something from the kernel. This may be useful for debugging.

amanda
  • 394
  • 1
  • 9