aboutsummaryrefslogtreecommitdiff
path: root/libgomp
diff options
context:
space:
mode:
authorTobias Burnus <tobias@codesourcery.com>2020-05-13 10:06:45 +0200
committerTobias Burnus <tobias@codesourcery.com>2020-05-13 10:06:45 +0200
commitf884bef21cccc05d748fd7869cd641cbb4f6b6bb (patch)
treeed7ca416894ca3fa773b4bb4edebb46e593bb2fe /libgomp
parent3d96f7b92415b7a277a87e7825efc958030e20b6 (diff)
downloadgcc-f884bef21cccc05d748fd7869cd641cbb4f6b6bb.zip
gcc-f884bef21cccc05d748fd7869cd641cbb4f6b6bb.tar.gz
gcc-f884bef21cccc05d748fd7869cd641cbb4f6b6bb.tar.bz2
[Fortran] OpenMP - permit lastprivate in distribute + SIMD fixes (PR94690)
gcc/fortran/ 2020-05-13 Tobias Burnus <tobias@codesourcery.com> PR fortran/94690 * openmp.c (OMP_DISTRIBUTE_CLAUSES): Add OMP_CLAUSE_LASTPRIVATE. (gfc_resolve_do_iterator): Skip the private handling for SIMD as that is handled by ME code. * trans-openmp.c (gfc_trans_omp_do): Don't add private/lastprivate for dovar_found == 0, unless !simple. libgomp/ 2020-05-13 Tobias Burnus <tobias@codesourcery.com> PR fortran/94690 * testsuite/libgomp.fortran/pr66199-3.f90: New. * testsuite/libgomp.fortran/pr66199-4.f90: New. * testsuite/libgomp.fortran/pr66199-5.f90: New. * testsuite/libgomp.fortran/pr66199-6.f90: New. * testsuite/libgomp.fortran/pr66199-7.f90: New. * testsuite/libgomp.fortran/pr66199-8.f90: New. * testsuite/libgomp.fortran/pr66199-9.f90: New.
Diffstat (limited to 'libgomp')
-rw-r--r--libgomp/ChangeLog11
-rw-r--r--libgomp/testsuite/libgomp.fortran/pr66199-3.f9053
-rw-r--r--libgomp/testsuite/libgomp.fortran/pr66199-4.f9060
-rw-r--r--libgomp/testsuite/libgomp.fortran/pr66199-5.f9071
-rw-r--r--libgomp/testsuite/libgomp.fortran/pr66199-6.f9042
-rw-r--r--libgomp/testsuite/libgomp.fortran/pr66199-7.f9072
-rw-r--r--libgomp/testsuite/libgomp.fortran/pr66199-8.f9076
-rw-r--r--libgomp/testsuite/libgomp.fortran/pr66199-9.f9046
8 files changed, 431 insertions, 0 deletions
diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog
index 1265640..104c527 100644
--- a/libgomp/ChangeLog
+++ b/libgomp/ChangeLog
@@ -1,3 +1,14 @@
+2020-05-13 Tobias Burnus <tobias@codesourcery.com>
+
+ PR fortran/94690
+ * testsuite/libgomp.fortran/pr66199-3.f90: New.
+ * testsuite/libgomp.fortran/pr66199-4.f90: New.
+ * testsuite/libgomp.fortran/pr66199-5.f90: New.
+ * testsuite/libgomp.fortran/pr66199-6.f90: New.
+ * testsuite/libgomp.fortran/pr66199-7.f90: New.
+ * testsuite/libgomp.fortran/pr66199-8.f90: New.
+ * testsuite/libgomp.fortran/pr66199-9.f90: New.
+
2020-05-12 Jakub Jelinek <jakub@redhat.com>
* testsuite/libgomp.c/target-39.c: New test.
diff --git a/libgomp/testsuite/libgomp.fortran/pr66199-3.f90 b/libgomp/testsuite/libgomp.fortran/pr66199-3.f90
new file mode 100644
index 0000000..7c596dc
--- /dev/null
+++ b/libgomp/testsuite/libgomp.fortran/pr66199-3.f90
@@ -0,0 +1,53 @@
+! { dg-do run }
+!
+! PR fortran/94690
+! PR middle-end/66199
+
+module m
+ integer u(0:1024-1), v(0:1024-1), w(0:1024-1)
+contains
+
+integer(8) function f1 (a, b)
+ implicit none
+ integer, value :: a, b
+ integer(8) :: d
+ !$omp parallel do lastprivate (d) default(none) firstprivate (a, b) shared(u, v, w)
+ do d = a, b-1
+ u(d) = v(d) + w(d)
+ end do
+ f1 = d
+end
+
+integer(8) function f2 (a, b, c)
+ implicit none
+ integer, value :: a, b, c
+ integer(8) :: d, e
+ !$omp parallel do lastprivate (d) default(none) firstprivate (a, b) shared(u, v, w) linear(c:5) lastprivate(e)
+ do d = a, b-1
+ u(d) = v(d) + w(d)
+ c = c + 5
+ e = c
+ end do
+ f2 = d + c + e
+end
+
+integer(8) function f3 (a1, b1, a2, b2)
+ implicit none
+ integer, value :: a1, b1, a2, b2
+ integer(8) d1, d2
+ !$omp parallel do default(none) firstprivate (a1, b1, a2, b2) shared(u, v, w) lastprivate(d1, d2) collapse(2)
+ do d1 = a1, b1-1
+ do d2 = a2, b2-1
+ u(d1 * 32 + d2) = v(d1 * 32 + d2) + w(d1 * 32 + d2)
+ end do
+ end do
+ f3 = d1 + d2
+end
+end module m
+
+program main
+ use m
+ if (f1 (0, 1024) /= 1024) stop 1
+ if (f2 (0, 1024, 17) /= 1024 + 2 * (17 + 5 * 1024)) stop 2
+ if (f3 (0, 32, 0, 32) /= 64) stop 3
+end program main
diff --git a/libgomp/testsuite/libgomp.fortran/pr66199-4.f90 b/libgomp/testsuite/libgomp.fortran/pr66199-4.f90
new file mode 100644
index 0000000..17b62a6
--- /dev/null
+++ b/libgomp/testsuite/libgomp.fortran/pr66199-4.f90
@@ -0,0 +1,60 @@
+! { dg-do run }
+!
+! PR fortran/94690
+! PR middle-end/66199
+
+module m
+ implicit none
+ integer u(0:1023), v(0:1023), w(0:1023)
+ !$omp declare target (u, v, w)
+
+contains
+
+subroutine f1 (a, b)
+ integer a, b, d
+ !$omp target teams distribute parallel do default(none) firstprivate (a, b) shared(u, v, w)
+ do d = a, b-1
+ u(d) = v(d) + w(d)
+ end do
+end
+
+subroutine f2 (a, b, c)
+ integer a, b, c, d, e
+ !$omp target teams distribute parallel do default(none) firstprivate (a, b, c) shared(u, v, w) lastprivate(d, e)
+ do d = a, b-1
+ u(d) = v(d) + w(d)
+ e = c + d * 5
+ end do
+end
+
+subroutine f3 (a1, b1, a2, b2)
+ integer :: a1, b1, a2, b2, d1, d2
+ !$omp target teams distribute parallel do default(none) firstprivate (a1, b1, a2, b2) shared(u, v, w) &
+ !$omp& lastprivate(d1, d2) collapse(2)
+ do d1 = a1, b1-1
+ do d2 = a2, b2-1
+ u(d1 * 32 + d2) = v(d1 * 32 + d2) + w(d1 * 32 + d2)
+ end do
+ end do
+end
+
+subroutine f4 (a1, b1, a2, b2)
+ integer :: a1, b1, a2, b2, d1, d2
+ !$omp target teams distribute parallel do default(none) firstprivate (a1, b1, a2, b2) shared(u, v, w) &
+ !$omp& collapse(2)
+ do d1 = a1, b1-1
+ do d2 = a2, b2-1
+ u(d1 * 32 + d2) = v(d1 * 32 + d2) + w(d1 * 32 + d2)
+ end do
+ end do
+end
+end module m
+
+program main
+ use m
+ implicit none
+ call f1 (0, 1024)
+ call f2 (0, 1024, 17)
+ call f3 (0, 32, 0, 32)
+ call f4 (0, 32, 0, 32)
+end
diff --git a/libgomp/testsuite/libgomp.fortran/pr66199-5.f90 b/libgomp/testsuite/libgomp.fortran/pr66199-5.f90
new file mode 100644
index 0000000..9482f08
--- /dev/null
+++ b/libgomp/testsuite/libgomp.fortran/pr66199-5.f90
@@ -0,0 +1,71 @@
+! { dg-do run }
+!
+! PR fortran/94690
+! PR middle-end/66199
+
+module m
+ implicit none
+ integer u(0:1023), v(0:1023), w(0:1023)
+ !$omp declare target (u, v, w)
+
+contains
+
+integer function f1 (a, b)
+ integer :: a, b, d
+ !$omp target map(from: d)
+ !$omp teams distribute parallel do simd default(none) firstprivate (a, b) shared(u, v, w)
+ do d = a, b-1
+ u(d) = v(d) + w(d)
+ end do
+ !$omp end target
+ f1 = d
+end
+
+integer function f2 (a, b, c)
+ integer :: a, b, c, d, e
+ !$omp target map(from: d, e)
+ !$omp teams distribute parallel do simd default(none) firstprivate (a, b, c) shared(u, v, w) linear(d) lastprivate(e)
+ do d = a, b-1
+ u(d) = v(d) + w(d)
+ e = c + d * 5
+ end do
+ !$omp end target
+ f2 = d + e
+end
+
+integer function f3 (a1, b1, a2, b2)
+ integer :: a1, b1, a2, b2, d1, d2
+ !$omp target map(from: d1, d2)
+ !$omp teams distribute parallel do simd default(none) firstprivate (a1, b1, a2, b2) shared(u, v, w) lastprivate(d1, d2) &
+ !$omp& collapse(2)
+ do d1 = a1, b1-1
+ do d2 = a2, b2-1
+ u(d1 * 32 + d2) = v(d1 * 32 + d2) + w(d1 * 32 + d2)
+ end do
+ end do
+ !$omp end target
+ f3 = d1 + d2
+end
+
+integer function f4 (a1, b1, a2, b2)
+ integer :: a1, b1, a2, b2, d1, d2
+ !$omp target map(from: d1, d2)
+ !$omp teams distribute parallel do simd default(none) firstprivate (a1, b1, a2, b2) shared(u, v, w) collapse(2)
+ do d1 = a1, b1-1
+ do d2 = a2, b2-1
+ u(d1 * 32 + d2) = v(d1 * 32 + d2) + w(d1 * 32 + d2)
+ end do
+ end do
+ !$omp end target
+ f4 = d1 + d2
+end
+end module
+
+program main
+ use m
+ implicit none
+ if (f1 (0, 1024) /= 1024) stop 1
+ if (f2 (0, 1024, 17) /= 1024 + (17 + 5 * 1023)) stop 2
+ if (f3 (0, 32, 0, 32) /= 64) stop 3
+ if (f4 (0, 32, 0, 32) /= 64) stop 3
+end
diff --git a/libgomp/testsuite/libgomp.fortran/pr66199-6.f90 b/libgomp/testsuite/libgomp.fortran/pr66199-6.f90
new file mode 100644
index 0000000..f73f683
--- /dev/null
+++ b/libgomp/testsuite/libgomp.fortran/pr66199-6.f90
@@ -0,0 +1,42 @@
+! { dg-do run }
+!
+! PR fortran/94690
+! PR middle-end/66199
+
+module m
+ implicit none
+ integer :: u(0:1023), v(0:1023), w(0:1023)
+ !$omp declare target (u, v, w)
+
+contains
+
+integer function f2 (a, b, c)
+ integer :: a, b, c, d, e
+ !$omp target map(from: d, e)
+ !$omp teams distribute parallel do default(none) firstprivate (a, b, c) shared(u, v, w) lastprivate(d, e)
+ do d = a, b-1
+ u(d) = v(d) + w(d)
+ e = c + d * 5
+ end do
+ !$omp end target
+ f2 = d + e
+end
+
+integer function f3 (a1, b1, a2, b2)
+ integer :: a1, b1, a2, b2, d1, d2
+ !$omp target map(from: d1, d2)
+ !$omp teams distribute parallel do default(none) firstprivate (a1, b1, a2, b2) shared(u, v, w) lastprivate(d1, d2) collapse(2)
+ do d1 = a1, b1-1
+ do d2 = a2, b2-1
+ u(d1 * 32 + d2) = v(d1 * 32 + d2) + w(d1 * 32 + d2)
+ end do
+ end do
+ !$omp end target
+ f3 = d1 + d2
+end
+end module m
+
+use m
+ if (f2 (0, 1024, 17) /= 1024 + (17 + 5 * 1023)) stop 1
+ if (f3 (0, 32, 0, 32) /= 64) stop 2
+end
diff --git a/libgomp/testsuite/libgomp.fortran/pr66199-7.f90 b/libgomp/testsuite/libgomp.fortran/pr66199-7.f90
new file mode 100644
index 0000000..2bd9468
--- /dev/null
+++ b/libgomp/testsuite/libgomp.fortran/pr66199-7.f90
@@ -0,0 +1,72 @@
+! { dg-do run }
+!
+! PR fortran/94690
+! PR middle-end/66199
+
+module m
+ implicit none
+ integer u(1024), v(1024), w(1024)
+ !$omp declare target (v, u, w)
+
+contains
+
+integer function f1 (a, b)
+ integer :: a, b, d
+ !$omp target map(from: d)
+ !$omp teams distribute simd default(none) firstprivate (a, b) shared(u, v, w)
+ do d = a, b-1
+ u(d) = v(d) + w(d)
+ end do
+ !$omp end teams distribute simd
+ !$omp end target
+ f1 = d
+end
+
+integer function f2 (a, b, c)
+ integer a, b, c, d, e
+ !$omp target map(from: d, e)
+ !$omp teams distribute simd default(none) firstprivate (a, b, c) shared(u, v, w) linear(d) lastprivate(e)
+ do d = a, b-1
+ u(d) = v(d) + w(d)
+ e = c + d * 5
+ end do
+ !$omp end teams distribute simd
+ !$omp end target
+ f2 = d + e
+end
+
+integer function f3 (a1, b1, a2, b2)
+ integer :: a1, b1, a2, b2, d1, d2
+ !$omp target map(from: d1, d2)
+ !$omp teams distribute simd default(none) firstprivate (a1, b1, a2, b2) shared(u, v, w) lastprivate(d1, d2) collapse(2)
+ do d1 = a1, b1-1
+ do d2 = a2, b2-1
+ u(d1 * 32 + d2) = v(d1 * 32 + d2) + w(d1 * 32 + d2)
+ end do
+ end do
+ !$omp end teams distribute simd
+ !$omp end target
+ f3 = d1 + d2
+end
+
+integer function f4 (a1, b1, a2, b2)
+ integer :: a1, b1, a2, b2, d1, d2
+ !$omp target map(from: d1, d2)
+ !$omp teams distribute simd default(none) firstprivate (a1, b1, a2, b2) shared(u, v, w) collapse(2)
+ do d1 = a1, b1-1
+ do d2 = a2, b2-1
+ u(d1 * 32 + d2) = v(d1 * 32 + d2) + w(d1 * 32 + d2)
+ end do
+ end do
+ !$omp end teams distribute simd
+ !$omp end target
+ f4 = d1 + d2
+end
+end module
+
+use m
+ if (f1 (0, 1024) /= 1024) stop 1
+ if (f2 (0, 1024, 17) /= 1024 + (17 + 5 * 1023)) stop 2
+ if (f3 (0, 32, 0, 32) /= 64) stop 3
+ if (f4 (0, 32, 0, 32) /= 64) stop 4
+end
diff --git a/libgomp/testsuite/libgomp.fortran/pr66199-8.f90 b/libgomp/testsuite/libgomp.fortran/pr66199-8.f90
new file mode 100644
index 0000000..8a21c6f
--- /dev/null
+++ b/libgomp/testsuite/libgomp.fortran/pr66199-8.f90
@@ -0,0 +1,76 @@
+! { dg-do run }
+!
+! PR fortran/94690
+! PR middle-end/66199
+
+module m
+ implicit none
+ integer u(0:1023), v(0:1023), w(0:1023)
+ !$omp declare target (u, v, w)
+
+contains
+
+integer function f1 (a, b)
+ integer :: a, b, d
+ !$omp target map(from: d)
+ !$omp teams default(none) shared(a, b, d, u, v, w)
+ !$omp distribute simd firstprivate (a, b)
+ do d = a, b-1
+ u(d) = v(d) + w(d)
+ end do
+ !$omp end teams
+ !$omp end target
+ f1 = d
+end
+
+integer function f2 (a, b, c)
+ integer a, b, c, d, e
+ !$omp target map(from: d, e)
+ !$omp teams default(none) firstprivate (a, b, c) shared(d, e, u, v, w)
+ !$omp distribute simd linear(d) lastprivate(e)
+ do d = a, b-1
+ u(d) = v(d) + w(d)
+ e = c + d * 5
+ end do
+ !$omp end teams
+ !$omp end target
+ f2 = d + e
+end
+
+integer function f3 (a1, b1, a2, b2)
+ integer a1, b1, a2, b2, d1, d2
+ !$omp target map(from: d1, d2)
+ !$omp teams default(none) shared(a1, b1, a2, b2, d1, d2, u, v, w)
+ !$omp distribute simd firstprivate (a1, b1, a2, b2) lastprivate(d1, d2) collapse(2)
+ do d1 = a1, b1-1
+ do d2 = a2, b2-1
+ u(d1 * 32 + d2) = v(d1 * 32 + d2) + w(d1 * 32 + d2)
+ end do
+ end do
+ !$omp end teams
+ !$omp end target
+ f3 = d1 + d2
+end
+
+integer function f4 (a1, b1, a2, b2)
+ integer a1, b1, a2, b2, d1, d2
+ !$omp target map(from: d1, d2)
+ !$omp teams default(none) firstprivate (a1, b1, a2, b2) shared(d1, d2, u, v, w)
+ !$omp distribute simd collapse(2)
+ do d1 = a1, b1-1
+ do d2 = a2, b2-1
+ u(d1 * 32 + d2) = v(d1 * 32 + d2) + w(d1 * 32 + d2)
+ end do
+ end do
+ !$omp end teams
+ !$omp end target
+ f4 = d1 + d2
+end
+end module m
+
+use m
+ if (f1 (0, 1024) /= 1024) stop 1
+ if (f2 (0, 1024, 17) /= 1024 + (17 + 5 * 1023)) stop 2
+ if (f3 (0, 32, 0, 32) /= 64) stop 3
+ if (f4 (0, 32, 0, 32) /= 64) stop 4
+end
diff --git a/libgomp/testsuite/libgomp.fortran/pr66199-9.f90 b/libgomp/testsuite/libgomp.fortran/pr66199-9.f90
new file mode 100644
index 0000000..5dde7f8
--- /dev/null
+++ b/libgomp/testsuite/libgomp.fortran/pr66199-9.f90
@@ -0,0 +1,46 @@
+! { dg-do run }
+!
+! PR fortran/94690
+! PR middle-end/66199
+
+module m
+ implicit none
+ integer u(1024), v(1024), w(1024)
+ !$omp declare target (u, v, w)
+
+contains
+
+integer function f2 (a, b, c)
+ integer :: a, b, c, d, e
+ !$omp target map(from: d, e)
+ !$omp teams default(none) firstprivate (a, b, c) shared(d, e, u, v, w)
+ !$omp distribute lastprivate(d, e)
+ do d = a, b-1
+ u(d) = v(d) + w(d)
+ e = c + d * 5
+ end do
+ !$omp end teams
+ !$omp end target
+ f2 = d + e
+end
+
+integer function f3 (a1, b1, a2, b2)
+ integer :: a1, b1, a2, b2, d1, d2
+ !$omp target map(from: d1, d2)
+ !$omp teams default(none) shared(a1, b1, a2, b2, d1, d2, u, v, w)
+ !$omp distribute firstprivate (a1, b1, a2, b2) lastprivate(d1, d2) collapse(2)
+ do d1 = a1, b1-1
+ do d2 = a2, b2-1
+ u(d1 * 32 + d2) = v(d1 * 32 + d2) + w(d1 * 32 + d2)
+ end do
+ end do
+ !$omp end teams
+ !$omp end target
+ f3 = d1 + d2
+end
+end module
+
+use m
+ if (f2 (0, 1024, 17) /= 1024 + (17 + 5 * 1023)) stop 1
+ if (f3 (0, 32, 0, 32) /= 64) stop 2
+end