[Cython] CEP: prange for parallel loops

Stefan Behnel stefan_ml at behnel.de
Tue Apr 5 12:51:33 CEST 2011


mark florisson, 04.04.2011 21:26:
> For clarity, I'll add an example:
>
> def f(np.ndarray[double] x, double alpha):
>      cdef double s = 0
>      cdef double tmp = 2
>      cdef double other = 6.6
>
>      with nogil:
>          for i in prange(x.shape[0]):
>              # reading 'tmp' makes it firstprivate in addition to lastprivate
>              # 'other' is only ever read, so it's shared
>              printf("%lf %lf %lf\n", tmp, s, other)

So, adding a printf() to your code can change the semantics of your 
variables? That sounds like a really bad design to me.

Stefan


More information about the cython-devel mailing list