title: Barriers in OpenCL
body: <p>In OpenCL, my understanding is that you can use the <code>barrier()</code> 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).</p>
  
  <p>So, my questions are:</p>
  
  <ol>
  <li>Any idea why this would happen?</li>
  <li>What is the difference between <code>barrier(CLK_LOCAL_MEM_FENCE)</code> and <code>barrier(CLK_GLOBAL_MEM_FENCE)</code>? I read the documentation, but it wasn't clear to me.</li>
  <li>Is there general rule about when to use <code>barrier(CLK_LOCAL_MEM_FENCE)</code> vs. <code>barrier(CLK_GLOBAL_MEM_FENCE)</code>?</li>
  <li>Is there ever a time that calling <code>barrier()</code> with the wrong parameter type could cause an error?</li>
  </ol>