[Omp] A question about threadprivate
Meadows, Lawrence F
lawrence.f.meadows at intel.com
Wed Apr 11 09:44:53 PDT 2007
In the first example?
-----Original Message-----
From: Dieter an Mey [mailto:anmey at rz.rwth-aachen.de]
Sent: Wednesday, April 11, 2007 9:43 AM
To: Meadows, Lawrence F
Cc: Marina Kraeva; omp at openmp.org
Subject: Re: [Omp] A question about threadprivate
Data race !
Dieter
Meadows, Lawrence F schrieb:
> I think that the standard specifies what you expect in the first
> example. It makes no guarantee about the second example.
>
> -----Original Message-----
> From: omp-bounces at openmp.org [mailto:omp-bounces at openmp.org] On Behalf
> Of Marina Kraeva
> Sent: Wednesday, April 11, 2007 9:16 AM
> To: omp at openmp.org
> Subject: [Omp] A question about threadprivate
>
> Hello,
>
> Could you please share your opinion on what will happen in the
following
>
> two small examples.
>
> In the OpenMP API 2.5 (and in the earlier versions) it is said:
> "The values of data in the threadprivate objects of threads other than
> the initial thread are guaranteed to persist between two consecutive
> active parallel regions only if all the following conditions hold:
> * Neither parallel region is nested inside another parallel region..."
>
>
> According to API, is it guaranteed that in the following example the
> values of 'i' will persist, so array will have values (0,1,2,3)?
>
> int i,array(0:3)
> threadprivate(i)
> !$omp parallel num_threads(4)
> i=omp_get_thread_num()
> !$omp parallel num_threads(2)
> ... ('i' is not referenced)
> !$omp end parallel
> !$omp end parallel
>
> !$omp parallel num_threads(4) shared(array)
> array(omp_get_thread_num())=i
> !$omp end parallel
>
>
>
> What if inside the nested parallel region 'i' was modified:
>
> 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
>
> Is it guaranteed, that array still will have values (0,1,2,3)?
>
> Thank you!
> Marina Kraeva.
> _______________________________________________
> Omp mailing list
> Omp at openmp.org
> http://openmp.org/mailman/listinfo/omp
> _______________________________________________
> Omp mailing list
> Omp at openmp.org
> http://openmp.org/mailman/listinfo/omp
>
--
--------------------------------------------------------------------
Dieter an Mey
High Performance Computing Hochleistungsrechnen
RWTH Aachen University Rechen- und Kommunikations-
Center for Computing and Communication zentrum der RWTH Aachen
phone: ++49-(0)241-80-24377 Seffenter Weg 23
fax: ++49-(0)241-80-22134 52074 Aachen, Germany
email: anmey at rz.rwth-aachen.de
--------------------------------------------------------------------
More information about the Omp
mailing list