Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

Journeyman III

Detecting which functions are available depending on platform


I have multiple OpenCL implementations on one PC. The Stream SDK, with OpenCL 1.1 support, and ... one implementation from another graphics card vendor, which does not yet support OpenCL 1.1.

This means that there are two platforms available, which support different versions of OpenCL. OpenCL is wrapped away in a DLL. When using this DLL to call an OpenCL 1.1-function (like clCreateSubBuffer), implicitly using the OpenCL 1.0 platform, the program dies painfully.

Theoretically, it would be possible to

- detect the context from the given memory object

- detect the devices for the context

- detect the platforms for the devices

- figure out whether these platforms are all the same, with OpenCL 1.1 support

But of course, this is not practically applicable.

Is there any way to detect at runtime(!) whether such a call is supported? For example, to achieve that a call to a non-supported function always returns a value different to CL_SUCCESS, but without causing a crash or non-recoverable error? One could query all OpenCL versions at startup, and set a flag to programmatically disable all functions which are not supported based on the lowest OpenCL version number, but maybe there is a more elegant and less restraining solution.

Thanks in advance for any hints.




1 Reply

Detecting which functions are available depending on platform

just check versin. IMHO it is better do not run unsupported code than after each cl funtion call check "CL_UNSUPPORTED_FUNCTION_ERROR".

so create two codpath or require certain CL version. and make some wrapper to CL which will shield implementation of CL from rest of the program.