This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [gomp] Predetermined loop iterators


On Wednesday 19 October 2005 10:11, Jakub Jelinek wrote:

> Note only speaking about parallel construct, not other omp constructs,
> while a few lines above it e.g. talks about parallel or parallel do
> constructs.
>
It means every sequential do-loop inside a parallel construct.  Regardless 
of other enclosing constructs.

> !$omp end parallel do
> !$omp parallel default (none) shared (a)
>   do i = 1, 10		! i is clearly predetermined here from this
>     a(i, 1) = 1		! particular rule
>   end do
> !$omp critical
>   do j = 1, 10		! But how about here?  Is this considered to
>     a(1, j) = j		! be also in the parallel construct, or just in
> 			! the critical construct
>
It's in both.  So 'j' must be private here.

>   end do
> !$omp end critical
> !$omp single
>   do k = 1, 10		! Similar, but unlike CRITICAL, SINGLE can have
>     a(k, k) = k		! its own PRIVATE clause, so why would k be
> 			! predetermined private in the outer PARALLEL
> 			! when it could be privatized in the SINGLE
>
The rule says that sequential loops inside parallel regions have implicitly 
private loop indices.  IMO, that's the only explanation that makes sense.  
Otherwise, you'd be forcing the user to explicitly privatize every index 
variable.  I actually wish C/C++ had this requirement, but alas.

FWIW, the Intel compiler implements this approach.

> The patch below implements do iterators being predetermined only
> directly in !$omp parallel construct (or if/do/... constructs within
> it), but not in nested !$omp constructs nor in !$omp parallel
> {do,sections,workshare}.
>
I don't think this is a good idea.  It would deviate us from the standard.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]