Detecting GPU idle time ?


my kernel does some complex computation and blocks the gpu for quite some time, thus making the normal GUI almost unusable; i’ve tested that on Linux, MacOS and Windows. I instantly loose lot of performance when I reduce the size of the input buffer in order to reduce the single-call-runtime and free some time for the GUI so this is not really an option.

My question now is if there is a way to schedule the kernel calls into idle gpu time or detect if e.g. no directx or opengl applications are running; I could fall back to cpu-only computation in that case.

Somehow the nVidia System Tools 6.0.2 (free download from nVidia) allow you to display GPU usage in %. So there must be an API to determine this. However I wonder if this API is public.

On Linux its apparently polled out of the X server.

24550 connect(4, {sa_family=AF_FILE, path="/tmp/.X11-unix/X1"}, 19) = 0

24550 poll([{fd=4, events=POLLIN, revents=POLLIN}], 1, -1) = 1

24550 read(4, “\1\0\270\0\33\0\0\0\1\0\0\0k\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0”, 32) = 32

24550 read(4, “perf=0, nvclock=300, memclock=10”…, 107) = 107

24550 read(4, “\0”, 1) = 1

(300mhz = idle on GTX 280)

Hope this helps.