I managed to find a solution, although it is far from optimal.
I changed the program so that OpenCL processing is done in a separate thread. I created a global watchdog shared variable between the parent and child process. When a parent spawns a processing function as a stream, it sets the variable at the current time in milliseconds. When the processing thread ends, the reset watchdog variable will be zero.
While the parent thread is waiting for the processing thread to complete, it watches the watchdog timer. If the timer exceeds a certain threshold, the program forcibly exits without waiting for the child process to return.
This solution works with or without TDR for Windows. If TDR is installed and the driver is reset, the clFinish () call will never return and the parent will stop working as soon as the watchdog timer goes off. If TDR is not installed, the escape process will freeze the display, but as soon as the watchdog timer is turned off, the parent will finish processing, stopping freezing.
Now that I have a watchdog timer set, I just wrapped my program in a script: if it failed (positive return code), the program will restart again.
source share