diff options
author | Julian Brown <julian@codesourcery.com> | 2021-01-21 06:54:54 -0800 |
---|---|---|
committer | Julian Brown <julian@codesourcery.com> | 2021-02-24 06:42:26 -0800 |
commit | 86fd5ebf3a8399baaafe2c08927f7cc8859b87ce (patch) | |
tree | 306c24ac812f1d881dc64f9a700aae994e0d3ef0 /libgomp | |
parent | d8b3ac6d51c72c7720f178960cdb2e8afbeae488 (diff) | |
download | gcc-86fd5ebf3a8399baaafe2c08927f7cc8859b87ce.tar.gz |
[og10] openacc: Fix lowering for derived-type mappings through array elements
This patch fixes lowering of derived-type mappings which select elements
of arrays of derived types, and similar. These would previously lead
to ICEs.
With this change, OpenACC directives can pass through constructs that
are no longer recognized by the gimplifier, hence alterations are needed
there also.
gcc/fortran/
* trans-openmp.c (gfc_trans_omp_clauses): Handle element selection
for arrays of derived types.
gcc/
* gimplify.c (gimplify_scan_omp_clauses): Handle ATTACH_DETACH
for non-decls.
gcc/testsuite/
* gfortran.dg/goacc/array-with-dt-1.f90: New test.
* gfortran.dg/goacc/array-with-dt-3.f90: Likewise.
* gfortran.dg/goacc/array-with-dt-4.f90: Likewise.
* gfortran.dg/goacc/array-with-dt-5.f90: Likewise.
* gfortran.dg/goacc/derived-chartypes-1.f90: Re-enable test.
* gfortran.dg/goacc/derived-chartypes-2.f90: Likewise.
* gfortran.dg/goacc/derived-classtypes-1.f95: Uncomment
previously-broken directives.
libgomp/
* testsuite/libgomp.oacc-fortran/derivedtypes-arrays-1.f90: New test.
* testsuite/libgomp.oacc-fortran/update-dt-array.f90: Likewise.
(cherry picked from commit d28f3da11d8c0aed9b746689d723022a9b5ec04c)
Diffstat (limited to 'libgomp')
-rw-r--r-- | libgomp/ChangeLog.omp | 7 | ||||
-rw-r--r-- | libgomp/testsuite/libgomp.oacc-fortran/derivedtypes-arrays-1.f90 | 109 | ||||
-rw-r--r-- | libgomp/testsuite/libgomp.oacc-fortran/update-dt-array.f90 | 53 |
3 files changed, 169 insertions, 0 deletions
diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp index db6ac79fe12..0f862d1b573 100644 --- a/libgomp/ChangeLog.omp +++ b/libgomp/ChangeLog.omp @@ -2,6 +2,13 @@ Backport from mainline + * testsuite/libgomp.oacc-fortran/derivedtypes-arrays-1.f90: New test. + * testsuite/libgomp.oacc-fortran/update-dt-array.f90: Likewise. + +2021-02-24 Julian Brown <julian@codesourcery.com> + + Backport from mainline + * testsuite/libgomp.oacc-fortran/array-stride-dt-1.f90: New test. 2021-02-09 Kwok Cheung Yeung <kcy@codesourcery.com> diff --git a/libgomp/testsuite/libgomp.oacc-fortran/derivedtypes-arrays-1.f90 b/libgomp/testsuite/libgomp.oacc-fortran/derivedtypes-arrays-1.f90 new file mode 100644 index 00000000000..644ad1f6b2f --- /dev/null +++ b/libgomp/testsuite/libgomp.oacc-fortran/derivedtypes-arrays-1.f90 @@ -0,0 +1,109 @@ +! { dg-do run } + +type type1 + integer, allocatable :: arr1(:,:) +end type type1 + +type type2 + type(type1) :: t1 +end type type2 + +type type3 + type(type2) :: t2(20) +end type type3 + +type type4 + type(type3), allocatable :: t3(:) +end type type4 + +integer :: i, j, k + +type(type4), allocatable :: var1(:) +type(type4) :: var2 +type(type3) :: var3 + +allocate(var1(1:20)) +do i=1,20 + allocate(var1(i)%t3(1:20)) + do j=1,20 + do k=1,20 + allocate(var1(i)%t3(j)%t2(k)%t1%arr1(1:20,1:20)) + end do + end do +end do + +allocate(var2%t3(1:20)) +do i=1,20 + do j=1,20 + allocate(var2%t3(i)%t2(j)%t1%arr1(1:20,1:20)) + end do +end do + +do i=1,20 + do j=1,20 + do k=1,20 + var1(i)%t3(j)%t2(k)%t1%arr1(:,:) = 0 + end do + var2%t3(i)%t2(j)%t1%arr1(:,:) = 0 + end do +end do + +!$acc enter data copyin(var2%t3(4)%t2(3)%t1%arr1(:,:)) +!$acc enter data copyin(var1(5)%t3(4)%t2(3)%t1%arr1(:,:)) + +var2%t3(4)%t2(3)%t1%arr1(:,:) = 5 +var1(5)%t3(4)%t2(3)%t1%arr1(:,:) = 4 + +!$acc update device(var2%t3(4)%t2(3)%t1%arr1) +!$acc update device(var1(5)%t3(4)%t2(3)%t1%arr1) + +!$acc exit data copyout(var1(5)%t3(4)%t2(3)%t1%arr1(:,:)) +!$acc exit data copyout(var2%t3(4)%t2(3)%t1%arr1(:,:)) + +do i=1,20 + do j=1,20 + do k=1,20 + if (i.eq.5 .and. j.eq.4 .and. k.eq.3) then + if (any(var1(i)%t3(j)%t2(k)%t1%arr1 .ne. 4)) stop 1 + else + if (any(var1(i)%t3(j)%t2(k)%t1%arr1 .ne. 0)) stop 2 + end if + end do + if (i.eq.4 .and. j.eq.3) then + if (any(var2%t3(i)%t2(j)%t1%arr1 .ne. 5)) stop 3 + else + if (any(var2%t3(i)%t2(j)%t1%arr1 .ne. 0)) stop 4 + end if + end do +end do + +do i=1,20 + allocate(var3%t2(i)%t1%arr1(1:20, 1:20)) + var3%t2(i)%t1%arr1(:,:) = 0 +end do + +!$acc enter data copyin(var3) +!$acc enter data copyin(var3%t2(:)) +!$acc enter data copyin(var3%t2(5)%t1) +!$acc data copyin(var3%t2(5)%t1%arr1) + +!$acc serial present(var3%t2(5)%t1%arr1) +var3%t2(5)%t1%arr1(:,:) = 6 +!$acc end serial + +!$acc update host(var3%t2(5)%t1%arr1) + +!$acc end data +!$acc exit data delete(var3%t2(5)%t1) +!$acc exit data delete(var3%t2) +!$acc exit data delete(var3) + +do i=1,20 + if (i.eq.5) then + if (any(var3%t2(i)%t1%arr1.ne.6)) stop 5 + else + if (any(var3%t2(i)%t1%arr1.ne.0)) stop 6 + end if +end do + +end diff --git a/libgomp/testsuite/libgomp.oacc-fortran/update-dt-array.f90 b/libgomp/testsuite/libgomp.oacc-fortran/update-dt-array.f90 new file mode 100644 index 00000000000..d796eddceda --- /dev/null +++ b/libgomp/testsuite/libgomp.oacc-fortran/update-dt-array.f90 @@ -0,0 +1,53 @@ +! { dg-do run } + +program myprog + + type mytype + integer, allocatable :: myarr(:,:) + end type mytype + integer :: i + + type(mytype), allocatable :: typearr(:) + + allocate(typearr(1:100)) + + do i=1,100 + allocate(typearr(i)%myarr(1:100,1:100)) + end do + + do i=1,100 + typearr(i)%myarr(:,:) = 0 + end do + + !$acc enter data copyin(typearr) + + do i=1,100 + !$acc enter data copyin(typearr(i)%myarr) + end do + + i=33 + typearr(i)%myarr(:,:) = 50 + + !$acc update device(typearr(i)%myarr(:,:)) + + do i=1,100 + !$acc exit data copyout(typearr(i)%myarr) + end do + + !$acc exit data delete(typearr) + + do i=1,100 + if (i.eq.33) then + if (any(typearr(i)%myarr.ne.50)) stop 1 + else + if (any(typearr(i)%myarr.ne.0)) stop 2 + end if + end do + + do i=1,100 + deallocate(typearr(i)%myarr) + end do + + deallocate(typearr) + +end program myprog |