构建 opencl 内核失败

标签 build kernel opencl

当我使用 clBuildProgram在我的 OpenCl 代码中,它失败并显示错误代码 -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

那么,只是偶然,你们能在上面的行中看到任何错误或奇怪的东西吗?

谢谢,

埃里克。

最佳答案

看起来您可能错误地使用了 clGetProgramBuildInfo()。第一次调用时,它应该告诉主机上它需要的缓冲区大小:
clGetProgramBuildInfo(program, device_id, CL_PROGRAM_BUILD_LOG, NULL, NULL, &len);
然后在主机上分配内存:
char *log = new char[len] //or whatever you use
然后调用 clGetProgramBuildInfo():
clGetProgramBuildInfo(program, device_id, CL_PROGRAM_BUILD_LOG, len, log, null);

关于构建 opencl 内核失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18973371/

相关文章:

opencv - 如何更改在 OpenCV 中使用 Umat 执行 OpenCL 代码的设备?

c++ - 构建简单 Qt5 应用程序时出错

performance - 减少 Visual Studio 构建时间

C Linux 内核页面干扰先前的变量

kernel - 程序栈和堆,它们是如何工作的?

c++ - OpenCL SHA1 吞吐量优化

opencv - 如何在没有默认YUV2RGB-> RGB2GRAY转换的情况下从H264 4:2:0视频读取Y分量

linux - 我如何解决 "Could not fix timestamps in ..." "...Error: The requested feature is not implemented."

css - 尊重相对 url 引用的构建时 CSS 组合器?

ubuntu - 命令 'ls'内核源代码在哪里?