When you are creating the command queue with clCreateCommandQueue, then you pass in a device
. This will be the device that is used for the kernels that are enqueued to this queue.
Whether or not this is a GPU can be found out with with clGetDeviceInfo, by querying the CL_DEVICE_TYPE
. It will return one or a combination of
CL_DEVICE_TYPE_CPU
CL_DEVICE_TYPE_GPU
CL_DEVICE_TYPE_ACCELERATOR
CL_DEVICE_TYPE_DEFAULT
CL_DEVICE_TYPE_CUSTOM
These are by the way the same types that you are passing to clGetDeviceIDs when you obtain the device IDs in the first place. So you might want to restrict this query to CL_DEVICE_TYPE_GPU
right at the beginning, so that you will only obtain the device IDs of GPUs.