Assuming I have a OpenCL driver / environment in which the function clGetPlatformIDs() returns more than one cl_platform_id:
Is it possible to create a create a context including devices from different platforms?
I tried to find an answer in the OpenCL specifications but didn’t found any definitive answer. There are some passage in section 4.3 which makes me think it is not possible but I’d like to be sure on this one.
The devices specified in <devices> argument to clCreateContext must be for the same platform. clCreateContext returns CL_INVALID_DEVICE if devices contains an invalid device or are not associated with the specified platform.
now that i now of this, it is finally clear to me that the sentence
“devices is a pointer to a list of unique devices returned by clGetDeviceIDs for a platform.”
implies this behaviour.
Perhaps it might be a good idea to clarify this point in the OpenCL spec? Something similar to this would have helped me a lot:
“devices is a pointer to a list of unique devices returned by clGetDeviceIDs for a specific platform. Therefor, it is not possible to mix devices from different platforms into one context.”
after reading your answer again it is also clear to me that the sentence
“CL_INVALID_DEVICE if devices contains an invalid device or are not associated with the
also describes this behaviour. Nevertheless, I think an additional sentence like the above might clarify the situation.
In my opinion the restriction is due to vendors having little or no apparent financial incentive to implement that level of interoperability relative to the support it would require. Efficiently managing buffers across platforms and including a compiler optimized for each device requires knowing all the hardware platforms and devices.
The closest thing available to what you seem to want is the IBM OpenCL Common Runtime for Linux, which is a platform wrapper. It hasn’t been updated in awhile and only supports OpenCL 1.1 vendor platforms (and/or devices, I can’t recall exactly).