OpenCL:cl::getDevices 崩溃

OpenCL: cl::getDevices crashes

我的 OpenCL 代码有问题,它在标记的位置崩溃,但仅适用于我的 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(在崩溃的情况下)

你有 header 的最新版本吗?它里面有“isReferenceCountable”函数吗?

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

header 的更高版本通过对设备版本执行版本检查并避免调用 retain/release 解决了这个问题。如果您遇到这种情况,那么下载更新版本的 header 应该可以解决这个问题: https://www.khronos.org/registry/cl/api/1.2/cl.hpp

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