cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

chrisgregg
Journeyman III

clWaitForEvents() leads to high CPU usage when kernel is running on GPU

I have a kernel that runs for about 10 seconds on the GPU, and for about 25 seconds if I run it on the CPU.  If I look at the CPU usage percent in 'top' when the kernel is running on the GPU, CPU usage pegs at 100% for the process I'm running when the process is waiting at the clWaitForEvents() function.

When I run the same kernel on the CPU, the usage pegs at 200% (both cores at 100%) while waiting at the clWaitForEvents() function.

Is this something that just needs to be optimized at some point, or is there a better way to wait for the kernel to complete without the CPU overhead (is it just spinning?) when using clWaiForEvents()?  Thanks!

 

0 Likes
1 Reply
genaganna
Journeyman III

Originally posted by: chrisgregg I have a kernel that runs for about 10 seconds on the GPU, and for about 25 seconds if I run it on the CPU.  If I look at the CPU usage percent in 'top' when the kernel is running on the GPU, CPU usage pegs at 100% for the process I'm running when the process is waiting at the clWaitForEvents() function.

 

When I run the same kernel on the CPU, the usage pegs at 200% (both cores at 100%) while waiting at the clWaitForEvents() function.

 

Is this something that just needs to be optimized at some point, or is there a better way to wait for the kernel to complete without the CPU overhead (is it just spinning?) when using clWaiForEvents()?  Thanks!

 

 



Chrisgregg,

                 clWaitForEvents waits for event to complete i.e you can think of it checks condition in while loop. it comes out of while loop only if event is completed.  that is why one code is fully used.  You can use this time efficiently by doing some work on CPU just before clWaitForEvents.

0 Likes