[Omp] A question about threadprivate
Meadows, Lawrence F
lawrence.f.meadows at intel.com
Thu Apr 12 09:45:03 PDT 2007
Hmm. Good point. You can see how little time I spent thinking about
this.
So I still agree with Dieter, just with what he said originally, not
what
I said that he said.
-----Original Message-----
From: Marina Kraeva [mailto:kraeva at iastate.edu]
Sent: Thursday, April 12, 2007 9:35 AM
To: Meadows, Lawrence F
Cc: anmey at rz.rwth-aachen.de; omp at openmp.org
Subject: Re: [Omp] A question about threadprivate
Larry,
As I understood, Dieter suggested that the inner region modifying 'i' IS
relevant, because the master threads of the inner regions will be
modifying the parent copies of 'i', so after the nested parallel region
all four copies of 'i' will have value '-0'.
Anyway, I emailed a request to feedback at openmp.org asking to specify the
behavior in various situations, including these two examples.
Thanks again for your input!
Marina.
Meadows, Lawrence F wrote:
> Now that I re-read the second example, I agree with Dieter that
> the result is well-defined by the 2.0 standard:
>
>
>>>>int i,array(0:3)
>>>>threadprivate(i)
>>>>!$omp parallel num_threads(4)
>>>> i=omp_get_thread_num()
>>>> !$omp parallel num_threads(2)
>>>> i=-omp_get_thread_num()
>>>> !$omp end parallel
>>>>!$omp end parallel
>>>>
>>>>!$omp parallel num_threads(4) shared(array)
>>>> array(omp_get_thread_num())=i
>>>>!$omp end parallel
>>>>
>
>
> The two outer parallel regions are consecutive, have the
> same number of threads, dyn-var is false, and nthreads-var
> hasn't changed. The inner region modifying 'i' is not
> relevant here, it is a different 'i'.
>
> So I believe that the value of 'i' for the threads in the second
> out parallel region is retained in both examples, and that this
> behavior is clearly specified by the standard.
>
>
More information about the Omp
mailing list