clBuildProgram失败,错误代码为

编程入门 行业动态 更新时间:2024-10-24 22:24:52
本文介绍了clBuildProgram失败,错误代码为-11,并且没有构建日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我现在在OpenCL中工作很少,但是最近"clBuildProgram"在我的一个程序中失败了.我的代码摘录如下:

I have worked little bit in OpenCL now but recently "clBuildProgram" failed in one of my program. My code excerpt is below:

cl_program program; program = clCreateProgramWithSource(context, 1, (const char**) &kernel_string, NULL, &err); if(err != CL_SUCCESS) { cout<<"Unable to create Program Object. Error code = "<<err<<endl; exit(1); } if(clBuildProgram(program, 0, NULL, NULL, NULL, NULL) != CL_SUCCESS) { cout<<"Program Build failed\n"; size_t length; char buffer[2048]; clGetProgramBuildInfo(program, device_id[0], CL_PROGRAM_BUILD_LOG, sizeof(buffer), buffer, &length); cout<<"--- Build log ---\n "<<buffer<<endl; exit(1); }

通常之前,每当"clBuildProgram"失败时,借助"clGetProgramBuildInfo()"函数,我都会在内核文件中获得语法或其他错误,但是当该程序运行时,在控制台上它只会打印:

Normally earlier I got syntax or other errors inside kernel file here with the help of "clGetProgramBuildInfo()" function whenever "clBuildProgram" Failed but when this program runs, on console it only prints:

程序生成失败 ---建立记录---

Program Build failed --- Build log ---

当我尝试打印"clBuildProgram"返回的错误代码时;是"-11" ...... 我没有得到任何构建失败信息的内核文件可能是什么问题?

And when I tried to print the error code returned by "clBuildProgram"; it is "-11"...... What can be the problem with my kernel file that I dont get any build fail information ?

推荐答案

您可以通过在cl.h中进行搜索来了解OpenCL错误代码的含义.在这种情况下,-11就是您所期望的CL_BUILD_PROGRAM_FAILURE.生成日志为空当然很好奇.两个问题:

You can learn the meaning of OpenCL error codes by searching in cl.h. In this case, -11 is just what you'd expect, CL_BUILD_PROGRAM_FAILURE. It's certainly curious that the build log is empty. Two questions:

1.)clGetProgramBuildInfo的返回值是什么?

1.) What is the return value from clGetProgramBuildInfo?

2.)您在什么平台上?如果使用的是Apple的OpenCL实现,则可以尝试在您的环境中设置CL_LOG_ERRORS = stdout.例如,从终端:

2.) What platform are you on? If you are using Apple's OpenCL implementation, you could try setting CL_LOG_ERRORS=stdout in your environment. For example, from Terminal:

$ CL_LOG_ERRORS = stdout ./myprog

$ CL_LOG_ERRORS=stdout ./myprog

在Xcode(编辑方案->参数->环境变量)中进行设置也很容易.

It's also pretty easy to set this in Xcode (Edit Scheme -> Arguments -> Environment Variables).

更多推荐

clBuildProgram失败,错误代码为

本文发布于:2023-11-06 01:22:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1562368.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误代码   clBuildProgram

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!