title: If I create/assign shared memory in one function, I can use it inside the function I call after can't I?
body: <p>So, if I have a <strong>device</strong> (or <strong>global</strong>) function that creates/copies some data into shared memory and I later call another <strong>device</strong> function, like so:</p>
  
  <pre><code>__global__ void a(){ 
      __shared__ int blah=0;
      fun();
  }
  __device__ void fun(){
     blah = 1; //perform some operations
     //do whatever
  }
  </code></pre>
  
  <p>I'm a bit rusty with my CUDA, I think you might have had to "redefine" shared variable (I assume the operation checked if a shared variable of that name exists, if so assigns it) - this had the effect of creating context - so basically the variable didn't just come out of nowhere. Alternatively, if it's similar to having a global variable in standard C/C++ and I can just reference it, like I did above, it'd be great.</p>
  
  <p><strong>I am familiar with memory hierarchy, I'm just rusty on the semantics of creating/referencing memory.</strong></p>
  
  <p>Please advise on whether the above sketch would work. Thanks.</p>