[Omp] A question about threadprivate
Marina Kraeva
kraeva at iastate.edu
Thu Apr 12 09:35:27 PDT 2007
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