title: Cuda AtomicAdd not increment
body: <p>I'm stuck on such a stupid problem I suppose. This is a test kernel just to see the atomicAdd working:</p>
  
  <pre><code>__global__
  void pixelcount_kernel(unsigned int * d_count,
                        const size_t numElems)
  { 
  int myId = threadIdx.x + blockDim.x * blockIdx.x;
  //avoid out of boundary access
  if(myId &gt; (numElems-1))
  {return;
  }
  
  unsigned int inc=1;
  atomicAdd(d_count, inc);
  //debug code
  printf("d_count: %d \n", *d_count);   
  }
  </code></pre>
  
  <p>and this is the memory allocation,initialization and kernel call:</p>
  
  <pre><code>unsigned int* d_count;
  checkCudaErrors(cudaMalloc(&amp;d_count, sizeof(unsigned int)));
  checkCudaErrors(cudaMemset(d_count, 0, sizeof(unsigned int)));
  pixelcount_kernel&lt;&lt;&lt;gridSize, blockSize&gt;&gt;&gt;( d_count, 10);
  </code></pre>
  
  <p>In the output I don't see any increment from 0 to numElems (10 in this call), but this:</p>
  
  <pre><code>d_count: 10 
  d_count: 10 
  d_count: 10 
  d_count: 10 
  d_count: 10 
  d_count: 10 
  d_count: 10 
  d_count: 10 
  d_count: 10 
  d_count: 10
  </code></pre>
  
  <p>What's wrong?
  Thanks
  Giuseppe</p>