title: How can I access my constant memory in my kernel?
body: <p>I can't manage to access the data in my constant memory and I don't know why. Here is a snippet of my code:</p>
  
  <pre><code>#define N 10
  __constant__ int constBuf_d[N];
  
  __global__ void foo( int *results, int *constBuf )
  {
      int tdx = threadIdx.x;
      int idx = blockIdx.x * blockDim.x + tdx;
  
      if( idx &lt; N )
      {
           results[idx] = constBuf[idx];
      }
  }
  
  // main routine that executes on the host
  int main(int argc, char* argv[])
  {
      int *results_h = new int[N];
      int *results_d = NULL;
  
      cudaMalloc((void **)&amp;results_d, N*sizeof(int));
  
      int arr[10] = { 16, 2, 77, 40, 12, 3, 5, 3, 6, 6 };
  
      int *cpnt;
      cudaError_t err = cudaGetSymbolAddress((void **)&amp;cpnt, "constBuf_d");
  
      if( err )
          cout &lt;&lt; "error!";
  
      cudaMemcpyToSymbol((void**)&amp;cpnt, arr, N*sizeof(int), 0, cudaMemcpyHostToDevice);
  
      foo &lt;&lt;&lt; 1, 256 &gt;&gt;&gt; ( results_d, cpnt );
  
      cudaMemcpy(results_h, results_d, N*sizeof(int), cudaMemcpyDeviceToHost);
  
      for( int i=0; i &lt; N; ++i )
          printf("%i ", results_h[i] );
  }
  </code></pre>
  
  <p>For some reason, I only get "0" in results_h. I'm running CUDA 4.0 with a card with capability 1.1.</p>
  
  <p>Any ideas? Thanks!</p>