OpenCL with c++ wrapper - how to convert cl::CommandQueue to cl_command_queue?

c++, opencl

Solution

To get the `cl_command_queue` object, you simply need to use the `()` operator:

cl::CommandQueue cppQueue;
...
cl_command_queue queue = cppQueue();

The same goes for all of the other C++ objects in this header that are wrapping OpenCL runtime objects.

Problem

I am using OpenCL with the CL/cl.hpp c++ wrappers. So I have c++ objects such as e.g. `cl::CommandQueue` instead of `cl_command_queue`. I am also wanting to use AMD's BLAS library, clAmdBlas. The functions there require a `cl_command_queue` as one of their arguments. How do I get `cl_command_queue` from `cl::CommandQueue`?

Original source