Hi matteo.cimini1,
I believe the issue is that you’re trying to call “stop” in a kernels region executing in parallel on the GPU. Ideally, I think, what you would do here is instead of calling “stop” if you enter that exit condition, you could update a scalar value to serve as a “flag” to call stop when you exit the kernel. So, after the kernel, you check the scalars value in a CPU region and if it’s set to that stop condition, you then stop. You could still print the i,j,k and res values - you just wouldn’t stop there.
So a quick verification of that would be to just comment out the “stop” and see that the code continues execution.
However, I think it’s a compiler bug that we don’t catch this and warn you about it ahead of time - or force the loop to be a serial loop because of the existence of the stop. We shouldn’t let this happen, I think. I’m going to raise an issue with engineering about it.
Please let me know if that helps!