title: How to define a CUDA shared memory with a size known at run time?
body: <p>The <code>__shared__</code> memory in CUDA seems to require a known size at compile time. However, in my problem, the <code>__shared__</code> memory size is only know at run time, i.e.</p>
  
  <pre><code>int size=get_size();
  __shared__ mem[size];
  </code></pre>
  
  <p>This will end up with <em>"error: constant value is not known"</em>, and I'm not sure how to get around this problem.</p>