title: Using constants with CUDA
body: <p>Which is the best way of using constants in CUDA?</p>
  
  <p>One way is to define constants in constant memory, like:</p>
  
  <pre><code>// CUDA global constants
  __constant__ int M;
  
  int main(void)
  {
      ...
      cudaMemcpyToSymbol("M", &amp;M, sizeof(M));
      ...
  }
  </code></pre>
  
  <p>An alterative way would be to use the C preprocessor:</p>
  
  <pre><code>#define M = ... 
  </code></pre>
  
  <p>I would think defining constants with the C preprocessor is much faster. Which are then the benefits of using the constant memory on a CUDA device?</p>