Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Killing OpenCL Kernels

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.

like image 795
agrippa Avatar asked Jun 07 '26 05:06

agrippa


1 Answers

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.

like image 175
Eric Bainville Avatar answered Jun 08 '26 18:06

Eric Bainville



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!