杀死OpenCL内核 [英] Killing OpenCL Kernels

查看:105
本文介绍了杀死OpenCL内核的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过OpenCL API杀死正在运行的OpenCL内核?我还没有在规格中找到任何东西.

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

我能提供的唯一解决方案是1)定期检查主机要停止内核时主机写入的内核中的标志,或2)在单独的进程中运行内核并终止整个进程.我认为这都不是非常优雅的解决方案,而且我不确定#1能否可靠地工作.

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.

推荐答案

否,OpenCL API不允许中断正在运行的内核.在某些系统上,运行时间超过几秒钟的内核将被驱动程序杀死.

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.

参考对于Windows:超时检测和恢复通过WDDM的GPU ,以及适用于Linux + NVidia的GPU:使用CUDA和X .

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

该标准中的任何内容均不能保证您的选项1可以正常工作.几乎可以肯定不会. 您的选项2可以使用,但是随后您必须与其他进程进行通信.

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.

这篇关于杀死OpenCL内核的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆