I’m working in an algorithm that has to iterate doing some computation (a specific kernel) in an image until no changes are done (it always converges, no worries). In OpenCL, I’d need each thread to report whether it changed anything or not, to know if I need to run the kernel again.
The most trivial way I can think of to solve this is by using a global boolean. If a thread changes anything, they would set that bool to true, and the host would simply check that value. However, this sounds quite costly. I know I could split this reduction using shared memory to optimize it, but there must be an easier and better way to do this.
Is there a way to send some sort of signal from a thread to the host? There’s no extra data I need to transfer, I just need to be notified with a signal or anything.