clBuildProgram失败,错误代码为-11,并且没有构建日志 [英] clBuildProgram failed with error code -11 and without build log

查看:628
本文介绍了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失败,错误代码为-11,并且没有构建日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆