Question

I working with OpenCL and develop code that should be compiled on systems with OpenCL 1.1 while taking advantage of OpenCL 1.2 features when available.

Is it possible to simulate OpenCL 1.1 on a system with OpenCL 1.2?

I'm using Apple OpenCL framework, on Mac, and I want to make sure that the code will work for people who have OpenCL 1.1 (e.g. with Mountain Lion) before pushing the code back to the central repository.

Was it helpful?

Solution

Maybe you could take a look at the cl.hpp from the Khronos Group.

Link to the header only library: http://www.khronos.org/registry/cl/

Link to an short example: http://www.thebigblob.com/using-the-cpp-bindings-for-opencl/

This is a C++ OpenCL wrapper which delivers you OpenCL 1.0, 1.1 or 1.2 support depending on the OpenCL header versions in your system path. I think you could go a way like this to reach that at compile time.

If you have newer headers, but you want to restrict the version you can take a look at this thread: Cannot compile OpenCL application using 1.2 headers in 1.1 version

Or do you want to choose the appropriate OpenCL functions at runtime?

OTHER TIPS

See my answer on this thread

You can call can set the options of clBuildProgram as follows

const char options[] = "-cl-std=CL1.1";

clBuildProgram( program, 1, &devices, options, NULL, NULL );

This forces the compiler to use OpenCL 1.1 no matter which version is supported by your device

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top