开发者

Possible to run OpenCL program at low priority (be "nice")?

开发者 https://www.devze.com 2023-02-16 09:58 出处:网络
I have an OpenCL Windows program that does heavy number crunching and happily consumes 100% of the GPU. I\'d like to be able to run it in the background while using the computer normally, but right no

I have an OpenCL Windows program that does heavy number crunching and happily consumes 100% of the GPU. I'd like to be able to run it in the background while using the computer normally, but right now it causes considerable desktop lag and makes any 3d application unusable.

Is there a way to set a priority in OpenCL so that it will yield GPU power to other processes 开发者_运维技巧and only use spare cycles?


Unfortunately most GPU's do not support running several tasks at a time, and so there is no way to assign priority. This means that when your OpenCL kernel is running, it is the only task being executed by the GPU and that will be the case until the kernel is complete.

If you want the computer to be usable while running the kernel (normal desktop activity, browsing, videos, games) each kernel iteration would have to be very quick. So if you can reduce the time taken by each set of kernel launches (i.e. each job enqueued with clEnqueueNDRangeKernel) you might get what you're looking for. This could be achieved either through making the NDRange smaller, though it needs to be big enough to be efficient on the GPU. Something like 5120 work-items is what I've found to be the minimum on Radeon HD 5870. Or you could reduce the amount of work in each kernel.

If you can get the execution time of each enqueued job down to maybe 1/60 of a second, there's a good chance the computer will be usable. I've been able to run OpenCL programs where each enqueue takes about 1/120 of a second while gaming without noticing anything.

0

精彩评论

暂无评论...
验证码 换一张
取 消