title: PyOpenCL: how to create a local memory buffer?
body: <p>Probably extremely simple question here, but I've been searching for it for hours with nothing to show for.  </p>
  
  <p>I have this piece of code, I'd like to have a 256-bit (8 uint32) bitstring_gpu as a localmemory pointer in the device:</p>
  
  <pre><code>def Get_Bitstring_GPU_Buffer(ctx, bitstring):
      bitstring_gpu = cl.Buffer(ctx, mem_flags.READ_ONLY | mem_flags.COPY_HOST_PTR, hostbuf=bitstring)
  return bitstring_gpu
  </code></pre>
  
  <p>This is later used on a kernel call:</p>
  
  <pre><code>prg.get_active_hard_locations_64bit(queue, (HARD_LOCATIONS,), None, memory_addresses_gpu.data, bitstring_gpu, distances_gpu.data, hash_table_gpu.data ).wait()
  </code></pre>
  
  <p>... and bitstring is just a random 256-bit bitstring (generated through sha256, then transformed into a numpy array.  </p>
  
  <pre><code>def Get_Random_Bitstring():    
      bitstring = address_space_through_sha256_SDM.get_bitstring(str(random.randrange(2**32-1)))
  return bitstring
  </code></pre>
  
  <p>How can I make bitstring_buf go to fast, local memory?  </p>
  
  <p>Related, but different question; here the buffer is being created inside the kernel...</p>
  
  <p><a href="https://stackoverflow.com/questions/5912968/how-to-create-variable-sized-local-memory-in-pyopencl">How to create variable sized __local memory in pyopencl?</a></p>