aboutsummaryrefslogtreecommitdiff
path: root/libgomp
diff options
context:
space:
mode:
authorJulian Brown <julian@codesourcery.com>2022-12-06 12:18:33 +0000
committerJulian Brown <julian@codesourcery.com>2022-12-14 14:11:45 +0000
commit9316ad3b4354cbf2980f86902e54884e918c472a (patch)
treecb5a59f6ed70616e18e38d1036166ffa79b5283e /libgomp
parent881c6cabce5d0b27285ed41bd6dabdf48848cce7 (diff)
downloadgcc-9316ad3b4354cbf2980f86902e54884e918c472a.zip
gcc-9316ad3b4354cbf2980f86902e54884e918c472a.tar.gz
gcc-9316ad3b4354cbf2980f86902e54884e918c472a.tar.bz2
OpenMP/Fortran: Combined directives with map/firstprivate of same symbol
This patch fixes a case where a combined directive (e.g. "!$omp target parallel ...") contains both a map and a firstprivate clause for the same variable. When the combined directive is split into two nested directives, the outer "target" gets the "map" clause, and the inner "parallel" gets the "firstprivate" clause, like so: !$omp target parallel map(x) firstprivate(x) --> !$omp target map(x) !$omp parallel firstprivate(x) ... When there is no map of the same variable, the firstprivate is distributed to both directives, e.g. for 'y' in: !$omp target parallel map(x) firstprivate(y) --> !$omp target map(x) firstprivate(y) !$omp parallel firstprivate(y) ... This is not a recent regression, but appear to fix a long-standing ICE. (The included testcase is based on one by Tobias.) 2022-12-06 Julian Brown <julian@codesourcery.com> gcc/fortran/ * trans-openmp.cc (gfc_add_firstprivate_if_unmapped): New function. (gfc_split_omp_clauses): Call above. libgomp/ * testsuite/libgomp.fortran/combined-directive-splitting-1.f90: New test.
Diffstat (limited to 'libgomp')
-rw-r--r--libgomp/testsuite/libgomp.fortran/combined-directive-splitting-1.f9041
1 files changed, 41 insertions, 0 deletions
diff --git a/libgomp/testsuite/libgomp.fortran/combined-directive-splitting-1.f90 b/libgomp/testsuite/libgomp.fortran/combined-directive-splitting-1.f90
new file mode 100644
index 0000000..e662a2b
--- /dev/null
+++ b/libgomp/testsuite/libgomp.fortran/combined-directive-splitting-1.f90
@@ -0,0 +1,41 @@
+module m
+ integer :: a = 1
+ !$omp declare target enter(a)
+end module m
+
+module m2
+contains
+subroutine bar()
+ use m
+ implicit none
+ !$omp declare target
+ a = a + 5
+end subroutine bar
+end module m2
+
+program p
+ use m
+ use m2
+ implicit none
+ integer :: b, i
+
+ !$omp target parallel do map(always, tofrom: a) firstprivate(a)
+ do i = 1, 1
+ a = 7
+ call bar()
+ if (a /= 7) error stop 1
+ a = a + 8
+ end do
+ if (a /= 6) error stop 2
+
+ b = 3
+ !$omp target parallel do map(always, tofrom: a) firstprivate(b)
+ do i = 1, 1
+ a = 3
+ call bar ()
+ if (a /= 8) error stop 3
+ a = a + b
+ end do
+ if (a /= 11) error stop 4
+end program p
+