Killing OpenCL Kernels

天涯浪子 提交于 2019-12-22 10:13:25

问题


Is there any way to kill a running OpenCL kernel through the OpenCL API? I haven't found anything in the spec.

The only solutions I could come up with are 1) periodically checking a flag in the kernel that the host writes to when it wants the kernel to stop, or 2) running the kernel in a separate process and killing the entire process. I don't think either of those are very elegant solutions, and I'm not sure #1 would even work reliably.


回答1:


No, the OpenCL API doesn't allow to interrupt a running kernel. On some systems, a kernel running for more than a few seconds will be killed by the driver.

Ref. for Windows: Timeout Detection and Recovery of GPUs through WDDM, and for Linux+NVidia: Using CUDA and X.

Nothing in the standard guarantees your option 1 will work. It almost certainly won't. Your option 2 will work, but then you will have to communicate with the other process.

Splitting the kernel in smaller kernels, as suggested in the comments, is probably the best option.



来源:https://stackoverflow.com/questions/16308667/killing-opencl-kernels

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!