title: Is there any way to dynamically allocate constant memory? CUDA
body: <p>I'm confused about copying arrays to constant memory.</p>
  
  <p>According to <a href="http://docs.nvidia.com/cuda/cuda-c-programming-guide/#device-memory" rel="nofollow">programming guide</a> there's at least one way to allocate constant memory and use it in order to store an array of values. And this is called static memory allocation:</p>
  
  <pre><code>__constant__ float constData[256];
  float data[256];
  cudaMemcpyToSymbol(constData, data, sizeof(data));
  cudaMemcpyFromSymbol(data, constData, sizeof(data));
  </code></pre>
  
  <p>According to <a href="http://docs.nvidia.com/cuda/cuda-c-programming-guide/#device-memory" rel="nofollow">programming guide</a> again we can use:</p>
  
  <pre><code>__device__ float* devPointer;
  float* ptr;
  cudaMalloc(&amp;ptr, 256 * sizeof(float));
  cudaMemcpyToSymbol(devPointer, &amp;ptr, sizeof(ptr));
  </code></pre>
  
  <p>It looks like dynamic constant memory allocation is used, but I'm not sure about it. And also no qualifier <code>__constant__</code> is used here.</p>
  
  <p>So here are some questions:</p>
  
  <ol>
  <li>Is this pointer stored in constant memory?</li>
  <li>Is assigned (by this pointer) memory stored in constant memory too?</li>
  <li>Is this pointer constant? And it's not allowed to change that pointer using device or host function. But is changing values of array prohibited or not? If changing values of array is allowed, then does it mean that constant memory is not used to store this values?</li>
  </ol>