Author

Topic: Workaround for Nvidia OpenCL 100% CPU usage on linux. (Read 1058 times)

newbie
Activity: 14
Merit: 0
I'm only guessing here:

During executing the opencl program nvidia opencl library enters loop which checks if the execution of opencl program has ended. At the end of each iteration of the loop sched_yield function is called to move the tasks to the end of system tasks queue, to allow other tasks to run unaffected. But if there are no other tasks scheduled to run it just spins in this loop, eating CPU for nothing - not really a big problem, but eats power and heats up CPU.

In CUDA you can control weather it behaves like this, or use some kind of conditional wait, not spinning in a loop, till the CUDA program finishes.

Probably nvidia could've implemented this mode for OpenCL too, without much effort.
newbie
Activity: 21
Merit: 0
So what exactly causes this issue? A problem in OpenCL or NVIDIA's driver?
newbie
Activity: 14
Merit: 0
Little workaround for nvidia eating 100% CPU when running OpenCL apps.

mk.junkyard.one.pl/libsleep.c

To compile run:
gcc -O2 -fPIC -shared -Wl,-soname,libsleep.so -o libsleep.so libsleep.c

To use:
LD_PRELOAD="./libsleep.so" ./cgminer

You can configure sleep time by setting
YIELD_SLEEP_TIME environment variable (in microseconds)
Default is 1000usec
Example:
YIELD_SLEEP_TIME="1500" LD_PRELOAD="./libsleep.so" ./cgminer

How does it work:
It overrides sched_yield function called during running OpenCL program with call to usleep.
Expect a little performance drop (less than 5%) - adjust YIELD_SLEEP_TIME for your needs.
The longer opencl program running time (ie. higher agression), the lower the performance drop is.

Does someone who is affected by similar problem with ATI cards would be willing to give me access to their system, so i could look up how to resolve this issue with ATI?
Jump to: