diff options
author | Julian Brown <julian@codesourcery.com> | 2020-06-09 15:53:39 -0700 |
---|---|---|
committer | Julian Brown <julian@codesourcery.com> | 2020-07-16 14:12:53 -0700 |
commit | 39dda0020801045d9a604575b2a2593c05310015 (patch) | |
tree | 32b809bf7d91a985754ef7bc0e33e8c92bff749c /libgomp | |
parent | 0f66b8486cea8668020e4bd48f261b760cb579be (diff) | |
download | gcc-39dda0020801045d9a604575b2a2593c05310015.zip gcc-39dda0020801045d9a604575b2a2593c05310015.tar.gz gcc-39dda0020801045d9a604575b2a2593c05310015.tar.bz2 |
openacc: Fix standalone attach for Fortran assumed-shape array pointers
This patch makes it so that an "attach" operation for a Fortran pointer
with an array descriptor copies that array descriptor to the target,
and similarly that detach operations release the array descriptor.
2020-07-16 Julian Brown <julian@codesourcery.com>
Thomas Schwinge <thomas@codesourcery.com>
gcc/fortran/
* trans-openmp.c (gfc_trans_omp_clauses): Rework OpenACC
attach/detach handling for arrays with descriptors.
gcc/testsuite/
* gfortran.dg/goacc/attach-descriptor.f90: New test.
libgomp/
* testsuite/libgomp.oacc-fortran/attach-descriptor-1.f90: New test.
* testsuite/libgomp.oacc-fortran/attach-descriptor-2.f90: New test.
Co-Authored-By: Thomas Schwinge <thomas@codesourcery.com>
Diffstat (limited to 'libgomp')
-rw-r--r-- | libgomp/testsuite/libgomp.oacc-fortran/attach-descriptor-1.f90 | 53 | ||||
-rw-r--r-- | libgomp/testsuite/libgomp.oacc-fortran/attach-descriptor-2.f90 | 18 |
2 files changed, 71 insertions, 0 deletions
diff --git a/libgomp/testsuite/libgomp.oacc-fortran/attach-descriptor-1.f90 b/libgomp/testsuite/libgomp.oacc-fortran/attach-descriptor-1.f90 new file mode 100644 index 0000000..5d79cbc --- /dev/null +++ b/libgomp/testsuite/libgomp.oacc-fortran/attach-descriptor-1.f90 @@ -0,0 +1,53 @@ +! { dg-do run } + +program att + use openacc + implicit none + type t + integer :: arr1(10) + integer, allocatable :: arr2(:) + end type t + integer :: i + type(t) :: myvar + integer, target :: tarr(10) + integer, pointer :: myptr(:) + + allocate(myvar%arr2(10)) + + do i=1,10 + myvar%arr1(i) = 0 + myvar%arr2(i) = 0 + tarr(i) = 0 + end do + + call acc_copyin(myvar) + call acc_copyin(myvar%arr2) + call acc_copyin(tarr) + + myptr => tarr + + !$acc enter data attach(myvar%arr2, myptr) + + ! FIXME: This warning is emitted on the wrong line number. + ! { dg-warning "using vector_length \\(32\\), ignoring 1" "" { target openacc_nvidia_accel_selected } 38 } + !$acc serial present(myvar%arr2) + do i=1,10 + myvar%arr1(i) = i + myvar%arr2(i) = i + end do + myptr(3) = 99 + !$acc end serial + + !$acc exit data detach(myvar%arr2, myptr) + + call acc_copyout(myvar%arr2) + call acc_copyout(myvar) + call acc_copyout(tarr) + + do i=1,10 + if (myvar%arr1(i) .ne. i) stop 1 + if (myvar%arr2(i) .ne. i) stop 2 + end do + if (tarr(3) .ne. 99) stop 3 + +end program att diff --git a/libgomp/testsuite/libgomp.oacc-fortran/attach-descriptor-2.f90 b/libgomp/testsuite/libgomp.oacc-fortran/attach-descriptor-2.f90 new file mode 100644 index 0000000..58ef44e --- /dev/null +++ b/libgomp/testsuite/libgomp.oacc-fortran/attach-descriptor-2.f90 @@ -0,0 +1,18 @@ +! { dg-do run } + +program main + use openacc + implicit none + ! TODO Per PR96080, data types chosen so that we can create a + ! "pointer object 'data_p'" on the device. + integer, dimension(:), target :: data(1) + integer, dimension(:), pointer :: data_p + + !TODO Per PR96080, not using OpenACC/Fortran runtime library routines. + + !$acc enter data create(data) + data_p => data + !$acc enter data copyin(data_p) + + !$acc enter data attach(data_p) +end program main |