title: CUDA synchronization and reading global memory
body: <p>I have something like this:</p>
  
  <pre><code>__global__ void globFunction(int *arr, int N) {
      int idx = blockIdx.x* blockDim.x+ threadIdx.x;
      // calculating and Writing results to arr ...
      __syncthreads();
      // reading values of another threads(ex i+1)
      int val = arr[idx+1]; // IT IS GIVING OLD VALUE
  }
  
  
  int main() {
      // declare array, alloc memory, copy memory, etc.
      globFunction&lt;&lt;&lt; 4000, 256&gt;&gt;&gt;(arr, N); 
      // do something ...
      return 0;
  }
  </code></pre>
  
  <p>Why am I getting the old value when I read <code>arr[idx+1]</code>? I called <code>__syncthreads</code>, so I expect to see the updated value.  What did I do wrong? Am I reading a cache or what?</p>