OpenCL 中错误代码的 perror() 等效项是什么?

发布于 2024-08-24 05:07:50 字数 422 浏览 3 评论 0原文

如果我有类似的事情:

err = clEnqueueReadBuffer(cmdQueue, output, CL_TRUE, 0, sizeof(float) * data_sz, &results, 0, NULL, NULL);

我想做:

if (err != CL_SUCCESS){
    perror("Read Failed!");
}

但是 perror() 不知道像“CL_HOST_OUT_OF_MEMORY”之类的错误常量(可以理解)。

我可以四处 grep 与 opencl 相关的 .h 文件,但这不是一个理想的解决方案。我愿意接受任何其他方便的方法来追踪错误号。我使用的是 OSX Snow Leopard(包括以防万一,但我认为这不相关)

If I have something like:

err = clEnqueueReadBuffer(cmdQueue, output, CL_TRUE, 0, sizeof(float) * data_sz, &results, 0, NULL, NULL);

I'd like to do:

if (err != CL_SUCCESS){
    perror("Read Failed!");
}

But the error constants like "CL_HOST_OUT_OF_MEMORY" and the like are (understandably) not known to perror().

I could go around grepping the .h files associated with opencl, but that is not an ideal solution. I'm open to any other convenient ways of tracking down the error numbers. I'm on OSX Snow Leopard (Including that just in case, but I don't think it's relevant)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

别低头,皇冠会掉 2024-08-31 05:07:50

如果您有 NVIDIA OpenCL SDK,则可以使用 oclUtils 提供的 oclErrorString() 函数。

If you have the NVIDIA OpenCL SDK then you could use the oclErrorString() function provided by oclUtils.

她如夕阳 2024-08-31 05:07:50

目前还没有。我最终以 gluErrorString() 的风格编写了自己的代码。我只是将所有 cl_error 代码粘贴到一个文件中,并处理 Emacs 中的每一行,将其转换为返回常量字符串的 switch 语句内的一堆 case(以允许不连续的条目)。这非常简单,而且非常有用。如果你愿意的话我可以把它贴在某个地方。

There is none currently. I ended up writing my own, in the style of gluErrorString(). I just pasted all the cl_error codes into a file and processed each line in Emacs to convert it into a bunch of cases inside a switch statement (to allow for discontiguous entries) that return constant strings. It was pretty easy, and quite useful. I can post it somewhere if you like.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文