问题
Is it possible to manually throw an exception in OpenCL, just for debugging purposes? I am having a very strange error in my code: when I computed two double values and add them up, the host reports "CL_OUT_OF_RESOURCE". However if I don't add these two values, the host doesn't report any error.
回答1:
Exceptions are not supported in OpenCL - it is based on the C99 language.
On AMD GPUs you can use printf
inside the kernel - see the cl_amd_printf
extension. To use, put this at the top of your .cl file:
#pragma OPENCL EXTENSION cl_amd_printf : enable
来源:https://stackoverflow.com/questions/12245247/opencl-manually-throw-an-exception-in-kernel