OpenCL:在内核中手动引发异常 [英] OpenCL: Manually throw an exception in kernel
问题描述
是否可以仅出于调试目的在OpenCL中手动引发异常?我的代码中出现一个非常奇怪的错误:当我计算两个双精度值并将它们加起来时,主机报告"CL_OUT_OF_RESOURCE".但是,如果我不添加这两个值,则主机不会报告任何错误.
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.
推荐答案
OpenCL不支持异常-它基于C99语言.
Exceptions are not supported in OpenCL - it is based on the C99 language.
在AMD GPU上,您可以在内核内部使用printf
-请参见cl_amd_printf
扩展名.要使用它,请将其放在.cl文件的顶部:
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
这篇关于OpenCL:在内核中手动引发异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!