This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix Fortran serial loop iterators sharing (PR fortran/43339)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 20 Apr 2010 00:03:28 +0200
- Subject: [PATCH] Fix Fortran serial loop iterators sharing (PR fortran/43339)
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
While OpenMP 2.5 has been pretty vague here and I don't remember
getting any OpenMP response for
http://openmp.org/pipermail/omp/2005/000353.html
(for more details see also
http://gcc.gnu.org/ml/gcc-patches/2005-10/msg01150.html )
OpenMP 3.0 seems to be pretty clear that only the innermost task region
is affected.
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
committed to trunk, will commit to 4.5/4.4 tomorrow after
bootstrapping/regtesting there.
2010-04-19 Jakub Jelinek <jakub@redhat.com>
PR fortran/43339
* openmp.c (gfc_resolve_do_iterator): Only make iteration vars for
sequential loops private in the innermost containing task region.
* gfortran.dg/gomp/sharing-2.f90: Adjust for iteration vars
of sequential loops being private only in the innermost containing
task region.
--- gcc/fortran/openmp.c.jj 2009-08-19 17:46:03.000000000 +0200
+++ gcc/fortran/openmp.c 2010-04-19 19:31:06.000000000 +0200
@@ -1,5 +1,5 @@
/* OpenMP directive matching and resolving.
- Copyright (C) 2005, 2006, 2007, 2008
+ Copyright (C) 2005, 2006, 2007, 2008, 2010
Free Software Foundation, Inc.
Contributed by Jakub Jelinek
@@ -1367,7 +1367,6 @@ gfc_resolve_omp_parallel_blocks (gfc_cod
void
gfc_resolve_do_iterator (gfc_code *code, gfc_symbol *sym)
{
- struct omp_context *ctx;
int i = omp_current_do_collapse;
gfc_code *c = omp_current_do_code;
@@ -1386,21 +1385,21 @@ gfc_resolve_do_iterator (gfc_code *code,
c = c->block->next;
}
- for (ctx = omp_current_ctx; ctx; ctx = ctx->previous)
- {
- if (pointer_set_contains (ctx->sharing_clauses, sym))
- continue;
+ if (omp_current_ctx == NULL)
+ return;
- if (! pointer_set_insert (ctx->private_iterators, sym))
- {
- gfc_omp_clauses *omp_clauses = ctx->code->ext.omp_clauses;
- gfc_namelist *p;
+ if (pointer_set_contains (omp_current_ctx->sharing_clauses, sym))
+ return;
- p = gfc_get_namelist ();
- p->sym = sym;
- p->next = omp_clauses->lists[OMP_LIST_PRIVATE];
- omp_clauses->lists[OMP_LIST_PRIVATE] = p;
- }
+ if (! pointer_set_insert (omp_current_ctx->private_iterators, sym))
+ {
+ gfc_omp_clauses *omp_clauses = omp_current_ctx->code->ext.omp_clauses;
+ gfc_namelist *p;
+
+ p = gfc_get_namelist ();
+ p->sym = sym;
+ p->next = omp_clauses->lists[OMP_LIST_PRIVATE];
+ omp_clauses->lists[OMP_LIST_PRIVATE] = p;
}
}
--- gcc/testsuite/gfortran.dg/gomp/sharing-2.f90.jj 2008-09-05 12:55:10.000000000 +0200
+++ gcc/testsuite/gfortran.dg/gomp/sharing-2.f90 2010-04-19 20:51:32.000000000 +0200
@@ -28,10 +28,10 @@
end do
!$omp end single
!$omp end parallel
-!$omp parallel default (none) shared (a)
- i = 1
- j = 1
- k = 1
+!$omp parallel default (none) shared (a) ! { dg-error "enclosing parallel" }
+ i = 1 ! { dg-error "not specified in" }
+ j = 1 ! { dg-error "not specified in" }
+ k = 1 ! { dg-error "not specified in" }
!$omp parallel default (none) shared (a)
i = 1
j = 1
@@ -68,8 +68,8 @@
a(i, 1) = i + 1
end do
!$omp end parallel
-!$omp parallel default (none) shared (a)
- i = 1
+!$omp parallel default (none) shared (a) ! { dg-error "enclosing parallel" }
+ i = 1 ! { dg-error "not specified in" }
!$omp parallel default (none) shared (a, i)
i = 2
!$omp parallel default (none) shared (a)
Jakub