title: cython shared memory in cython.parallel.prange - block
body: <p>I have a function <code>foo</code> that takes a pointer to memory as argument and both writes and reads to that memory:</p>
  
  <pre><code>cdef void foo (double *data):
     data[some_index_int] = some_value_double
     do_something_dependent_on (data)
  </code></pre>
  
  <p>I'm allocating to <code>data</code> like so:</p>
  
  <pre><code>cdef int N = some_int
  cdef double *data = &lt;double*&gt; malloc (N * sizeof (double))
  
  cdef int i
  for i in cython.parallel.prange (N, nogil=True):
      foo (data)
  
  readout (data)
  </code></pre>
  
  <p>My question is now: how do the different threads treat this? My guess is that the memory pointed to by <code>data</code> will be shared by all threads and 'simultaneously' read from or written to while inside the function <code>foo</code>. This would then mess up all results as one can't rely on a previously set datavalue (within <code>foo</code>)? Is my guessing correct or is there some magic safety-belt implemented in the cython-compiler?</p>
  
  <p>Thank you very much in advance.</p>