OpenCL: Manually throw an exception in kernel

蓝咒 提交于 2019-12-10 16:09:56

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!