0
votes

I have problems with my OpenCL-Code, that crashes at the marked position, but only for my nvidia gpu (OpenCL 1.1) (the intel platforms (OpenCL 1.2 and OpenCL 2.0) behave well).

   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;
}

I've no idea why it crashes and how to fix it.

Edit: my debugger says that ids is a valid pointer and n=1 (in the case of crash)

1

1 Answers

2
votes

Do you have a recent version of the header? Does it have the "isReferenceCountable" function in it?

Earlier versions of the header suffered from a problem that NVIDIA (incorrectly) releases a 1.2 cl.h with a 1.1 ICD. The C__ header has no way to know that this is a link error because cl.h reports a 1.2 version flag and calls clRetainDevice blindly, which segfaults because it isn't implemented in the ICD.

Later versions of the header worked around this by performing a version check against the device version and avoiding calling retain/release. If you are in that situation, then downloading a more recent version of the header should fix it: https://www.khronos.org/registry/cl/api/1.2/cl.hpp

If that doesn't work, where does the debugger report the crash?