This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [gomp] Predetermined loop iterators
- From: Diego Novillo <dnovillo at redhat dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: Richard Henderson <rth at redhat dot com>, gcc-patches at gcc dot gnu dot org, fortran at gcc dot gnu dot org
- Date: Wed, 19 Oct 2005 10:36:48 -0400
- Subject: Re: [gomp] Predetermined loop iterators
- Organization: Red Hat Canada
- References: <20051019141108.GR16034@devserv.devel.redhat.com>
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.