From patchwork Tue Feb 2 13:28:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Brown X-Patchwork-Id: 1434667 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Received: from sourceware.org (unknown [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DVQdP6wWvz9tkb for ; Wed, 3 Feb 2021 00:29:13 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B03E73987C30; Tue, 2 Feb 2021 13:29:09 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa3.mentor.iphmx.com (esa3.mentor.iphmx.com [68.232.137.180]) by sourceware.org (Postfix) with ESMTPS id A954A3987C2F for ; Tue, 2 Feb 2021 13:29:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A954A3987C2F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Julian_Brown@mentor.com IronPort-SDR: fekgBLQ8PxNEK3IfVuafQhm0SvM+G8SbTY++iW72KEs+zVjxgWCEPBJUqVptDYsbGGJr36C+h9 GQvS6ij9ILqnHmnhXK/SLlZm0S5XU/9fyHCfS5EbzFlqH14gh0RU6xyDCOMZb1MTCrtL6Ni3Vv nr17+yjyBMxWFr0cq1jvCE1i8Yfjsvc2Sqg3QutNrv7k1bxjHVMEhHMvS3EBDKe/aPce7g4qwk xBHhcafFxT39MecSAuqPwyC1wpZlgpMYZbHmeSfed9ZyrzCi76FxywyP2338Cn/NddN7x05ixH Bgo= X-IronPort-AV: E=Sophos;i="5.79,395,1602576000"; d="scan'208";a="57673735" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa3.mentor.iphmx.com with ESMTP; 02 Feb 2021 05:29:06 -0800 IronPort-SDR: +4pxI6jRvmCpVW4FNl8j/4MRAqY0i0NLvAjdHzQpOrgK05ONkNfgSMTWOoAr+Pkmd5lnagoRhm XNdcvG/upZAPG/OQoEIaYv3F3cY7lWa+lB9qxOLoD5O54y81nUb25AuXQL9j0MuK362/UzlB/x yvZdy8goo+grmunu9T4tA1RQtBlnRNg5p8en1SZuCqB0O0ccWiyFssJLDoXYXIGdF0J1+XJh5a PG76JZUVdkBNGqLLpr7rhdBA5IzeIt9FGEsbeugH+nhwkX53zyyx01dYKYCH0vAvd+5M4yT2Bb Zps= From: Julian Brown To: Subject: [PATCH 1/4] openacc: Remove dereference for non-pointer derived-type members Date: Tue, 2 Feb 2021 05:28:43 -0800 Message-ID: <7f95349f1ef9bdd02ea7b70d15b74b1d50f00ab3.1612271845.git.julian@codesourcery.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-02.mgc.mentorg.com (139.181.222.2) To SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jakub Jelinek , Thomas Schwinge , Tobias Burnus Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Derived-type members that are themselves derived types are not always represented as pointers, so it is not always correct to dereference them. The attached test case fails during gimplification without this patch. Tested with offloading to AMD GCN. OK for mainline? Thanks, Julian 2020-02-02 Julian Brown gcc/fortran/ * trans-openmp.c (gfc_trans_omp_clauses): Handle non-pointer type. gcc/testsuite/ * gfortran.dg/goacc/derived-classtypes-1.f95: New test. --- gcc/fortran/trans-openmp.c | 7 +- .../goacc/derived-classtypes-1.f95 | 129 ++++++++++++++++++ 2 files changed, 134 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/goacc/derived-classtypes-1.f95 diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c index 00358ca4d39..8d8da4593c3 100644 --- a/gcc/fortran/trans-openmp.c +++ b/gcc/fortran/trans-openmp.c @@ -3013,7 +3013,8 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses, } OMP_CLAUSE_DECL (node) - = build_fold_indirect_ref (data); + = (POINTER_TYPE_P (TREE_TYPE (data)) + ? build_fold_indirect_ref (data) : data); OMP_CLAUSE_SIZE (node) = size; node2 = build_omp_clause (input_location, OMP_CLAUSE_MAP); @@ -3021,7 +3022,9 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses, openacc ? GOMP_MAP_ATTACH_DETACH : GOMP_MAP_ALWAYS_POINTER); - OMP_CLAUSE_DECL (node2) = data; + OMP_CLAUSE_DECL (node2) + = (POINTER_TYPE_P (TREE_TYPE (data)) + ? data : build_fold_addr_expr (data)); OMP_CLAUSE_SIZE (node2) = size_int (0); } else diff --git a/gcc/testsuite/gfortran.dg/goacc/derived-classtypes-1.f95 b/gcc/testsuite/gfortran.dg/goacc/derived-classtypes-1.f95 new file mode 100644 index 00000000000..e6cf09c6d3c --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/derived-classtypes-1.f95 @@ -0,0 +1,129 @@ +type :: type1 + integer :: a +end type type1 + +type :: type2 + integer, pointer :: b +end type type2 + +type :: aux1 + integer :: y +end type aux1 + +type, extends(aux1) :: aux + integer :: x +end type aux + +type :: type3 + class(aux), pointer :: c(:) +end type type3 + +type :: type4 + integer, pointer :: d(:) +end type type4 + +type :: type5 + type(aux) :: e +end type type5 + +type :: type6 + type(aux), pointer :: f +end type type6 + +type :: type7 + class(aux), pointer :: g +end type type7 + +type(type1) :: foo +type(type2) :: bar +type(type3) :: qux +type(type4) :: quux +type(type5) :: fred +type(type6) :: jim +type(type7) :: shiela + +type(type1), pointer :: pfoo +type(type2), pointer :: pbar +type(type3), pointer :: pqux +type(type4), pointer :: pquux +type(type5), pointer :: pfred +type(type6), pointer :: pjim +type(type7), pointer :: pshiela + +class(type1), pointer :: cfoo +class(type2), pointer :: cbar +class(type3), pointer :: cqux +class(type4), pointer :: cquux +class(type5), pointer :: cfred +class(type6), pointer :: cjim +class(type7), pointer :: cshiela + +class(type1), allocatable :: acfoo +class(type2), allocatable :: acbar +class(type3), allocatable :: acqux +class(type4), allocatable :: acquux +class(type5), allocatable :: acfred +class(type6), allocatable :: acjim +class(type7), allocatable :: acshiela + +!$acc enter data copyin(foo) +!$acc enter data copyin(foo%a) +!$acc enter data copyin(bar) +!$acc enter data copyin(bar%b) +!$acc enter data copyin(qux) +!!$acc enter data copyin(qux%c) +!$acc enter data copyin(quux) +!$acc enter data copyin(quux%d) +!$acc enter data copyin(fred) +!$acc enter data copyin(fred%e) +!$acc enter data copyin(jim) +!$acc enter data copyin(jim%f) +!$acc enter data copyin(shiela) +!$acc enter data copyin(shiela%g) + +!$acc enter data copyin(pfoo) +!$acc enter data copyin(pfoo%a) +!$acc enter data copyin(pbar) +!$acc enter data copyin(pbar%b) +!$acc enter data copyin(pqux) +!!$acc enter data copyin(pqux%c) +!$acc enter data copyin(pquux) +!$acc enter data copyin(pquux%d) +!$acc enter data copyin(pfred) +!$acc enter data copyin(pfred%e) +!$acc enter data copyin(pjim) +!$acc enter data copyin(pjim%f) +!$acc enter data copyin(pshiela) +!$acc enter data copyin(pshiela%g) + +!$acc enter data copyin(cfoo) +!$acc enter data copyin(cfoo%a) +!$acc enter data copyin(cbar) +!$acc enter data copyin(cbar%b) +!$acc enter data copyin(cqux) +!!$acc enter data copyin(cqux%c) +!$acc enter data copyin(cquux) +!$acc enter data copyin(cquux%d) +!$acc enter data copyin(cfred) +!$acc enter data copyin(cfred%e) +!$acc enter data copyin(cjim) +!$acc enter data copyin(cjim%f) +!$acc enter data copyin(cshiela) +!$acc enter data copyin(cshiela%g) + +!$acc enter data copyin(acfoo) +!$acc enter data copyin(acfoo%a) +!$acc enter data copyin(acbar) +!$acc enter data copyin(acbar%b) +!$acc enter data copyin(acqux) +!!$acc enter data copyin(acqux%c) +!$acc enter data copyin(acquux) +!$acc enter data copyin(acquux%d) +!$acc enter data copyin(acfred) +!$acc enter data copyin(acfred%e) +!$acc enter data copyin(acjim) +!$acc enter data copyin(acjim%f) +!$acc enter data copyin(acshiela) +!$acc enter data copyin(acshiela%g) + +end From patchwork Tue Feb 2 13:28:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Brown X-Patchwork-Id: 1434668 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DVQdW108fz9tkb for ; Wed, 3 Feb 2021 00:29:19 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 305C53987C36; Tue, 2 Feb 2021 13:29:11 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa3.mentor.iphmx.com (esa3.mentor.iphmx.com [68.232.137.180]) by sourceware.org (Postfix) with ESMTPS id 7263F3987C20 for ; Tue, 2 Feb 2021 13:29:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 7263F3987C20 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Julian_Brown@mentor.com IronPort-SDR: hjc13J71izaOeqZTikDEszHOrKFmr6A5eLFht+KW4FE1d1rN5Fw8cbMKfNE1aO8u/Xld0ViBcX NBdTd7qyPYzHdICzjH0jz1469Ct0kGIbwzc5x6L2RluCNGfN4scbHtmt2WFd8jFanfRwneEoRP GlUXGCsG6oiZEQMKM27JBhH/sF3NFMrZVwnG1qH0Ofc4X/aluVWtLsltOK98X2NIAYt+SqTBtN XCKMHdjSayER3+dyhr7GwwKbmzdHoHCG14CO379Dx3S8LStiu9WZ3ANqGzKEEPhO3KHtERqIKg ff8= X-IronPort-AV: E=Sophos;i="5.79,395,1602576000"; d="scan'208";a="57673737" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa3.mentor.iphmx.com with ESMTP; 02 Feb 2021 05:29:09 -0800 IronPort-SDR: oDRC60F/mLSIcCjcQdEAcJpJD+ly7HlmMBSCldhiNwfZjCNJWibGsYw0dE5nlSVuyPYXe+hHaD tzoxJGHJfKjZbym7/n5YEBl/LgGWrzYhmmGgojcKQgWzEtoyL4IeiSe0iyivhpcu+IETftbqMk 60iHU8kTmfOXAw+QHu2OSLZ43KttMkUdYOWPa/kn5bxIFWeqZIWLToR9QqvBKb1F4ZAkk1h/km GcwZeeg7/Et4sT+P6bU3TMo6VDakpKr74avTTYTZ3lKbR3XBWHDGW3gCA8hbieW+xpXiImmoEB I+E= From: Julian Brown To: Subject: [PATCH 2/4] openacc: Use class_pointer instead of pointer attribute for class types Date: Tue, 2 Feb 2021 05:28:44 -0800 Message-ID: <1ac13f53bd9bfe128fe0889760a735aa3d860c49.1612271845.git.julian@codesourcery.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-02.mgc.mentorg.com (139.181.222.2) To SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jakub Jelinek , Thomas Schwinge , Tobias Burnus Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Elsewhere in the Fortran front-end, the class_pointer attribute is used for BT_CLASS entities instead of the pointer attribute. This patch follows suit for OpenACC. I couldn't actually come up with a test case where this makes a difference (i.e., where "class_pointer" and "pointer" have different values at this point in the code), but this may nonetheless fix a latent bug. Tested with offloading to AMD GCN. OK for mainline? Thanks, Julian 2020-02-02 Julian Brown gcc/fortran/ * trans-openmp.c (gfc_trans_omp_clauses): Use class_pointer attribute for BT_CLASS. --- gcc/fortran/trans-openmp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c index 8d8da4593c3..7be34ef9a35 100644 --- a/gcc/fortran/trans-openmp.c +++ b/gcc/fortran/trans-openmp.c @@ -2997,7 +2997,10 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses, if (lastcomp->u.c.component->ts.type == BT_DERIVED || lastcomp->u.c.component->ts.type == BT_CLASS) { - if (sym_attr.pointer || (openacc && sym_attr.allocatable)) + bool pointer + = (lastcomp->u.c.component->ts.type == BT_CLASS + ? sym_attr.class_pointer : sym_attr.pointer); + if (pointer || (openacc && sym_attr.allocatable)) { tree data, size; From patchwork Tue Feb 2 13:28:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Brown X-Patchwork-Id: 1434670 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DVQdh6WC8z9tlN for ; Wed, 3 Feb 2021 00:29:28 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 23BCB386F46C; Tue, 2 Feb 2021 13:29:17 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa3.mentor.iphmx.com (esa3.mentor.iphmx.com [68.232.137.180]) by sourceware.org (Postfix) with ESMTPS id D155E3987C2F for ; Tue, 2 Feb 2021 13:29:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D155E3987C2F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Julian_Brown@mentor.com IronPort-SDR: 5PuXcqBZDxGzi5QDR30ZhKWnUBLsCJVeDfecwwQX9R5QUSDw2OVoig6jASJHgGXHNI03tgzZpU /z06SbSRLvjWvJ2OVMcpZlicrZPywK/0LMZBIdY3S7oYDZtu+glQ0h9bdI6M4DKIazg0sATXT0 eUYYWnRH19UOVNV9YT0kfoz+22egKfgRjz50AgP++vvraDIdetbjGk6RIw9FnxpvvVaAOb9rXD 8KrpdWUVE8DOnJPqUUTltr1NPe5IoTH2jtLWyAnT+TkupqjJHSV2HsTb5mivaalSBTg54vhCHK K2M= X-IronPort-AV: E=Sophos;i="5.79,395,1602576000"; d="scan'208";a="57673740" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa3.mentor.iphmx.com with ESMTP; 02 Feb 2021 05:29:12 -0800 IronPort-SDR: NC14/61lYvwgFKyRcFYFmShRdF+Ke75gh49sz3L+XuQ+O/gBDgC0xiu7Vbr+mmUnOLZeSySPCF qO9YUKtwJ5LEPMXw0rvqR+HasWF+9374WfAJhmFbSKjNP27UH8SFu12QQ1VhABfBi51TzR8cg1 2zM1A9MpTQzHZIEM57bc6SZpd5XZPWWtGS2M1Mr9f47F+RB8/CR8v4ybcH/AeY1jtuqCLYycGi Na/fDbeh+12LbfuuTBIatW7s+5cyzBx9KY3E115lc+0CGvf8fvUOPMfq+OnLnil4dhaEZsXB+K mg0= From: Julian Brown To: Subject: [PATCH 3/4] openacc: Fix lowering for derived-type mappings through array elements Date: Tue, 2 Feb 2021 05:28:45 -0800 Message-ID: X-Mailer: git-send-email 2.29.2 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-02.mgc.mentorg.com (139.181.222.2) To SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jakub Jelinek , Thomas Schwinge , Tobias Burnus Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" 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, update directives and enter/exit data directives can pass through constructs that are no longer recognized by the gimplifier, hence alterations are needed there also. Tested with offloading to AMD GCN. OK for mainline? Thanks, Julian 2020-02-02 Julian Brown 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-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. --- gcc/fortran/trans-openmp.c | 192 ++++++++++-------- gcc/gimplify.c | 12 ++ .../gfortran.dg/goacc/array-with-dt-1.f90 | 11 + .../gfortran.dg/goacc/array-with-dt-3.f90 | 14 ++ .../gfortran.dg/goacc/array-with-dt-4.f90 | 18 ++ .../gfortran.dg/goacc/array-with-dt-5.f90 | 12 ++ ...sstypes-1.f95 => derived-classtypes-1.f90} | 8 +- .../derivedtypes-arrays-1.f90 | 109 ++++++++++ .../libgomp.oacc-fortran/update-dt-array.f90 | 53 +++++ 9 files changed, 344 insertions(+), 85 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/goacc/array-with-dt-1.f90 create mode 100644 gcc/testsuite/gfortran.dg/goacc/array-with-dt-3.f90 create mode 100644 gcc/testsuite/gfortran.dg/goacc/array-with-dt-4.f90 create mode 100644 gcc/testsuite/gfortran.dg/goacc/array-with-dt-5.f90 rename gcc/testsuite/gfortran.dg/goacc/{derived-classtypes-1.f95 => derived-classtypes-1.f90} (95%) create mode 100644 libgomp/testsuite/libgomp.oacc-fortran/derivedtypes-arrays-1.f90 create mode 100644 libgomp/testsuite/libgomp.oacc-fortran/update-dt-array.f90 diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c index 7be34ef9a35..0ab08dabe9a 100644 --- a/gcc/fortran/trans-openmp.c +++ b/gcc/fortran/trans-openmp.c @@ -2675,6 +2675,32 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses, tree decl = gfc_trans_omp_variable (n->sym, false); if (DECL_P (decl)) TREE_ADDRESSABLE (decl) = 1; + + gfc_ref *lastref = NULL; + + if (n->expr) + for (gfc_ref *ref = n->expr->ref; ref; ref = ref->next) + if (ref->type == REF_COMPONENT || ref->type == REF_ARRAY) + lastref = ref; + + bool allocatable = false, pointer = false; + + if (lastref && lastref->type == REF_COMPONENT) + { + gfc_component *c = lastref->u.c.component; + + if (c->ts.type == BT_CLASS) + { + pointer = CLASS_DATA (c)->attr.class_pointer; + allocatable = CLASS_DATA (c)->attr.allocatable; + } + else + { + pointer = c->attr.pointer; + allocatable = c->attr.allocatable; + } + } + if (n->expr == NULL || (n->expr->ref->type == REF_ARRAY && n->expr->ref->u.ar.type == AR_FULL)) @@ -2911,74 +2937,79 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses, } else if (n->expr && n->expr->expr_type == EXPR_VARIABLE - && n->expr->ref->type == REF_COMPONENT) + && n->expr->ref->type == REF_ARRAY + && !n->expr->ref->next) { - gfc_ref *lastcomp; - - for (gfc_ref *ref = n->expr->ref; ref; ref = ref->next) - if (ref->type == REF_COMPONENT) - lastcomp = ref; - - symbol_attribute sym_attr; - - if (lastcomp->u.c.component->ts.type == BT_CLASS) - sym_attr = CLASS_DATA (lastcomp->u.c.component)->attr; - else - sym_attr = lastcomp->u.c.component->attr; - + /* An array element or array section which is not part of a + derived type, etc. */ + bool element = n->expr->ref->u.ar.type == AR_ELEMENT; + gfc_trans_omp_array_section (block, n, decl, element, + GOMP_MAP_POINTER, node, node2, + node3, node4); + } + else if (n->expr + && n->expr->expr_type == EXPR_VARIABLE + && (n->expr->ref->type == REF_COMPONENT + || n->expr->ref->type == REF_ARRAY) + && lastref + && lastref->type == REF_COMPONENT + && lastref->u.c.component->ts.type != BT_CLASS + && lastref->u.c.component->ts.type != BT_DERIVED + && !lastref->u.c.component->attr.dimension) + { + /* Derived type access with last component being a scalar. */ gfc_init_se (&se, NULL); - if (!sym_attr.dimension - && lastcomp->u.c.component->ts.type != BT_CLASS - && lastcomp->u.c.component->ts.type != BT_DERIVED) + gfc_conv_expr (&se, n->expr); + gfc_add_block_to_block (block, &se.pre); + /* For BT_CHARACTER a pointer is returned. */ + OMP_CLAUSE_DECL (node) + = POINTER_TYPE_P (TREE_TYPE (se.expr)) + ? build_fold_indirect_ref (se.expr) : se.expr; + gfc_add_block_to_block (block, &se.post); + if (pointer || allocatable) { - /* Last component is a scalar. */ - gfc_conv_expr (&se, n->expr); - gfc_add_block_to_block (block, &se.pre); - /* For BT_CHARACTER a pointer is returned. */ - OMP_CLAUSE_DECL (node) + node2 = build_omp_clause (input_location, + OMP_CLAUSE_MAP); + gomp_map_kind kind + = (openacc ? GOMP_MAP_ATTACH_DETACH + : GOMP_MAP_ALWAYS_POINTER); + OMP_CLAUSE_SET_MAP_KIND (node2, kind); + OMP_CLAUSE_DECL (node2) = POINTER_TYPE_P (TREE_TYPE (se.expr)) - ? build_fold_indirect_ref (se.expr) : se.expr; - gfc_add_block_to_block (block, &se.post); - if (sym_attr.pointer || sym_attr.allocatable) + ? se.expr + : gfc_build_addr_expr (NULL, se.expr); + OMP_CLAUSE_SIZE (node2) = size_int (0); + if (!openacc + && n->expr->ts.type == BT_CHARACTER + && n->expr->ts.deferred) { - node2 = build_omp_clause (input_location, + gcc_assert (se.string_length); + tree tmp + = gfc_get_char_type (n->expr->ts.kind); + OMP_CLAUSE_SIZE (node) + = fold_build2 (MULT_EXPR, size_type_node, + fold_convert (size_type_node, + se.string_length), + TYPE_SIZE_UNIT (tmp)); + node3 = build_omp_clause (input_location, OMP_CLAUSE_MAP); - OMP_CLAUSE_SET_MAP_KIND (node2, - openacc - ? GOMP_MAP_ATTACH_DETACH - : GOMP_MAP_ALWAYS_POINTER); - OMP_CLAUSE_DECL (node2) - = POINTER_TYPE_P (TREE_TYPE (se.expr)) - ? se.expr : gfc_build_addr_expr (NULL, se.expr); - OMP_CLAUSE_SIZE (node2) = size_int (0); - if (!openacc - && n->expr->ts.type == BT_CHARACTER - && n->expr->ts.deferred) - { - gcc_assert (se.string_length); - tree tmp = gfc_get_char_type (n->expr->ts.kind); - OMP_CLAUSE_SIZE (node) - = fold_build2 (MULT_EXPR, size_type_node, - fold_convert (size_type_node, - se.string_length), - TYPE_SIZE_UNIT (tmp)); - node3 = build_omp_clause (input_location, - OMP_CLAUSE_MAP); - OMP_CLAUSE_SET_MAP_KIND (node3, GOMP_MAP_TO); - OMP_CLAUSE_DECL (node3) = se.string_length; - OMP_CLAUSE_SIZE (node3) - = TYPE_SIZE_UNIT (gfc_charlen_type_node); - } + OMP_CLAUSE_SET_MAP_KIND (node3, GOMP_MAP_TO); + OMP_CLAUSE_DECL (node3) = se.string_length; + OMP_CLAUSE_SIZE (node3) + = TYPE_SIZE_UNIT (gfc_charlen_type_node); } - goto finalize_map_clause; } - + } + else if (n->expr + && n->expr->expr_type == EXPR_VARIABLE + && (n->expr->ref->type == REF_COMPONENT + || n->expr->ref->type == REF_ARRAY)) + { + gfc_init_se (&se, NULL); se.expr = gfc_maybe_dereference_var (n->sym, decl); - for (gfc_ref *ref = n->expr->ref; - ref && ref != lastcomp->next; - ref = ref->next) + for (gfc_ref *ref = n->expr->ref; ref; ref = ref->next) { if (ref->type == REF_COMPONENT) { @@ -2987,24 +3018,30 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses, gfc_conv_component_ref (&se, ref); } + else if (ref->type == REF_ARRAY) + { + if (ref->u.ar.type == AR_ELEMENT && ref->next) + gfc_conv_array_ref (&se, &ref->u.ar, n->expr, + &n->expr->where); + else + gcc_assert (!ref->next); + } else - sorry ("unhandled derived-type component"); + sorry ("unhandled expression type"); } tree inner = se.expr; /* Last component is a derived type or class pointer. */ - if (lastcomp->u.c.component->ts.type == BT_DERIVED - || lastcomp->u.c.component->ts.type == BT_CLASS) + if (lastref->type == REF_COMPONENT + && (lastref->u.c.component->ts.type == BT_DERIVED + || lastref->u.c.component->ts.type == BT_CLASS)) { - bool pointer - = (lastcomp->u.c.component->ts.type == BT_CLASS - ? sym_attr.class_pointer : sym_attr.pointer); - if (pointer || (openacc && sym_attr.allocatable)) + if (pointer || (openacc && allocatable)) { tree data, size; - if (lastcomp->u.c.component->ts.type == BT_CLASS) + if (lastref->u.c.component->ts.type == BT_CLASS) { data = gfc_class_data_get (inner); size = gfc_class_vtab_size_get (inner); @@ -3037,9 +3074,8 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses, = TYPE_SIZE_UNIT (TREE_TYPE (inner)); } } - else if (lastcomp->next - && lastcomp->next->type == REF_ARRAY - && lastcomp->next->u.ar.type == AR_FULL) + else if (lastref->type == REF_ARRAY + && lastref->u.ar.type == AR_FULL) { /* Just pass the (auto-dereferenced) decl through for bare attach and detach clauses. */ @@ -3133,27 +3169,21 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses, else OMP_CLAUSE_DECL (node) = inner; } - else /* An array element or section. */ + else if (lastref->type == REF_ARRAY) { - bool element - = (lastcomp->next - && lastcomp->next->type == REF_ARRAY - && lastcomp->next->u.ar.type == AR_ELEMENT); - + /* An array element or section. */ + bool element = lastref->u.ar.type == AR_ELEMENT; gomp_map_kind kind = (openacc ? GOMP_MAP_ATTACH_DETACH : GOMP_MAP_ALWAYS_POINTER); gfc_trans_omp_array_section (block, n, inner, element, kind, node, node2, node3, node4); } + else + gcc_unreachable (); } - else /* An array element or array section. */ - { - bool element = n->expr->ref->u.ar.type == AR_ELEMENT; - gfc_trans_omp_array_section (block, n, decl, element, - GOMP_MAP_POINTER, node, node2, - node3, node4); - } + else + sorry ("unhandled expression"); finalize_map_clause: diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 95d55bb8ba4..62fb6370819 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -9406,6 +9406,18 @@ gimplify_scan_omp_clauses (tree *list_p, gimple_seq *pre_p, } } } + else if ((code == OACC_ENTER_DATA + || code == OACC_EXIT_DATA + || code == OACC_DATA + || code == OACC_PARALLEL + || code == OACC_KERNELS + || code == OACC_SERIAL) + && OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_ATTACH_DETACH) + { + gomp_map_kind k = (code == OACC_EXIT_DATA + ? GOMP_MAP_DETACH : GOMP_MAP_ATTACH); + OMP_CLAUSE_SET_MAP_KIND (c, k); + } if (gimplify_expr (pd, pre_p, NULL, is_gimple_lvalue, fb_lvalue) == GS_ERROR) diff --git a/gcc/testsuite/gfortran.dg/goacc/array-with-dt-1.f90 b/gcc/testsuite/gfortran.dg/goacc/array-with-dt-1.f90 new file mode 100644 index 00000000000..4a3ff0ef3a7 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/array-with-dt-1.f90 @@ -0,0 +1,11 @@ +type t + integer, allocatable :: A(:,:) +end type t + +type(t), allocatable :: b(:) + +!$acc update host(b) +!$acc update host(b(:)) +!$acc update host(b(1)%A) +!$acc update host(b(1)%A(:,:)) +end diff --git a/gcc/testsuite/gfortran.dg/goacc/array-with-dt-3.f90 b/gcc/testsuite/gfortran.dg/goacc/array-with-dt-3.f90 new file mode 100644 index 00000000000..dcb63657f2b --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/array-with-dt-3.f90 @@ -0,0 +1,14 @@ +type t2 + integer :: A(200,200) +end type t2 +type t + integer, allocatable :: A(:,:) +end type t + +type(t2),allocatable :: c(:) +type(t), allocatable :: d(:) + +!$acc exit data delete(c(1)%A) +!$acc exit data delete(d(1)%A) + +end diff --git a/gcc/testsuite/gfortran.dg/goacc/array-with-dt-4.f90 b/gcc/testsuite/gfortran.dg/goacc/array-with-dt-4.f90 new file mode 100644 index 00000000000..637d5f57e1c --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/array-with-dt-4.f90 @@ -0,0 +1,18 @@ +type t4 + integer, allocatable :: quux(:) +end type t4 +type t3 + type(t4), pointer :: qux(:) +end type t3 +type t2 + type(t3), allocatable :: bar(:) +end type t2 +type t + type(t2), allocatable :: foo(:) +end type t + +type(t), allocatable :: c(:) + +!$acc enter data copyin(c(5)%foo(4)%bar(3)%qux(2)%quux(:)) +!$acc exit data delete(c(5)%foo(4)%bar(3)%qux(2)%quux(:)) +end diff --git a/gcc/testsuite/gfortran.dg/goacc/array-with-dt-5.f90 b/gcc/testsuite/gfortran.dg/goacc/array-with-dt-5.f90 new file mode 100644 index 00000000000..900587b7eaf --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/array-with-dt-5.f90 @@ -0,0 +1,12 @@ +type t2 + integer :: bar +end type t2 +type t + type(t2), pointer :: foo +end type t + +type(t) :: c + +!$acc enter data copyin(c%foo) + +end diff --git a/gcc/testsuite/gfortran.dg/goacc/derived-classtypes-1.f95 b/gcc/testsuite/gfortran.dg/goacc/derived-classtypes-1.f90 similarity index 95% rename from gcc/testsuite/gfortran.dg/goacc/derived-classtypes-1.f95 rename to gcc/testsuite/gfortran.dg/goacc/derived-classtypes-1.f90 index e6cf09c6d3c..85a2e1d373d 100644 --- a/gcc/testsuite/gfortran.dg/goacc/derived-classtypes-1.f95 +++ b/gcc/testsuite/gfortran.dg/goacc/derived-classtypes-1.f90 @@ -71,7 +71,7 @@ class(type7), allocatable :: acshiela !$acc enter data copyin(bar) !$acc enter data copyin(bar%b) !$acc enter data copyin(qux) -!!$acc enter data copyin(qux%c) +!$acc enter data copyin(qux%c) !$acc enter data copyin(quux) !$acc enter data copyin(quux%d) !$acc enter data copyin(fred) @@ -86,7 +86,7 @@ class(type7), allocatable :: acshiela !$acc enter data copyin(pbar) !$acc enter data copyin(pbar%b) !$acc enter data copyin(pqux) -!!$acc enter data copyin(pqux%c) +!$acc enter data copyin(pqux%c) !$acc enter data copyin(pquux) !$acc enter data copyin(pquux%d) !$acc enter data copyin(pfred) @@ -101,7 +101,7 @@ class(type7), allocatable :: acshiela !$acc enter data copyin(cbar) !$acc enter data copyin(cbar%b) !$acc enter data copyin(cqux) -!!$acc enter data copyin(cqux%c) +!$acc enter data copyin(cqux%c) !$acc enter data copyin(cquux) !$acc enter data copyin(cquux%d) !$acc enter data copyin(cfred) @@ -116,7 +116,7 @@ class(type7), allocatable :: acshiela !$acc enter data copyin(acbar) !$acc enter data copyin(acbar%b) !$acc enter data copyin(acqux) -!!$acc enter data copyin(acqux%c) +!$acc enter data copyin(acqux%c) !$acc enter data copyin(acquux) !$acc enter data copyin(acquux%d) !$acc enter data copyin(acfred) 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 From patchwork Tue Feb 2 13:28:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Brown X-Patchwork-Id: 1434669 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DVQdb5RNhz9tkb for ; Wed, 3 Feb 2021 00:29:23 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A2BD83987C35; Tue, 2 Feb 2021 13:29:16 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa3.mentor.iphmx.com (esa3.mentor.iphmx.com [68.232.137.180]) by sourceware.org (Postfix) with ESMTPS id E840B3987C33 for ; Tue, 2 Feb 2021 13:29:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E840B3987C33 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Julian_Brown@mentor.com IronPort-SDR: G03Ots2UEspzy6Sso/Z5YSyQQ5N/RWQRc8kezPdlx1OtgJDk0D7dlxBzhRCN01hTyuwEX4Co3L ZhY6P3TNG7EZ/qOB8dX4YHHBl6WsapTlPoGngUnpPkbL58jMdYYTwyG03O2xu3cu6blyt7w9cc A/H/52PuncgaT0C4Ca0zAhOkP9ZUamDYkGSDEsozhoys5nst5ponS5TSN1OROjWCnIk6nT9nmV SK8V3dzjWdxG87lWqLDeJrSgWliGaiKp4FO3PqynZx7tti0nRiy5/3fBM7EskgT+9EnOfNt9n0 Ch8= X-IronPort-AV: E=Sophos;i="5.79,395,1602576000"; d="scan'208";a="57673742" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa3.mentor.iphmx.com with ESMTP; 02 Feb 2021 05:29:13 -0800 IronPort-SDR: GKpRMhGzs8plXF2r8i1gSBFfLV5kE9gvA0bL0dY+1b9uMPDJfrzXpQaJWY0fbrKWqQ01Obn1bA h6N9Fwbmykmg6tfaok87veh4VUDoDpNJLxc6iNTCUbJhauliHWs5SAFdjlhu+WmJgBI11CpgIq l1YpQvRRItLW3ZjQn4DpQwb2a9wp1/BMqkX7ZB4OEymdBrO/eGkIBTM0r9Lw45WwcDSfuPll+q 6d1LwrmiGj3/uKM3tkhi44/EI5cg5e4TDYIAXAYspe7W7uPXsTw6UXOf7UeXlmsGiiV72X/xkr iWM= From: Julian Brown To: Subject: [PATCH 4/4] openacc: Allow strided arrays in update directives Date: Tue, 2 Feb 2021 05:28:46 -0800 Message-ID: X-Mailer: git-send-email 2.29.2 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-02.mgc.mentorg.com (139.181.222.2) To SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jakub Jelinek , Thomas Schwinge , Tobias Burnus Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" OpenACC 3.0 ("2.14.4. Update Directive") states: Noncontiguous subarrays may appear. It is implementation-specific whether noncontiguous regions are updated by using one transfer for each contiguous subregion, or whether the non-contiguous data is packed, transferred once, and unpacked, or whether one or more larger subarrays (no larger than the smallest contiguous region that contains the specified subarray) are updated. This patch relaxes some conditions in the Fortran front-end so that strided accesses are permitted for update directives. Tested with offloading to AMD GCN. OK for mainline? Thanks, Julian 2020-02-02 Julian Brown gcc/fortran/ * openmp.c (resolve_omp_clauses): Omit OpenACC update in contiguity check and stride-specified error. gcc/testsuite/ * gfortran.dg/goacc/array-with-dt-2.f90: New test. --- gcc/fortran/openmp.c | 5 +++-- gcc/testsuite/gfortran.dg/goacc/array-with-dt-2.f90 | 10 ++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/goacc/array-with-dt-2.f90 diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c index 9a3a8f63b5e..1c8c5315329 100644 --- a/gcc/fortran/openmp.c +++ b/gcc/fortran/openmp.c @@ -5192,7 +5192,8 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses, array isn't contiguous. An expression such as arr(-n:n,-n:n) could be contiguous even if it looks like it may not be. */ - if (list != OMP_LIST_CACHE + if (code->op != EXEC_OACC_UPDATE + && list != OMP_LIST_CACHE && list != OMP_LIST_DEPEND && !gfc_is_simply_contiguous (n->expr, false, true) && gfc_is_not_contiguous (n->expr)) @@ -5224,7 +5225,7 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses, int i; gfc_array_ref *ar = &array_ref->u.ar; for (i = 0; i < ar->dimen; i++) - if (ar->stride[i]) + if (ar->stride[i] && code->op != EXEC_OACC_UPDATE) { gfc_error ("Stride should not be specified for " "array section in %s clause at %L", diff --git a/gcc/testsuite/gfortran.dg/goacc/array-with-dt-2.f90 b/gcc/testsuite/gfortran.dg/goacc/array-with-dt-2.f90 new file mode 100644 index 00000000000..807580d75a9 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/array-with-dt-2.f90 @@ -0,0 +1,10 @@ +type t + integer, allocatable :: A(:,:) +end type t + +type(t), allocatable :: b(:) + +!$acc update host(b(::2)) +!$acc update host(b(1)%A(::3,::4)) +end +