aboutsummaryrefslogtreecommitdiff
path: root/libgomp
diff options
context:
space:
mode:
authorThomas Schwinge <thomas@codesourcery.com>2019-06-19 00:14:24 +0200
committerThomas Schwinge <tschwinge@gcc.gnu.org>2019-06-19 00:14:24 +0200
commit4017da8d1ccc205b51ad4dbfcb63b799ad9c9a51 (patch)
tree135dceff521920b841c745107ae1a1c697a275b3 /libgomp
parent6f7c1f65027e3372ce540398e55781f84bf575d3 (diff)
downloadgcc-4017da8d1ccc205b51ad4dbfcb63b799ad9c9a51.zip
gcc-4017da8d1ccc205b51ad4dbfcb63b799ad9c9a51.tar.gz
gcc-4017da8d1ccc205b51ad4dbfcb63b799ad9c9a51.tar.bz2
[PR90743] Fortran 'allocatable' with OpenACC data/OpenMP 'target' 'map' clauses
Test what OpenMP 5.0 has to say on this topic. And, do the same for OpenACC. libgomp/ PR fortran/90743 * oacc-parallel.c (GOACC_parallel_keyed): Handle NULL mapping case. * testsuite/libgomp.fortran/target-allocatable-1-1.f90: New file. * testsuite/libgomp.fortran/target-allocatable-1-2.f90: Likewise. * testsuite/libgomp.oacc-fortran/allocatable-1-1.f90: Likewise. * testsuite/libgomp.oacc-fortran/allocatable-1-2.f90: Likewise. From-SVN: r272447
Diffstat (limited to 'libgomp')
-rw-r--r--libgomp/ChangeLog8
-rw-r--r--libgomp/oacc-parallel.c9
-rw-r--r--libgomp/testsuite/libgomp.fortran/target-allocatable-1-1.f9069
-rw-r--r--libgomp/testsuite/libgomp.fortran/target-allocatable-1-2.f9082
-rw-r--r--libgomp/testsuite/libgomp.oacc-fortran/allocatable-1-1.f9068
-rw-r--r--libgomp/testsuite/libgomp.oacc-fortran/allocatable-1-2.f9081
6 files changed, 314 insertions, 3 deletions
diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog
index 1a0d363..62c4582 100644
--- a/libgomp/ChangeLog
+++ b/libgomp/ChangeLog
@@ -1,5 +1,13 @@
2019-06-18 Thomas Schwinge <thomas@codesourcery.com>
+ PR fortran/90743
+ * oacc-parallel.c (GOACC_parallel_keyed): Handle NULL mapping
+ case.
+ * testsuite/libgomp.fortran/target-allocatable-1-1.f90: New file.
+ * testsuite/libgomp.fortran/target-allocatable-1-2.f90: Likewise.
+ * testsuite/libgomp.oacc-fortran/allocatable-1-1.f90: Likewise.
+ * testsuite/libgomp.oacc-fortran/allocatable-1-2.f90: Likewise.
+
PR testsuite/90861
* testsuite/libgomp.oacc-c-c++-common/declare-vla.c: Update.
diff --git a/libgomp/oacc-parallel.c b/libgomp/oacc-parallel.c
index e56330f..0c2cfa0 100644
--- a/libgomp/oacc-parallel.c
+++ b/libgomp/oacc-parallel.c
@@ -325,9 +325,12 @@ GOACC_parallel_keyed (int flags_m, void (*fn) (void *),
devaddrs = gomp_alloca (sizeof (void *) * mapnum);
for (i = 0; i < mapnum; i++)
- devaddrs[i] = (void *) (tgt->list[i].key->tgt->tgt_start
- + tgt->list[i].key->tgt_offset
- + tgt->list[i].offset);
+ if (tgt->list[i].key != NULL)
+ devaddrs[i] = (void *) (tgt->list[i].key->tgt->tgt_start
+ + tgt->list[i].key->tgt_offset
+ + tgt->list[i].offset);
+ else
+ devaddrs[i] = NULL;
if (aq == NULL)
acc_dev->openacc.exec_func (tgt_fn, mapnum, hostaddrs, devaddrs, dims,
tgt);
diff --git a/libgomp/testsuite/libgomp.fortran/target-allocatable-1-1.f90 b/libgomp/testsuite/libgomp.fortran/target-allocatable-1-1.f90
new file mode 100644
index 0000000..429a855
--- /dev/null
+++ b/libgomp/testsuite/libgomp.fortran/target-allocatable-1-1.f90
@@ -0,0 +1,69 @@
+! Test 'allocatable' with OpenMP 'target' 'map' clauses.
+
+! See also '../libgomp.oacc-fortran/allocatable-1-1.f90'.
+
+! { dg-do run }
+! { dg-additional-options "-cpp" }
+! { dg-additional-options "-DMEM_SHARED" { target offload_device_shared_as } }
+
+program main
+ implicit none
+ integer, allocatable :: a, b, c, d, e
+
+ allocate (a)
+ a = 11
+
+ b = 25 ! Implicit allocation.
+
+ c = 52 ! Implicit allocation.
+
+ !No 'allocate (d)' here.
+
+ !No 'allocate (e)' here.
+
+ !$omp target map(to: a) map(tofrom: b, c, d) map(from: e)
+
+ if (.not. allocated (a)) stop 1
+ if (a .ne. 11) stop 2
+ a = 33
+
+ if (.not. allocated (b)) stop 3
+ if (b .ne. 25) stop 4
+
+ if (.not. allocated (c)) stop 5
+ if (c .ne. 52) stop 6
+ c = 10
+
+ if (allocated (d)) stop 7
+ d = 42 ! Implicit allocation, but on device only.
+ if (.not. allocated (d)) stop 8
+ deallocate (d) ! OpenMP requires must be "unallocated upon exit from the region".
+
+ if (allocated (e)) stop 9
+ e = 24 ! Implicit allocation, but on device only.
+ if (.not. allocated (e)) stop 10
+ deallocate (e) ! OpenMP requires must be "unallocated upon exit from the region".
+
+ !$omp end target
+
+ if (.not. allocated (a)) stop 20
+#ifdef MEM_SHARED
+ if (a .ne. 33) stop 21
+#else
+ if (a .ne. 11) stop 22
+#endif
+ deallocate (a)
+
+ if (.not. allocated (b)) stop 23
+ if (b .ne. 25) stop 24
+ deallocate (b)
+
+ if (.not. allocated (c)) stop 25
+ if (c .ne. 10) stop 26
+ deallocate (c)
+
+ if (allocated (d)) stop 27
+
+ if (allocated (e)) stop 28
+
+end program main
diff --git a/libgomp/testsuite/libgomp.fortran/target-allocatable-1-2.f90 b/libgomp/testsuite/libgomp.fortran/target-allocatable-1-2.f90
new file mode 100644
index 0000000..5301c8e
--- /dev/null
+++ b/libgomp/testsuite/libgomp.fortran/target-allocatable-1-2.f90
@@ -0,0 +1,82 @@
+! Test 'allocatable' with OpenMP 'target' 'map' clauses, subroutine in module,
+! pass by reference.
+
+! See also '../libgomp.oacc-fortran/allocatable-1-2.f90'.
+
+! { dg-do run }
+! { dg-additional-options "-cpp" }
+! { dg-additional-options "-DMEM_SHARED" { target offload_device_shared_as } }
+
+module m
+contains
+ subroutine r (a, b, c, d, e)
+ implicit none
+ integer, allocatable :: a, b, c, d, e
+
+ !$omp target map(to: a) map(tofrom: b, c, d) map(from: e)
+
+ if (.not. allocated (a)) stop 1
+ if (a .ne. 11) stop 2
+ a = 33
+
+ if (.not. allocated (b)) stop 3
+ if (b .ne. 25) stop 4
+
+ if (.not. allocated (c)) stop 5
+ if (c .ne. 52) stop 6
+ c = 10
+
+ if (allocated (d)) stop 7
+ d = 42 ! Implicit allocation, but on device only.
+ if (.not. allocated (d)) stop 8
+ deallocate (d) ! OpenMP requires must be "unallocated upon exit from the region".
+
+ if (allocated (e)) stop 9
+ e = 24 ! Implicit allocation, but on device only.
+ if (.not. allocated (e)) stop 10
+ deallocate (e) ! OpenMP requires must be "unallocated upon exit from the region".
+
+ !$omp end target
+
+ end subroutine r
+end module m
+
+program main
+ use m
+ implicit none
+ integer, allocatable :: a, b, c, d, e
+
+ allocate (a)
+ a = 11
+
+ b = 25 ! Implicit allocation.
+
+ c = 52 ! Implicit allocation.
+
+ !No 'allocate (d)' here.
+
+ !No 'allocate (e)' here.
+
+ call r(a, b, c, d, e)
+
+ if (.not. allocated (a)) stop 20
+#ifdef MEM_SHARED
+ if (a .ne. 33) stop 21
+#else
+ if (a .ne. 11) stop 22
+#endif
+ deallocate (a)
+
+ if (.not. allocated (b)) stop 23
+ if (b .ne. 25) stop 24
+ deallocate (b)
+
+ if (.not. allocated (c)) stop 25
+ if (c .ne. 10) stop 26
+ deallocate (c)
+
+ if (allocated (d)) stop 27
+
+ if (allocated (e)) stop 28
+
+end program main
diff --git a/libgomp/testsuite/libgomp.oacc-fortran/allocatable-1-1.f90 b/libgomp/testsuite/libgomp.oacc-fortran/allocatable-1-1.f90
new file mode 100644
index 0000000..e598131
--- /dev/null
+++ b/libgomp/testsuite/libgomp.oacc-fortran/allocatable-1-1.f90
@@ -0,0 +1,68 @@
+! Test 'allocatable' with OpenACC data clauses.
+
+! See also '../libgomp.fortran/target-allocatable-1-1.f90'.
+
+! { dg-do run }
+! { dg-additional-options "-cpp" }
+
+program main
+ implicit none
+ integer, allocatable :: a, b, c, d, e
+
+ allocate (a)
+ a = 11
+
+ b = 25 ! Implicit allocation.
+
+ c = 52 ! Implicit allocation.
+
+ !No 'allocate (d)' here.
+
+ !No 'allocate (e)' here.
+
+ !$acc parallel copyin(a) copy(b, c, d) copyout(e)
+
+ if (.not. allocated (a)) stop 1
+ if (a .ne. 11) stop 2
+ a = 33
+
+ if (.not. allocated (b)) stop 3
+ if (b .ne. 25) stop 4
+
+ if (.not. allocated (c)) stop 5
+ if (c .ne. 52) stop 6
+ c = 10
+
+ if (allocated (d)) stop 7
+ d = 42 ! Implicit allocation, but on device only.
+ if (.not. allocated (d)) stop 8
+ deallocate (d) ! OpenMP requires must be "unallocated upon exit from the region".
+
+ if (allocated (e)) stop 9
+ e = 24 ! Implicit allocation, but on device only.
+ if (.not. allocated (e)) stop 10
+ deallocate (e) ! OpenMP requires must be "unallocated upon exit from the region".
+
+ !$acc end parallel
+
+ if (.not. allocated (a)) stop 20
+#if ACC_MEM_SHARED
+ if (a .ne. 33) stop 21
+#else
+ if (a .ne. 11) stop 22
+#endif
+ deallocate (a)
+
+ if (.not. allocated (b)) stop 23
+ if (b .ne. 25) stop 24
+ deallocate (b)
+
+ if (.not. allocated (c)) stop 25
+ if (c .ne. 10) stop 26
+ deallocate (c)
+
+ if (allocated (d)) stop 27
+
+ if (allocated (e)) stop 28
+
+end program main
diff --git a/libgomp/testsuite/libgomp.oacc-fortran/allocatable-1-2.f90 b/libgomp/testsuite/libgomp.oacc-fortran/allocatable-1-2.f90
new file mode 100644
index 0000000..2faf0f8
--- /dev/null
+++ b/libgomp/testsuite/libgomp.oacc-fortran/allocatable-1-2.f90
@@ -0,0 +1,81 @@
+! Test 'allocatable' with OpenACC data clauses, subroutine in module, pass by
+! reference.
+
+! See also '../libgomp.fortran/target-allocatable-1-2.f90'.
+
+! { dg-do run }
+! { dg-additional-options "-cpp" }
+
+module m
+contains
+ subroutine r (a, b, c, d, e)
+ implicit none
+ integer, allocatable :: a, b, c, d, e
+
+ !$acc parallel copyin(a) copy(b, c, d) copyout(e)
+
+ if (.not. allocated (a)) stop 1
+ if (a .ne. 11) stop 2
+ a = 33
+
+ if (.not. allocated (b)) stop 3
+ if (b .ne. 25) stop 4
+
+ if (.not. allocated (c)) stop 5
+ if (c .ne. 52) stop 6
+ c = 10
+
+ if (allocated (d)) stop 7
+ d = 42 ! Implicit allocation, but on device only.
+ if (.not. allocated (d)) stop 8
+ deallocate (d) ! OpenMP requires must be "unallocated upon exit from the region".
+
+ if (allocated (e)) stop 9
+ e = 24 ! Implicit allocation, but on device only.
+ if (.not. allocated (e)) stop 10
+ deallocate (e) ! OpenMP requires must be "unallocated upon exit from the region".
+
+ !$acc end parallel
+
+ end subroutine r
+end module m
+
+program main
+ use m
+ implicit none
+ integer, allocatable :: a, b, c, d, e
+
+ allocate (a)
+ a = 11
+
+ b = 25 ! Implicit allocation.
+
+ c = 52 ! Implicit allocation.
+
+ !No 'allocate (d)' here.
+
+ !No 'allocate (e)' here.
+
+ call r(a, b, c, d, e)
+
+ if (.not. allocated (a)) stop 20
+#if ACC_MEM_SHARED
+ if (a .ne. 33) stop 21
+#else
+ if (a .ne. 11) stop 22
+#endif
+ deallocate (a)
+
+ if (.not. allocated (b)) stop 23
+ if (b .ne. 25) stop 24
+ deallocate (b)
+
+ if (.not. allocated (c)) stop 25
+ if (c .ne. 10) stop 26
+ deallocate (c)
+
+ if (allocated (d)) stop 27
+
+ if (allocated (e)) stop 28
+
+end program main