Error handling in CUDA kernels

Hi all,

I have a CUDA global kernel whose execution can fail if a condition is not met. Within that kernel I have something like:

if (condition is not met)
return

How can I trigger a CUDA error such that, on the host side, a call to cudaGetLastError() will return a CUDA error code.

If this is not possible, is there a workaround? I guess one can always perform an invalid operation on the device to force an error, but I am looking for a cleaner solution than that.

Thanks a lot,
Olivier

PTX has the [font=“Courier New”]trap[/font] instruction to abort a kernel. I think it still isn’t exposed as an intrinsic function, so you will need to use inline assembly to use it.