In OpenCL, my understanding is that you can use the barrier()
function to synchronize threads in a work group. I do (generally) understand what they are for and when to use them. I'm also aware that all threads in a work group must hit the barrier, otherwise there are problems. However, every time I've tried to use barriers so far, it seems to result in either my video driver crashing, or an error message about accessing invalid memory of some sort. I've seen this on 2 different video cards so far (1 ATI, 1 NVIDIA).
So, my questions are:
- Any idea why this would happen?
- What is the difference between
barrier(CLK_LOCAL_MEM_FENCE)
andbarrier(CLK_GLOBAL_MEM_FENCE)
? I read the documentation, but it wasn't clear to me. - Is there general rule about when to use
barrier(CLK_LOCAL_MEM_FENCE)
vs.barrier(CLK_GLOBAL_MEM_FENCE)
? - Is there ever a time that calling
barrier()
with the wrong parameter type could cause an error?