[Cython] prange CEP updated
Dag Sverre Seljebotn
d.s.seljebotn at astro.uio.no
Wed May 4 13:54:18 CEST 2011
On 05/04/2011 01:48 PM, mark florisson wrote:
> On 4 May 2011 13:47, mark florisson<markflorisson88 at gmail.com> wrote:
>> On 4 May 2011 13:45, Dag Sverre Seljebotn<d.s.seljebotn at astro.uio.no> wrote:
>>> Look.
>>>
>>> i = 42
>>> for i in prange(n):
>>> f(i)
>>> print i # want 42 whenever n == 0
>>>
>>> Now, translate this to:
>>>
>>> i = 42;
>>> #pragma omp parallel for firstprivate(i) lastprivate(i)
>>> for (temp = 0; ...; ...) {
>>> i = ...
>>> }
>>> #pragma omp parallel end
>>> /* At this point, i == 42 if n == 0 */
>>>
>>> Am I missing something?
>>
>> Yes, 'i' may be uninitialized with nsteps> 0 (this should be valid
>> code). So if nsteps> 0, we need to initialize 'i' to something to get
>> correct behaviour with firstprivate.
This I don't see. I think I need to be spoon-fed on this one.
> And of course, if you initialize 'i' unconditionally, you change 'i'
> whereas you might have to leave it unaffected.
This I see.
Dag Sverre
More information about the cython-devel
mailing list