OpenCL:cl :: getDevices崩溃

时间:2015-07-23 15:03:28

标签: c++ crash opencl

我的OpenCL-Code出现问题,在标记位置崩溃,但仅限于我的nvidia gpu(OpenCL 1.1)(英特尔平台(OpenCL 1.2和OpenCL 2.0)表现良好)。

   cl::Platform::get(&allPlatforms);

    allDevices.resize(allPlatforms.size());         
       size_t noDevices = 0;
    for (size_t i = 0, end = allPlatforms.size(); i < end; ++i)
    {
        allPlatforms[i].getDevices(CL_DEVICE_TYPE_ALL, &allDevices[i]); //here it crashes
        noDevices += allDevices[i].size();
    }


cl_int getDevices(
    cl_device_type type,
    VECTOR_CLASS<Device>* devices) const
{
  ...

    devices->assign(&ids[0], &ids[n]); //here it crashes
    return CL_SUCCESS;
}

我不知道为什么会崩溃以及如何修复它。

编辑:我的调试器说ids是一个有效的指针,n = 1(在崩溃的情况下)

1 个答案:

答案 0 :(得分:2)

你有最新版本的标题吗?它是否具有&#34; isReferenceCountable&#34;功能呢?

标题的早期版本遇到了NVIDIA(错误地)发布带有1.1 ICD的1.2 cl.h的问题。 C__标头无法知道这是一个链接错误,因为cl.h报告1.2版本标志并盲目调用clRetainDevice,因为它没有在ICD中实现,所以会发生段错误。

标题的更高版本通过对设备版本执行版本检查并避免调用retain / release来解决此问题。如果您处于这种情况,那么下载更新版本的标题应修复它: https://www.khronos.org/registry/cl/api/1.2/cl.hpp

如果这不起作用,调试器会在哪里报告崩溃?