当我在我的OpenCl代码中使用clBuildProgram
时,它会失败,并显示错误代码-11,但没有任何日志信息。
以下是我的代码示例:
ret = clBuildProgram(program, 1, &device_id, NULL, NULL, NULL);
if (ret != CL_SUCCESS)
{
size_t len;
char buffer[2048];
cl_build_status bldstatus;
printf("\nError %d: Failed to build program executable [ %s ]\n",ret,get_error_string(ret));
ret = clGetProgramBuildInfo(program, device_id, CL_PROGRAM_BUILD_STATUS, sizeof(bldstatus), (void *)&bldstatus, &len);
printf("Build Status %d: %s\n",ret,get_error_string(ret));
printf("INFO: %s\n", get_error_string(bldstatus));
ret = clGetProgramBuildInfo(program, device_id, CL_PROGRAM_BUILD_OPTIONS, sizeof(buffer), buffer, &len);
printf("Build Options %d: %s\n",ret,get_error_string(ret));
printf("INFO: %s\n", buffer);
ret = clGetProgramBuildInfo(program, device_id, CL_PROGRAM_BUILD_LOG, sizeof(buffer), buffer, &len);
printf("Build Log %d: %s\n",ret,get_error_string(ret));
printf("%s\n", buffer);
(void)infoinfo(platform_id,device_id);
exit(1);
}
以下是输出的样例:
Error -11: Failed to build program executable [ CL_BUILD_PROGRAM_FAILURE ]
Build Status 0: CL_SUCCESS
INFO: CL_DEVICE_NOT_AVAILABLE
Build Options 0: CL_SUCCESS
INFO:
Build Log -30: CL_INVALID_VALUE
CL_PLATFORM_NAME : NVIDIA CUDA
CL_PLATFORM_VERSION : OpenCL 1.1 CUDA 4.2.1
Device name : Tesla K20m
Driver version : 319.32
Global Memory (MB) : 4799
Global Memory Cache (KB) : 208
Local Memory (KB) : 48
Max clock (MHz) : 705
Max Work Group Size : 1024
Number of parallel compute cores : 13
Is the device available : yes
那么,你们能否偶然发现上面的行中有任何错误或奇怪的地方吗?
谢谢,
Éric。
get_error_string(bldstatus)
所说的那样?需要更多的代码吗? - Michael HaidlclGetProgramBuildInfo
调用方式或者是get_error_string
子程序中使用的错误码定义上。实际上,get_error_string
子程序返回与 OpenCl 错误码对应的字符串。但该代码可能与 cl_build_status 代码不对应! - Éric