Any way to understand is GPU occupied

Hi all,

My question is related concurrent cuda kernels. I am wondering is there any way to understand, gpu is occupied by some kernels? It means, even if I enqueue yet another kernel, it is not able to execute right now.

Thanks in advance

You could issue an event to the device (cudaEventRecord()) then issue a call to cudaEventQuery() (with that event).

http://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__EVENT.html#group__CUDART__EVENT_1g2bf738909b4a059023537eaa29d8a5b7

If the call to cudaEventQuery returns cudaSuccess, then the device is not busy. It is of course still possible to launch a new kernel even if the device is busy. And depending on how the busy device is occupied, it may even be possible for a new kernel launch to begin executing on the device, even when the device is still busy.