Question

How can I be 100% sure that my opencl kernel are actually running on the GPU and not on the CPU. I am not able to understand this because openCL kernel can also run on CPU. Any pointers here?

Was it helpful?

Solution

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.

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