From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa2.mentor.iphmx.com (esa2.mentor.iphmx.com [68.232.141.98]) by sourceware.org (Postfix) with ESMTPS id 4FB4A3850415; Tue, 16 Feb 2021 10:09:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4FB4A3850415 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Tobias_Burnus@mentor.com IronPort-SDR: FogbtFAx1G6V+OQdJhuzPKwcg5+k0uoyslIEwiVH/UVFRkH0MJXfENXak2x/POknnn5+P0mV+C DlUxrna4MboQJwbprZJx1lQZaWSbIBf1kfryUIRqS35jmDxzHDN6ylV6DbN9UzDSCV5Kxjyo8n cEbz9GHygrSCEM64vvMbuzTCA28YjQ/9esO37T/H5RlEZci3J6+xx952rFtInBBPGAjaJ0fazZ nLKggoTP7V1u1KokrOoDjmUgNTqVBFl4yx8W+mYx13rt+oXBOmq7CaqKMQ5IEw891lWQjcVKth 4+A= X-IronPort-AV: E=Sophos;i="5.81,183,1610438400"; d="scan'208";a="58136955" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa2.mentor.iphmx.com with ESMTP; 16 Feb 2021 02:09:23 -0800 IronPort-SDR: U8lvKJannwBsrnhri0i9+XQLJiKWQjrkf3vZyIyjJEGCdNV8mtmgfdjO2gIm+EKVR8QTiRUApk gvN9cCC2s3azXSj+3fIM0Fy56jbwOAccl+nRMowzpg/vZN2rZfScQjg1xUMFJD6FYXJ/vfZVWr UMw+uTUtwRG7Syqf0My+TWpwZy6DyqbAOM4x3++HEuH635UJbqeTSeWXWMmvK9uk5nK3+WtoQS mZEYj9Pr0ZLzLY6vqhZisoxd04Yr3bhvEulbP9PdHKChL7UuWCATX2KzNj0pEsN2BioAl7UsXg TvU= Subject: Re: [PATCH 2/2] openacc: Strided array sections and components of derived-type arrays To: Julian Brown , , CC: Jakub Jelinek , Thomas Schwinge References: <20210212154649.96393-1-julian@codesourcery.com> <20210212154649.96393-3-julian@codesourcery.com> From: Tobias Burnus Message-ID: <0dd09235-2564-0545-124f-f4b31e6520f0@codesourcery.com> Date: Tue, 16 Feb 2021 11:09:17 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <20210212154649.96393-3-julian@codesourcery.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: quoted-printable Content-Language: en-US X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: SVR-IES-MBX-03.mgc.mentorg.com (139.181.222.3) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: fortran@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Fortran mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Feb 2021 10:09:26 -0000 On 12.02.21 16:46, Julian Brown wrote: > This patch disallows selecting components of array sections in update > directives for OpenACC, as specified in OpenACC 3.0, "2.14.4. Update > Directive", "Restrictions": > > "In Fortran, members of variables of derived type may appear, includin= g > a subarray of a member. Members of subarrays of derived type may > not appear." > > The diagnostic for attempting to use the same construct on other > directives has also been improved. > > OK for mainline? LGTM. Tobias > gcc/fortran/ > * openmp.c (resolve_omp_clauses): Disallow selecting components of > arrays of derived type. > > gcc/testsuite/ > * gfortran.dg/goacc/array-with-dt-2.f90: Remove expected errors. > * gfortran.dg/goacc/array-with-dt-6.f90: New test. > * gfortran.dg/goacc/mapping-tests-2.f90: Update expected error. > > libgomp/ > * testsuite/libgomp.oacc-fortran/array-stride-dt-1.f90: Remove expe= cted > errors. > --- > gcc/fortran/openmp.c | 55 +++++++++++-------- > .../gfortran.dg/goacc/array-with-dt-2.f90 | 5 +- > .../gfortran.dg/goacc/array-with-dt-6.f90 | 10 ++++ > .../gfortran.dg/goacc/mapping-tests-2.f90 | 4 +- > .../array-stride-dt-1.f90 | 5 +- > 5 files changed, 48 insertions(+), 31 deletions(-) > create mode 100644 gcc/testsuite/gfortran.dg/goacc/array-with-dt-6.f90 > > diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c > index aab17f0589f..9bcb1bf62ca 100644 > --- a/gcc/fortran/openmp.c > +++ b/gcc/fortran/openmp.c > @@ -5174,17 +5174,29 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clau= ses *omp_clauses, > "are allowed on ORDERED directive at %L", > &n->where); > } > - gfc_ref *array_ref =3D NULL; > + gfc_ref *lastref =3D NULL, *lastslice =3D NULL; > bool resolved =3D false; > if (n->expr) > { > - array_ref =3D n->expr->ref; > + lastref =3D n->expr->ref; > resolved =3D gfc_resolve_expr (n->expr); > > /* Look through component refs to find last array > reference. */ > if (resolved) > { > + for (gfc_ref *ref =3D n->expr->ref; ref; ref =3D re= f->next) > + if (ref->type =3D=3D REF_COMPONENT) > + lastref =3D ref; > + else if (ref->type =3D=3D REF_ARRAY) > + { > + for (int i =3D 0; i < ref->u.ar.dimen; i++) > + if (ref->u.ar.dimen_type[i] =3D=3D DIMEN_RA= NGE) > + lastslice =3D ref; > + > + lastref =3D ref; > + } > + > /* The "!$acc cache" directive allows rectangular > subarrays to be specified, with some restriction= s > on the form of bounds (not implemented). > @@ -5192,45 +5204,42 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clau= ses *omp_clauses, > array isn't contiguous. An expression such as > arr(-n:n,-n:n) could be contiguous even if it lo= oks > like it may not be. */ > - if (list !=3D OMP_LIST_CACHE > + if (code->op !=3D EXEC_OACC_UPDATE > + && list !=3D OMP_LIST_CACHE > && list !=3D OMP_LIST_DEPEND > && !gfc_is_simply_contiguous (n->expr, false, t= rue) > - && gfc_is_not_contiguous (n->expr)) > + && gfc_is_not_contiguous (n->expr) > + && !(lastslice > + && (lastslice->next > + || lastslice->type !=3D REF_ARRAY))) > gfc_error ("Array is not contiguous at %L", > &n->where); > - > - while (array_ref > - && (array_ref->type =3D=3D REF_COMPONENT > - || (array_ref->type =3D=3D REF_ARRAY > - && array_ref->next > - && (array_ref->next->type > - =3D=3D REF_COMPONENT)))) > - array_ref =3D array_ref->next; > } > } > - if (array_ref > + if (lastref > || (n->expr > && (!resolved || n->expr->expr_type !=3D EXPR_VARIA= BLE))) > { > - if (array_ref > - && (array_ref->type =3D=3D REF_SUBSTRING > - || (array_ref->next > - && array_ref->next->type =3D=3D REF_SUBSTRI= NG))) > + if (lastref > + && (lastref->type =3D=3D REF_SUBSTRING > + || (lastref->next > + && lastref->next->type =3D=3D REF_SUBSTRING= ))) > gfc_error ("Unexpected substring reference in %s clau= se " > "at %L", name, &n->where); > else if (!resolved > - || n->expr->expr_type !=3D EXPR_VARIABLE > - || array_ref->next > - || array_ref->type !=3D REF_ARRAY) > + || n->expr->expr_type !=3D EXPR_VARIABLE > + || (lastslice > + && (lastslice->next > + || lastslice->type !=3D REF_ARRAY))) > gfc_error ("%qs in %s clause at %L is not a proper " > "array section", n->sym->name, name, > &n->where); > - else > + else if (lastslice) > { > int i; > - gfc_array_ref *ar =3D &array_ref->u.ar; > + gfc_array_ref *ar =3D &lastslice->u.ar; > for (i =3D 0; i < ar->dimen; i++) > - if (ar->stride[i]) > + if (ar->stride[i] && code->op !=3D EXEC_OACC_UPDA= TE) > { > gfc_error ("Stride should not be specified fo= r " > "array section in %s clause at %L"= , > diff --git a/gcc/testsuite/gfortran.dg/goacc/array-with-dt-2.f90 b/gcc/te= stsuite/gfortran.dg/goacc/array-with-dt-2.f90 > index e4a6f319772..807580d75a9 100644 > --- a/gcc/testsuite/gfortran.dg/goacc/array-with-dt-2.f90 > +++ b/gcc/testsuite/gfortran.dg/goacc/array-with-dt-2.f90 > @@ -4,8 +4,7 @@ end type t > > type(t), allocatable :: b(:) > > -! TODO: Remove expected errors when this is supported. > -!$acc update host(b(::2)) ! { dg-error "Stride should not be specified = for array section in MAP clause" } > -!$acc update host(b(1)%A(::3,::4)) ! { dg-error "Stride should not be s= pecified for array section in MAP clause" } > +!$acc update host(b(::2)) > +!$acc update host(b(1)%A(::3,::4)) > end > > diff --git a/gcc/testsuite/gfortran.dg/goacc/array-with-dt-6.f90 b/gcc/te= stsuite/gfortran.dg/goacc/array-with-dt-6.f90 > new file mode 100644 > index 00000000000..adac8e3945e > --- /dev/null > +++ b/gcc/testsuite/gfortran.dg/goacc/array-with-dt-6.f90 > @@ -0,0 +1,10 @@ > +type t > + integer :: i, j > +end type t > +type t2 > + type(t) :: b(4) > +end type > +type(t2) :: var(10) > +!$acc update host(var(3)%b(:)%j) ! { dg-error "not a proper array secti= on" } > +!$acc update host(var(3)%b%j) ! { dg-error "not a proper array section"= } > +end > diff --git a/gcc/testsuite/gfortran.dg/goacc/mapping-tests-2.f90 b/gcc/te= stsuite/gfortran.dg/goacc/mapping-tests-2.f90 > index 1372f6af53e..6b414fb8524 100644 > --- a/gcc/testsuite/gfortran.dg/goacc/mapping-tests-2.f90 > +++ b/gcc/testsuite/gfortran.dg/goacc/mapping-tests-2.f90 > @@ -24,9 +24,9 @@ subroutine foo > ! Bad - we cannot do a strided access of 'x' > ! No C/C++ equivalent > !$acc enter data copyin(y(:)%i) > -! { dg-error "Array is not contiguous" "" { target "*-*-*" } 26 } > +! { dg-error "not a proper array section" "" { target "*-*-*" } 26 } > > ! Bad - again, a strided access > !$acc enter data copyin(z(1)%cc(:)%i) > -! { dg-error "Array is not contiguous" "" { target "*-*-*" } 30 } > +! { dg-error "not a proper array section" "" { target "*-*-*" } 30 } > end > diff --git a/libgomp/testsuite/libgomp.oacc-fortran/array-stride-dt-1.f90= b/libgomp/testsuite/libgomp.oacc-fortran/array-stride-dt-1.f90 > index 61250708197..f04d76d583a 100644 > --- a/libgomp/testsuite/libgomp.oacc-fortran/array-stride-dt-1.f90 > +++ b/libgomp/testsuite/libgomp.oacc-fortran/array-stride-dt-1.f90 > @@ -24,9 +24,8 @@ end do > > b(1)%A(:,:) =3D 5 > > -! TODO: Remove expected errors once this is supported. > -!$acc update device(b(::2)) ! { dg-error "Stride should not be specifie= d for array section in MAP clause" } > -!$acc update device(b(1)%A(::3,::4)) ! { dg-error "Stride should not be= specified for array section in MAP clause" } > +!$acc update device(b(::2)) > +!$acc update device(b(1)%A(::3,::4)) > > do i=3D1,20 > !$acc exit data copyout(b(i)%A) ----------------- Mentor Graphics (Deutschland) GmbH, Arnulfstrasse 201, 80634 M=C3=BCnchen R= egistergericht M=C3=BCnchen HRB 106955, Gesch=C3=A4ftsf=C3=BChrer: Thomas H= eurung, Frank Th=C3=BCrauf