[Cython] prange CEP updated

Dag Sverre Seljebotn d.s.seljebotn at astro.uio.no
Sat Apr 16 18:42:07 CEST 2011


(Moving discussion from http://markflorisson.wordpress.com/, where Mark 
said:)

"""
Started a new branch https://github.com/markflorisson88/cython/tree/openmp .

Now the question is whether sharing attributes should be propagated 
outwards. e.g. if you do

for i in prange(m):
     for j in prange(n):
         sum += i * j

then ‘sum’ is a reduction for the inner parallel loop, but not for the 
outer one. So the user would currently have to rewrite this to

for i in prange(m):
     for j in prange(n):
         sum += i * j
     sum += 0

which seems a bit silly  . Of course, we could just disable nested 
parallelism, or tell the users to use a prange and a ‘for from’ in such 
cases.
"""

Dag: Interesting. The first one is definitely the behaviour we want, as 
long as it doesn't cause unintended consequences.

I don't really think it will -- the important thing is that that the 
order of loop iteration evaluation must be unimportant. And that is 
still true (for the outer loop, as well as for the inner) in your first 
example.

Question: When you have nested pranges, what will happen is that two 
nested OpenMP parallel blocks are used, right? And do you know if there 
is complete freedom/"reentrancy" in that variables that are 
thread-private in an outer parallel block and be shared in an inner one, 
and vice versa?

If so I'd think that this algorithm should work and feel natural:

  - In each prange, for the purposes of variable 
private/shared/reduction inference, consider all internal "prange" just 
as if they had been "range"; no special treatment.

  - Recurse to children pranges.

DS


More information about the cython-devel mailing list