clGetProgramBuildInfo不打印构建日志 [英] clGetProgramBuildInfo does not print build log

查看:168
本文介绍了clGetProgramBuildInfo不打印构建日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在OpenCL中编写了代码.构建内核程序时出错.错误代码为-11.我尝试打印"BUILD LOG",但它不打印正确的日志,而是生成一些随机变量.这是那部分

I have written a code in OpenCL. There is an error while building the kernel program. The error code is -11. I tried printing the BUILD LOG but it does not print a proper log but instead it generates some random variables. Here is that part

//these are variable declarations
cl_device_id* devices;
cl_program kernelprgrm;
size_t size;
//these varaibles have already been assigned properly

//main code
clGetProgramBuildInfo(kernelprgrm,devices[i], CL_PROGRAM_BUILD_LOG ,0,NULL,&size);
char *buildlog=(char*)malloc(size);
clGetProgramBuildInfo(kernelprgrm,devices[i], CL_PROGRAM_BUILD_LOG ,size,buildlog,NULL);
printf("\n\nBuildlog:   %s\n\n",buildlog);

它给出以下输出:-

Buildlog:   ���0

请帮助我获取正确的构建日志.谢谢

Please help me in getting a proper build log. Thanks

推荐答案

我在我的计算机上测试了此代码,它可以正常工作:

I tested this code on my machine and it works ok:

size_t len = 0;
cl_int ret = CL_SUCCESS;
ret = clGetProgramBuildInfo(program, device_id, CL_PROGRAM_BUILD_LOG, 0, NULL, &len);
char *buffer = calloc(len, sizeof(char));
ret = clGetProgramBuildInfo(program, device_id, CL_PROGRAM_BUILD_LOG, len, buffer, NULL);

看起来很像您的代码,就会有2个差异,这可能会产生错误:

As soon as it looks pretty much like your code, there are 2 differences, which may produce error:

  • 检查返回码
  • 检查阵列中设备的索引.可能是您想从错误的设备获取日志.

这篇关于clGetProgramBuildInfo不打印构建日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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