我在OpenCL中编写了一个代码。构建内核程序时出错。错误代码是-11。我尝试打印BUILD LOG但它不打印正确的日志,而是生成一些随机变量。这是那部分
//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
请帮助我获取正确的构建日志。感谢
答案 0 :(得分:1)
我在我的机器上测试了这段代码,它运行正常:
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);
只要它看起来与您的代码非常相似,就会有两个不同之处,这可能会产生错误: