From patchwork Wed Feb 24 21:57:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Brown X-Patchwork-Id: 1444067 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 4Dm8tG3Z53z9sBy for ; Thu, 25 Feb 2021 08:57:58 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C60913959E6B; Wed, 24 Feb 2021 21:57:46 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa4.mentor.iphmx.com (esa4.mentor.iphmx.com [68.232.137.252]) by sourceware.org (Postfix) with ESMTPS id 05BAA393BC05; Wed, 24 Feb 2021 21:57:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 05BAA393BC05 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: wZR2p1Iu/tXTiVPMUwp5AELOivMrP5A3qGnWkW3thZTC3dq332GQDTxguFevW3+8LVaFc6ivzs Drr2D7AbsvQYIzh+azFHzpBUFxDu2kXD2vUaCMfFa4NWymTZZuAo0qOpGUNFiFr4+MqfKV7JfJ tBe/MsRU8EQyZmeysYnZTdMp4OaJJt8BJiZHUPcI8WwFAOcghUOt1VCxgKCCWuqkVvQdwPhLHn KE8NGCdkPonnMLfroa6doGMP/9BTU2yxq9O+XOKWf9I9/t8m1d77kasdGnzblFKyxkpgpxaa+L owc= X-IronPort-AV: E=Sophos;i="5.81,203,1610438400"; d="scan'208";a="58597695" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa4.mentor.iphmx.com with ESMTP; 24 Feb 2021 13:57:41 -0800 IronPort-SDR: 8kdO04ziMcqSqCwhjwfHePZZbFAGelyUrU3ST+UaYrVebXHvbCUSV/50bw/kJjIRoomRIsPxTB 98FoJDQbROlLERU+WaBD/SwJdBxw3bkNkqx4GfyjzS4lYjdSxTNAguPBZ+7E+QMrnPxudBhiJH OMAuv5XUjWW9J5VQIEYAGAmi199zhw7nuw98djKG7rHgJXh2IUhNyX8dWUKPZ2TOg3U6djtNxf SKl+0AG4tkIGYdzapu8zri69ctqKgYWkkCZEF66azrx/cWSOm8wI18TOHq9rSQqRtVhUkxiqcD B/k= From: Julian Brown To: Subject: [PATCH 1/7] [og10] openacc: Dereference BT_CLASS data pointers but not BT_DERIVED pointers Date: Wed, 24 Feb 2021 13:57:22 -0800 Message-ID: <20210224215726.129681-2-julian@codesourcery.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210224215726.129681-1-julian@codesourcery.com> References: <20210224215726.129681-1-julian@codesourcery.com> MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: SVR-IES-MBX-07.mgc.mentorg.com (139.181.222.7) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) 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: Tobias Burnus , fortran@gcc.gnu.org Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" The stanza in gfc_trans_omp_clauses that handles derived type members that are themselves derived type pointers or class pointers now adds an explicit dereference only for the latter. The former is already dereferenced transparently in gfc_conv_component_ref. gcc/fortran/ * trans-openmp.c (gfc_trans_omp_clauses): Fix dereferencing for BT_DERIVED members. gcc/testsuite/ * gfortran.dg/goacc/derived-classtypes-1.f95: New test. (cherry picked from commit cff6e8db880b6e262730b1ce9a9cb00c1f5571e2) --- gcc/fortran/ChangeLog.omp | 7 + gcc/fortran/trans-openmp.c | 7 +- gcc/testsuite/ChangeLog.omp | 6 + .../goacc/derived-classtypes-1.f95 | 129 ++++++++++++++++++ 4 files changed, 146 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/goacc/derived-classtypes-1.f95 diff --git a/gcc/fortran/ChangeLog.omp b/gcc/fortran/ChangeLog.omp index a02606190319..9e0cf7198acf 100644 --- a/gcc/fortran/ChangeLog.omp +++ b/gcc/fortran/ChangeLog.omp @@ -1,3 +1,10 @@ +2021-02-24 Julian Brown + + Backport from mainline + + * trans-openmp.c (gfc_trans_omp_clauses): Fix dereferencing for + BT_DERIVED members. + 2021-02-12 Tobias Burnus Backport from mainline diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c index 452e2a69baa2..e53f7ebb7d7f 100644 --- a/gcc/fortran/trans-openmp.c +++ b/gcc/fortran/trans-openmp.c @@ -2980,6 +2980,8 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses, if (lastcomp->u.c.component->ts.type == BT_CLASS) { data = gfc_class_data_get (inner); + gcc_assert (POINTER_TYPE_P (TREE_TYPE (data))); + data = build_fold_indirect_ref (data); size = gfc_class_vtab_size_get (inner); } else /* BT_DERIVED. */ @@ -2988,8 +2990,7 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses, size = TYPE_SIZE_UNIT (TREE_TYPE (inner)); } - OMP_CLAUSE_DECL (node) - = build_fold_indirect_ref (data); + OMP_CLAUSE_DECL (node) = data; OMP_CLAUSE_SIZE (node) = size; node2 = build_omp_clause (input_location, OMP_CLAUSE_MAP); @@ -2997,7 +2998,7 @@ 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) = build_fold_addr_expr (data); OMP_CLAUSE_SIZE (node2) = size_int (0); } else diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp index 8f5512990b85..8caef33f95e4 100644 --- a/gcc/testsuite/ChangeLog.omp +++ b/gcc/testsuite/ChangeLog.omp @@ -1,3 +1,9 @@ +2021-02-24 Julian Brown + + Backport from mainline + + * gfortran.dg/goacc/derived-classtypes-1.f95: New test. + 2021-02-12 Tobias Burnus Backport from mainline 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 000000000000..e6cf09c6d3c1 --- /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 Wed Feb 24 21:57:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Brown X-Patchwork-Id: 1444068 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 4Dm8tQ6yGJz9sSC for ; Thu, 25 Feb 2021 08:58:06 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0EE00395ACD3; Wed, 24 Feb 2021 21:57:49 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa4.mentor.iphmx.com (esa4.mentor.iphmx.com [68.232.137.252]) by sourceware.org (Postfix) with ESMTPS id D06543959E59; Wed, 24 Feb 2021 21:57:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D06543959E59 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: nGLuoNGJX0EE/SOdx3Z8I8wc+tkoQapOxweZD+zl/D2Bym8fV8aUUnRjhjDbTKPmriXwqJJ+40 PUp/TZqFdQQ+JlI3M/NB3DhAKtkFkwAXdbQsJota1yL7OmIG9DZjVMfGE4e1lYBeJZjO1yDqgf s2xWW9JJ+8hQx3bIH1/HVYmZe65+pilTTrArNxwmFhBPMppCXBLg6NwnLtScIaUamYBwV8l8LU cH8zE/DBJ8X2z4COuaamgmwU8MmN4pSa0kn3a7T71YVcORB4GE00Ni7/WRrRAk9g0RiPYZ1676 n6k= X-IronPort-AV: E=Sophos;i="5.81,203,1610438400"; d="scan'208";a="58597697" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa4.mentor.iphmx.com with ESMTP; 24 Feb 2021 13:57:45 -0800 IronPort-SDR: nhkRmnmckDtBVwqf63Tn5XgGCtav6IgLvwEICHDiswmu8nYvb8VIyuw8G1Rmw4pVhb+JgC7enl 2QeF9VPnjnuZkrswCv/NTDCBlYLKK+C7ub0fFO0pbbAQgvFUzOiOSDkwvmRw3KsbdKdwS7nN9/ gyFF2cMPcyb1lSzMSUBcel1Ds0oc7dYgzm5fUMDqKx72GWYyrqHsp0oIleTx/hoci3NO3lV3Bp OWjDUTTG1/6NPq+oZN2gX6YYO6uOf2DYYiENOajm36Rx7Cmtr5RITlGbq+SNs+iZGrCuvki0Kh PdU= From: Julian Brown To: Subject: [PATCH 2/7] [og10] openacc: Use class_pointer instead of pointer attribute for class types Date: Wed, 24 Feb 2021 13:57:23 -0800 Message-ID: <20210224215726.129681-3-julian@codesourcery.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210224215726.129681-1-julian@codesourcery.com> References: <20210224215726.129681-1-julian@codesourcery.com> MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: SVR-IES-MBX-07.mgc.mentorg.com (139.181.222.7) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) 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: Tobias Burnus , fortran@gcc.gnu.org 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. gcc/fortran/ * trans-openmp.c (gfc_trans_omp_clauses): Use class_pointer attribute for BT_CLASS. (cherry picked from commit f743fe231663e32d52db987650d0ec3381a777af) --- gcc/fortran/ChangeLog.omp | 7 +++++++ gcc/fortran/trans-openmp.c | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/gcc/fortran/ChangeLog.omp b/gcc/fortran/ChangeLog.omp index 9e0cf7198acf..2dd82a70cb71 100644 --- a/gcc/fortran/ChangeLog.omp +++ b/gcc/fortran/ChangeLog.omp @@ -1,3 +1,10 @@ +2021-02-24 Julian Brown + + Backport from mainline + + * trans-openmp.c (gfc_trans_omp_clauses): Use class_pointer attribute + for BT_CLASS. + 2021-02-24 Julian Brown Backport from mainline diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c index e53f7ebb7d7f..d0e299b02142 100644 --- a/gcc/fortran/trans-openmp.c +++ b/gcc/fortran/trans-openmp.c @@ -2973,7 +2973,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 Wed Feb 24 21:57:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Brown X-Patchwork-Id: 1444069 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 4Dm8tV5Y8yz9sBy for ; Thu, 25 Feb 2021 08:58:10 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 80F8F395B059; Wed, 24 Feb 2021 21:57:53 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa4.mentor.iphmx.com (esa4.mentor.iphmx.com [68.232.137.252]) by sourceware.org (Postfix) with ESMTPS id 4F06E395B059; Wed, 24 Feb 2021 21:57:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4F06E395B059 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: k4jHu2x6RFZ7RbgjMM2jz7ihL14n3S2ooR2vVgAOg+L/XRdKYjPyhUtiu3cfk+0QcuU+ASCsGV Izxo+2xGfKEiudJVzMbEIihuiBN/2dHiU/ebszW6DRGz9Xjp+xhhPrx/rEGAvP1Kxh8KGg3kpP mneqQ/hoNCrSxzGujAYq8kpHkSwWkYO2Bzt3X+batdENFxsSBczuuvIdL548Sik/z79IcHVMRC tXO3pdzP9gwIMNqi7jdmPmEcLX4cKFqwCCWSnUofYHqPHnzvqTMXKHitcpWoa/Z5JrUiuvw0g+ pAY= X-IronPort-AV: E=Sophos;i="5.81,203,1610438400"; d="scan'208";a="58597698" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa4.mentor.iphmx.com with ESMTP; 24 Feb 2021 13:57:48 -0800 IronPort-SDR: eTrWruJxUY8fdsq+DSIzXFKimBsPJRB65UCUu907ZGuJp7IQfolaM8i0XtWYbSEjGATL09suJc l0tUoe+VdRd+MXMZG1zfQk1vz+Mgamu9qFIGd0S2U/xIjXhFqQBJafNH0PTPD/uzLEKyZMhZDF ZrhpVSG3+6fYguJlDzZPG/9E+q5PGoXsM7xqN+fKvaNp4yv0MuakXoPBzic0UsbEJt1Twzjet8 qIQ9Lc8Bshqwzv4UKqzRnvpfsMNpZ/WVPhChHbVdLwD26JfYphl7ctio3sh9b+hyu/z6WrBCcX FBc= From: Julian Brown To: Subject: [PATCH 3/7] [og10] openacc: Character types and mixed arrays/derived type tests Date: Wed, 24 Feb 2021 13:57:24 -0800 Message-ID: <20210224215726.129681-4-julian@codesourcery.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210224215726.129681-1-julian@codesourcery.com> References: <20210224215726.129681-1-julian@codesourcery.com> MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: SVR-IES-MBX-07.mgc.mentorg.com (139.181.222.7) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) 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: Tobias Burnus , fortran@gcc.gnu.org Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" This patch adds some tests for character types that are components of derived types used in OpenACC data-movement clauses (some of which currently fail and are thus XFAILed), and tests (also XFAILed) mixing arrays and derived types. The XFAILs are addressed by follow-on patches. Originally a combination of several mainline patches. (cherry picked from commit b2d84e9f9cccbe4ee662f7002b83105629d09939) (cherry picked from commit 9a4d32f85ccebc0ee4b24e6d9d7a4f11c04d7146) (cherry picked from commit b0fb2720d88d680af18981a2097397196b505a1f) (cherry picked from commit f7fb2f662fe12f327ece8b034ab76b36fdca4696) gcc/testsuite/ * gfortran.dg/goacc/array-with-dt-2.f90: New test. * gfortran.dg/goacc/derived-chartypes-1.f90: Likewise. * gfortran.dg/goacc/derived-chartypes-2.f90: Likewise. * gfortran.dg/goacc/derived-chartypes-3.f90: Likewise. * gfortran.dg/goacc/derived-chartypes-4.f90: Likewise. libgomp/ * testsuite/libgomp.oacc-fortran/array-stride-dt-1.f90: New test. --- gcc/testsuite/ChangeLog.omp | 10 ++ .../gfortran.dg/goacc/array-with-dt-2.f90 | 11 ++ .../gfortran.dg/goacc/derived-chartypes-1.f90 | 132 ++++++++++++++++++ .../gfortran.dg/goacc/derived-chartypes-2.f90 | 132 ++++++++++++++++++ .../gfortran.dg/goacc/derived-chartypes-3.f90 | 38 +++++ .../gfortran.dg/goacc/derived-chartypes-4.f90 | 38 +++++ libgomp/ChangeLog.omp | 6 + .../array-stride-dt-1.f90 | 45 ++++++ 8 files changed, 412 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/goacc/array-with-dt-2.f90 create mode 100644 gcc/testsuite/gfortran.dg/goacc/derived-chartypes-1.f90 create mode 100644 gcc/testsuite/gfortran.dg/goacc/derived-chartypes-2.f90 create mode 100644 gcc/testsuite/gfortran.dg/goacc/derived-chartypes-3.f90 create mode 100644 gcc/testsuite/gfortran.dg/goacc/derived-chartypes-4.f90 create mode 100644 libgomp/testsuite/libgomp.oacc-fortran/array-stride-dt-1.f90 diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp index 8caef33f95e4..e04a4ee3ebff 100644 --- a/gcc/testsuite/ChangeLog.omp +++ b/gcc/testsuite/ChangeLog.omp @@ -1,3 +1,13 @@ +2021-02-24 Julian Brown + + Backport from mainline + + * gfortran.dg/goacc/array-with-dt-2.f90: New test. + * gfortran.dg/goacc/derived-chartypes-1.f90: Likewise. + * gfortran.dg/goacc/derived-chartypes-2.f90: Likewise. + * gfortran.dg/goacc/derived-chartypes-3.f90: Likewise. + * gfortran.dg/goacc/derived-chartypes-4.f90: Likewise. + 2021-02-24 Julian Brown Backport from mainline 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 000000000000..e4a6f319772c --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/array-with-dt-2.f90 @@ -0,0 +1,11 @@ +type t + integer, allocatable :: A(:,:) +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 specified for array section in MAP clause" } +end + diff --git a/gcc/testsuite/gfortran.dg/goacc/derived-chartypes-1.f90 b/gcc/testsuite/gfortran.dg/goacc/derived-chartypes-1.f90 new file mode 100644 index 000000000000..f7aafbfc036f --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/derived-chartypes-1.f90 @@ -0,0 +1,132 @@ +! This currently ICEs. Avoid that. +! { dg-skip-if "PR98979" { *-*-* } } + +type :: type1 + character(len=35) :: a +end type type1 + +type :: type2 + character(len=35), pointer :: b +end type type2 + +type :: aux1 + character(len=22) :: y +end type aux1 + +type, extends(aux1) :: aux + character(len=33) :: x +end type aux + +type :: type3 + class(aux), pointer :: c(:) +end type type3 + +type :: type4 + integer, pointer :: d(:) +end type type4 + +type :: type5 + type(aux1) :: e +end type type5 + +type :: type6 + type(aux1), 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 diff --git a/gcc/testsuite/gfortran.dg/goacc/derived-chartypes-2.f90 b/gcc/testsuite/gfortran.dg/goacc/derived-chartypes-2.f90 new file mode 100644 index 000000000000..e22fc679df2b --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/derived-chartypes-2.f90 @@ -0,0 +1,132 @@ +! This currently ICEs. Avoid that. +! { dg-skip-if "PR98979" { *-*-* } } + +type :: type1 + character(len=35,kind=4) :: a +end type type1 + +type :: type2 + character(len=35,kind=4), pointer :: b +end type type2 + +type :: aux1 + character(len=22,kind=4) :: y +end type aux1 + +type, extends(aux1) :: aux + character(len=33,kind=4) :: x +end type aux + +type :: type3 + class(aux), pointer :: c(:) +end type type3 + +type :: type4 + integer, pointer :: d(:) +end type type4 + +type :: type5 + type(aux1) :: e +end type type5 + +type :: type6 + type(aux1), 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 diff --git a/gcc/testsuite/gfortran.dg/goacc/derived-chartypes-3.f90 b/gcc/testsuite/gfortran.dg/goacc/derived-chartypes-3.f90 new file mode 100644 index 000000000000..2bab497cef5d --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/derived-chartypes-3.f90 @@ -0,0 +1,38 @@ +! { dg-additional-options "-fdump-tree-gimple" } + +type :: type1 + character(len=35) :: a +end type type1 + +type :: type2 + character(len=46), pointer :: b +end type type2 + +type(type1) :: foo +type(type2) :: bar + +type(type1), pointer :: pfoo +type(type2), pointer :: pbar + +class(type1), pointer :: cfoo +class(type2), pointer :: cbar + +class(type1), allocatable :: acfoo +class(type2), allocatable :: acbar + +!$acc enter data copyin(foo%a) +!$acc enter data copyin(bar%b) + +!$acc enter data copyin(pfoo%a) +!$acc enter data copyin(pbar%b) + +!$acc enter data copyin(cfoo%a) +!$acc enter data copyin(cbar%b) + +!$acc enter data copyin(acfoo%a) +!$acc enter data copyin(acbar%b) + +! { dg-final { scan-tree-dump-times "to:\[^\\\[\]*\\\[len: 35\\\]" 4 "gimple" } } +! { dg-final { scan-tree-dump-times "to:\[^\\\[\]*\\\[len: 46\\\]" 4 "gimple" } } + +end diff --git a/gcc/testsuite/gfortran.dg/goacc/derived-chartypes-4.f90 b/gcc/testsuite/gfortran.dg/goacc/derived-chartypes-4.f90 new file mode 100644 index 000000000000..cfe40066a595 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/derived-chartypes-4.f90 @@ -0,0 +1,38 @@ +! { dg-additional-options "-fdump-tree-gimple" } + +type :: type1 + character(len=35,kind=4) :: a +end type type1 + +type :: type2 + character(len=46,kind=4), pointer :: b +end type type2 + +type(type1) :: foo +type(type2) :: bar + +type(type1), pointer :: pfoo +type(type2), pointer :: pbar + +class(type1), pointer :: cfoo +class(type2), pointer :: cbar + +class(type1), allocatable :: acfoo +class(type2), allocatable :: acbar + +!$acc enter data copyin(foo%a) +!$acc enter data copyin(bar%b) + +!$acc enter data copyin(pfoo%a) +!$acc enter data copyin(pbar%b) + +!$acc enter data copyin(cfoo%a) +!$acc enter data copyin(cbar%b) + +!$acc enter data copyin(acfoo%a) +!$acc enter data copyin(acbar%b) + +! { dg-final { scan-tree-dump-times "to:\[^\\\[\]*\\\[len: 140\\\]" 4 "gimple" } } +! { dg-final { scan-tree-dump-times "to:\[^\\\[\]*\\\[len: 184\\\]" 4 "gimple" } } + +end diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp index addab7d05c5f..db6ac79fe123 100644 --- a/libgomp/ChangeLog.omp +++ b/libgomp/ChangeLog.omp @@ -1,3 +1,9 @@ +2021-02-24 Julian Brown + + Backport from mainline + + * testsuite/libgomp.oacc-fortran/array-stride-dt-1.f90: New test. + 2021-02-09 Kwok Cheung Yeung Backport from mainline diff --git a/libgomp/testsuite/libgomp.oacc-fortran/array-stride-dt-1.f90 b/libgomp/testsuite/libgomp.oacc-fortran/array-stride-dt-1.f90 new file mode 100644 index 000000000000..61250708197d --- /dev/null +++ b/libgomp/testsuite/libgomp.oacc-fortran/array-stride-dt-1.f90 @@ -0,0 +1,45 @@ +! { dg-do run } + +type t + integer, allocatable :: A(:,:) +end type t + +type(t), allocatable :: b(:) + +integer :: i + +allocate(b(1:20)) +do i=1,20 + allocate(b(i)%A(1:20,1:20)) +end do + +do i=1,20 + b(i)%A(:,:) = 0 +end do + +!$acc enter data copyin(b) +do i=1,20 + !$acc enter data copyin(b(i)%A) +end do + +b(1)%A(:,:) = 5 + +! TODO: Remove expected errors once this is supported. +!$acc update device(b(::2)) ! { dg-error "Stride should not be specified 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" } + +do i=1,20 + !$acc exit data copyout(b(i)%A) +end do +!$acc exit data copyout(b) + +! This is necessarily conservative because the "update" is allowed to copy +! e.g. the whole of the containing block for a discontinuous update. +! Try to ensure that the update covers a sufficient portion of the array. + +if (any(b(1)%A(::3,::4) .ne. 5)) stop 1 +do i=2,20 + if (any(b(i)%A(:,:) .ne. 0)) stop 2 +end do + +end From patchwork Wed Feb 24 21:57:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Brown X-Patchwork-Id: 1444070 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 4Dm8tg0xHNz9sBy for ; Thu, 25 Feb 2021 08:58:19 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 04A07395B81A; Wed, 24 Feb 2021 21:57:55 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa4.mentor.iphmx.com (esa4.mentor.iphmx.com [68.232.137.252]) by sourceware.org (Postfix) with ESMTPS id E2D983959E61; Wed, 24 Feb 2021 21:57:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E2D983959E61 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: DrcsT0CUGMQnfF6u6YILynSW/8oI6GgStIlrrh+ru59AQd2UsaPyBFVgS4o/PtZEylWtuXJPAm y7L9nOoM1+oirZ+J8xpVkjJoE3nA4w9/4SIIGY603sp6I68i1Wuwh23wBo3Eg16C1hoL2btChh BWgMCdB+ceFMLUDYNNih9p24FjAHMy2TsW2kKmDVb1f0vyP7PEPOOSTZi0ypapVbo5Wgut3TlO 1ICjeNJhO+noYsZXnOy9Yqfzeega/9zfFfZyGbHBH1ZmJCHbnBX7alB0EKGiS7XD0fDZnwb0nn ZZo= X-IronPort-AV: E=Sophos;i="5.81,203,1610438400"; d="scan'208";a="58597699" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa4.mentor.iphmx.com with ESMTP; 24 Feb 2021 13:57:49 -0800 IronPort-SDR: EV2c7CVcasW28rXt5sEq353WweURm79WMvisiBxG9H39HtBdckt6znOF6oy/FSA3yvzppnUWOj G7iPortJNL+yk5kCEL6L0BPrBcCt2H+4mCz35/SxML0m1HlotTHeS+uG7vt8o1jMYDIwaNYC87 PWLuNdMqMIjMZrfNQkrOSPbgqSqaveqd+sU0+WZU39wZp0mO+XIfbw4/IIBb/Mv2zqlur6cmdw 6c9zGyKI0pdxdacTd8N8z8MZQ335yV9Fiu7lKhlgGrB3KSgzTG+69mrcd0fmpZ7RDGaBBStaOq SYA= From: Julian Brown To: Subject: [PATCH 4/7] [og10] Fortran: OpenMP/OpenACC diagnose substring rejections better Date: Wed, 24 Feb 2021 13:57:25 -0800 Message-ID: <20210224215726.129681-5-julian@codesourcery.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210224215726.129681-1-julian@codesourcery.com> References: <20210224215726.129681-1-julian@codesourcery.com> MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: SVR-IES-MBX-07.mgc.mentorg.com (139.181.222.7) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) 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: Tobias Burnus , fortran@gcc.gnu.org Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" From: Tobias Burnus gcc/fortran/ChangeLog: * openmp.c (resolve_omp_clauses): Explicitly diagnose substrings as not permitted. gcc/testsuite/ChangeLog: * gfortran.dg/goacc/substring.f90: New test. * gfortran.dg/gomp/substring.f90: New test. (cherry picked from commit f0e618faeb619ec02dabbef203a5575fca44a7f7) --- gcc/fortran/ChangeLog.omp | 7 +++++ gcc/fortran/openmp.c | 8 +++++- gcc/testsuite/ChangeLog.omp | 7 +++++ gcc/testsuite/gfortran.dg/goacc/substring.f90 | 27 +++++++++++++++++++ gcc/testsuite/gfortran.dg/gomp/substring.f90 | 22 +++++++++++++++ 5 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/goacc/substring.f90 create mode 100644 gcc/testsuite/gfortran.dg/gomp/substring.f90 diff --git a/gcc/fortran/ChangeLog.omp b/gcc/fortran/ChangeLog.omp index 2dd82a70cb71..09c2bb855c88 100644 --- a/gcc/fortran/ChangeLog.omp +++ b/gcc/fortran/ChangeLog.omp @@ -1,3 +1,10 @@ +2021-02-24 Tobias Burnus + + Backport from mainline + + * openmp.c (resolve_omp_clauses): Explicitly diagnose + substrings as not permitted. + 2021-02-24 Julian Brown Backport from mainline diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c index 61a340d7f396..a7592f0545d9 100644 --- a/gcc/fortran/openmp.c +++ b/gcc/fortran/openmp.c @@ -4978,7 +4978,13 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses, || (n->expr && (!resolved || n->expr->expr_type != EXPR_VARIABLE))) { - if (!resolved + if (array_ref + && (array_ref->type == REF_SUBSTRING + || (array_ref->next + && array_ref->next->type == REF_SUBSTRING))) + gfc_error ("Unexpected substring reference in %s clause " + "at %L", name, &n->where); + else if (!resolved || n->expr->expr_type != EXPR_VARIABLE || array_ref->next || array_ref->type != REF_ARRAY) diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp index e04a4ee3ebff..d012e9e75b4e 100644 --- a/gcc/testsuite/ChangeLog.omp +++ b/gcc/testsuite/ChangeLog.omp @@ -1,3 +1,10 @@ +2021-02-24 Tobias Burnus + + Backport from mainline + + * gfortran.dg/goacc/substring.f90: New test. + * gfortran.dg/gomp/substring.f90: New test. + 2021-02-24 Julian Brown Backport from mainline diff --git a/gcc/testsuite/gfortran.dg/goacc/substring.f90 b/gcc/testsuite/gfortran.dg/goacc/substring.f90 new file mode 100644 index 000000000000..25031daddf33 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/substring.f90 @@ -0,0 +1,27 @@ +implicit none +character(len=10) :: str1, str2(5,5) + +type t + character(len=10) :: str1, str2(5,5) +end type t +type(t) :: v + +!$acc enter data copyin(v%str1) ! OK +!$acc enter data copyin(v%str2) ! OK +!$acc enter data copyin(v%str2(1,2)) ! OK +!$acc enter data copyin(str1) ! OK +!$acc enter data copyin(str2) ! OK +!$acc enter data copyin(str2(1,2)) ! OK + +!$acc enter data copyin(v%str1(2:5)) ! { dg-error "Unexpected substring reference in MAP clause" } +!$acc enter data copyin(v%str2(1,2)(2:4)) ! { dg-error "Unexpected substring reference in MAP clause" } +!$acc enter data copyin(str1(2:5)) ! { dg-error "Unexpected substring reference in MAP clause" } +!$acc enter data copyin(str2(1,2)(2:4)) ! { dg-error "Unexpected substring reference in MAP clause" } + +!$acc parallel +!$acc update host(v%str1(2:5)) ! { dg-error "Unexpected substring reference in MAP clause" } +!$acc update host(v%str2(1,2)(2:4)) ! { dg-error "Unexpected substring reference in MAP clause" } +!$acc update host(str1(2:5)) ! { dg-error "Unexpected substring reference in MAP clause" } +!$acc update host(str2(1,2)(2:4)) ! { dg-error "Unexpected substring reference in MAP clause" } +!$acc end parallel +end diff --git a/gcc/testsuite/gfortran.dg/gomp/substring.f90 b/gcc/testsuite/gfortran.dg/gomp/substring.f90 new file mode 100644 index 000000000000..23d7fb7e48ab --- /dev/null +++ b/gcc/testsuite/gfortran.dg/gomp/substring.f90 @@ -0,0 +1,22 @@ +implicit none +character(len=10) :: str1, str2(5,5) + +type t + character(len=10) :: str1, str2(5,5) +end type t +type(t) :: v + +!$omp target enter data map(to: str1) ! OK +!$omp target enter data map(to: str2) ! OK +!$omp target enter data map(to: str2(2,5)) ! OK + +!$omp target enter data map(to: str1(2,5)) ! { dg-error "Syntax error in OpenMP variable list" } +!$omp target enter data map(to: str2(1,2)(2:4)) ! { dg-error "Unexpected substring reference in MAP clause" } + +!$omp target enter data map(to: v%str1) ! OK +!$omp target enter data map(to: v%str2) ! OK +!$omp target enter data map(to: v%str2(1,2)) ! OK + +!$omp target enter data map(to: v%str1(2:5)) ! { dg-error "Unexpected substring reference in MAP clause" } +!$omp target enter data map(to: v%str2(1,2)(2:4)) ! { dg-error "Unexpected substring reference in MAP clause" } +end From patchwork Wed Feb 24 21:58:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Brown X-Patchwork-Id: 1444071 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 4Dm8vM35Rxz9sBy for ; Thu, 25 Feb 2021 08:58:55 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5E357395B818; Wed, 24 Feb 2021 21:58:51 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa1.mentor.iphmx.com (esa1.mentor.iphmx.com [68.232.129.153]) by sourceware.org (Postfix) with ESMTPS id 811FD3959E65; Wed, 24 Feb 2021 21:58:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 811FD3959E65 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: XZyj+xBlVqA6/bEgsVnPkGyqkXiQudE7OD1Gb7OQzruqjdm6t3iR+Qf1oNXQbpChd1ArH+J7Ru hdqs+CvIZnOf9n/IxpsMCu+Ouh5KEVjawBQKoG6dweeq6cVrEwwO07DZyu6TjqrvpGN5zafslT piyoJ2OCaApmtvluBaqZHqWtpqeJNR8GLr7Gmq4GYslrIZcOj00Zt5NKF8jnnC7J2BfGjy9y5s rrwbNrc5kKH2o6Kvbc2532RaLhvaXIkosC/vmwVAvMRvMcjw0ZPq4ddSiuUfPa59kQNkFvDE6i fSo= X-IronPort-AV: E=Sophos;i="5.81,203,1610438400"; d="scan'208";a="60790698" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa1.mentor.iphmx.com with ESMTP; 24 Feb 2021 13:58:47 -0800 IronPort-SDR: B/r9P0Dk051v64whwU5NuzvJNzTAl1sVPBp7ysZRgGkdp3e7KhMeg6F0YeLosSlshc0RUXgTCT E8c/4O6lwvyRT4pSt/hJfYc9l8W2FbUpdZArXOJTkVim9lDnQR9fG1C1CMWL6c7NMQZ3um22XO cvuDNjZMn88COyvEYLv3YID5JDg2HwoaMoxUR9xQI9yv6xN/hkdaarOvbEXs3ej6jXwiNDUVhK 93WlfcwTY+4RCHdUMMgK2KoT1rGwtKx5ZEHA1QaTYAFKbLvp7rDxfBcNaAlMW+WPKnRSGlo3oc T1M= From: Julian Brown To: Subject: [PATCH 5/7] [og10] Fortran: %re/%im fixes for OpenMP/OpenACC + gfc_is_simplify_contiguous Date: Wed, 24 Feb 2021 13:58:36 -0800 Message-ID: <20210224215838.130807-1-julian@codesourcery.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) 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: Tobias Burnus , fortran@gcc.gnu.org Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" From: Tobias Burnus gcc/fortran/ChangeLog: * expr.c (gfc_is_simplify_contiguous): Handle REF_INQUIRY, i.e. %im and %re which are EXPR_VARIABLE. * openmp.c (resolve_omp_clauses): Diagnose %re/%im explicitly. gcc/testsuite/ChangeLog: * gfortran.dg/goacc/ref_inquiry.f90: New test. * gfortran.dg/gomp/ref_inquiry.f90: New test. (cherry picked from commit 799478b8914c438f7a33eb319efbae69c81f2111) --- gcc/fortran/ChangeLog.omp | 8 +++ gcc/fortran/expr.c | 2 + gcc/fortran/openmp.c | 8 +++ gcc/testsuite/ChangeLog.omp | 7 +++ .../gfortran.dg/goacc/ref_inquiry.f90 | 56 +++++++++++++++++++ .../gfortran.dg/gomp/ref_inquiry.f90 | 39 +++++++++++++ 6 files changed, 120 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/goacc/ref_inquiry.f90 create mode 100644 gcc/testsuite/gfortran.dg/gomp/ref_inquiry.f90 diff --git a/gcc/fortran/ChangeLog.omp b/gcc/fortran/ChangeLog.omp index 09c2bb855c88..f99a11316f52 100644 --- a/gcc/fortran/ChangeLog.omp +++ b/gcc/fortran/ChangeLog.omp @@ -1,3 +1,11 @@ +2021-02-24 Tobias Burnus + + Backport from mainline + + * expr.c (gfc_is_simplify_contiguous): Handle REF_INQUIRY, i.e. + %im and %re which are EXPR_VARIABLE. + * openmp.c (resolve_omp_clauses): Diagnose %re/%im explicitly. + 2021-02-24 Tobias Burnus Backport from mainline diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index 569f4d9bf066..6cda947cd568 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -5837,6 +5837,8 @@ gfc_is_simply_contiguous (gfc_expr *expr, bool strict, bool permit_element) part_ref = ref; else if (ref->type == REF_SUBSTRING) return false; + else if (ref->type == REF_INQUIRY) + return false; else if (ref->u.ar.type != AR_ELEMENT) ar = &ref->u.ar; } diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c index a7592f0545d9..8d77f9e73510 100644 --- a/gcc/fortran/openmp.c +++ b/gcc/fortran/openmp.c @@ -4984,6 +4984,14 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses, && array_ref->next->type == REF_SUBSTRING))) gfc_error ("Unexpected substring reference in %s clause " "at %L", name, &n->where); + else if (array_ref && array_ref->type == REF_INQUIRY) + { + gcc_assert (array_ref->u.i == INQUIRY_RE + || array_ref->u.i == INQUIRY_IM); + gfc_error ("Unexpected complex-parts designator " + "reference in %s clause at %L", + name, &n->where); + } else if (!resolved || n->expr->expr_type != EXPR_VARIABLE || array_ref->next diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp index d012e9e75b4e..257981890982 100644 --- a/gcc/testsuite/ChangeLog.omp +++ b/gcc/testsuite/ChangeLog.omp @@ -1,3 +1,10 @@ +2021-02-24 Tobias Burnus + + Backport from mainline + + * gfortran.dg/goacc/ref_inquiry.f90: New test. + * gfortran.dg/gomp/ref_inquiry.f90: New test. + 2021-02-24 Tobias Burnus Backport from mainline diff --git a/gcc/testsuite/gfortran.dg/goacc/ref_inquiry.f90 b/gcc/testsuite/gfortran.dg/goacc/ref_inquiry.f90 new file mode 100644 index 000000000000..69dd38e51974 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/ref_inquiry.f90 @@ -0,0 +1,56 @@ +! Check for %re, ...%im, ...%kind, ...%len +! Cf. also OpenMP's ../gomp/ref_inquiry.f90 +! Cf. OpenACC spec issue 346 +! +implicit none +type t + integer :: i + character :: c + complex :: z + complex :: zz(5) +end type t + +integer :: i +character(kind=4, len=5) :: c +complex :: z, zz(5) +type(t) :: x + +print *, is_contiguous(zz(:)%re) + +! inquiry function; expr_type != EXPR_VARIABLE: +!$acc enter data copyin(i%kind, c%len) ! { dg-error "not a proper array section" } +!$acc enter data copyin(x%i%kind) ! { dg-error "not a proper array section" } +!$acc enter data copyin(x%c%len) ! { dg-error "not a proper array section" } +!$acc update self(i%kind, c%len) ! { dg-error "not a proper array section" } +!$acc update self(x%i%kind) ! { dg-error "not a proper array section" } +!$acc update self(x%c%len) ! { dg-error "not a proper array section" } + +! EXPR_VARIABLE +!$acc enter data copyin(z%re) ! { dg-error "Unexpected complex-parts designator" } +!$acc enter data copyin(z%im) ! { dg-error "Unexpected complex-parts designator" } +!$acc enter data copyin(zz%re) ! { dg-error "not a proper array section" } + ! { dg-error "Array is not contiguous" "" { target *-*-* } .-1 } +!$acc enter data copyin(zz%im) ! { dg-error "not a proper array section" } + ! { dg-error "Array is not contiguous" "" { target *-*-* } .-1 } + +!$acc enter data copyin(x%z%re) ! { dg-error "Unexpected complex-parts designator" } +!$acc enter data copyin(x%z%im) ! { dg-error "Unexpected complex-parts designator" } +!$acc enter data copyin(x%zz%re) ! { dg-error "not a proper array section" } + ! { dg-error "Array is not contiguous" "" { target *-*-* } .-1 } +!$acc enter data copyin(x%zz%im) ! { dg-error "not a proper array section" } + ! { dg-error "Array is not contiguous" "" { target *-*-* } .-1 } + +!$acc update self(z%re) ! { dg-error "Unexpected complex-parts designator" } +!$acc update self(z%im) ! { dg-error "Unexpected complex-parts designator" } +!$acc update self(zz%re) ! { dg-error "not a proper array section" } + ! { dg-error "Array is not contiguous" "" { target *-*-* } .-1 } +!$acc update self(zz%im) ! { dg-error "not a proper array section" } + ! { dg-error "Array is not contiguous" "" { target *-*-* } .-1 } + +!$acc update self(x%z%re) ! { dg-error "Unexpected complex-parts designator" } +!$acc update self(x%z%im) ! { dg-error "Unexpected complex-parts designator" } +!$acc update self(x%zz%re) ! { dg-error "is not a proper array section" } + ! { dg-error "Array is not contiguous" "" { target *-*-* } .-1 } +!$acc update self(x%zz%im) ! { dg-error "is not a proper array section" } + ! { dg-error "Array is not contiguous" "" { target *-*-* } .-1 } +end diff --git a/gcc/testsuite/gfortran.dg/gomp/ref_inquiry.f90 b/gcc/testsuite/gfortran.dg/gomp/ref_inquiry.f90 new file mode 100644 index 000000000000..374610405601 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/gomp/ref_inquiry.f90 @@ -0,0 +1,39 @@ +! Check for %re, ...%im, ...%kind, ...%len +! Cf. also OpenACC's ../goacc/ref_inquiry.f90 +! Cf. also OpenMP spec issue 2661 +implicit none +type t + integer :: i + character :: c + complex :: z + complex :: zz(5) +end type t + +integer :: i +character(kind=4, len=5) :: c +complex :: z, zz(5) +type(t) :: x + +print *, is_contiguous(zz(:)%re) + +! inquiry function; expr_type != EXPR_VARIABLE: +!$omp target enter data map(to: i%kind, c%len) ! { dg-error "not a proper array section" } +!$omp target enter data map(to: x%i%kind) ! { dg-error "not a proper array section" } +!$omp target enter data map(to: x%c%len) ! { dg-error "not a proper array section" } + +! EXPR_VARIABLE +!$omp target enter data map(to: z%re) ! { dg-error "Unexpected complex-parts designator" } +!$omp target enter data map(to: z%im) ! { dg-error "Unexpected complex-parts designator" } +!$omp target enter data map(to: zz%re) ! { dg-error "not a proper array section" } + ! { dg-error "Array is not contiguous" "" { target *-*-* } .-1 } +!$omp target enter data map(to: zz%im) ! { dg-error "not a proper array section" } + ! { dg-error "Array is not contiguous" "" { target *-*-* } .-1 } + +!$omp target enter data map(to: x%z%re) ! { dg-error "Unexpected complex-parts designator" } +!$omp target enter data map(to: x%z%im) ! { dg-error "Unexpected complex-parts designator" } +!$omp target enter data map(to: x%zz%re) ! { dg-error "not a proper array section" } + ! { dg-error "Array is not contiguous" "" { target *-*-* } .-1 } +!$omp target enter data map(to: x%zz%im) ! { dg-error "not a proper array section" } + ! { dg-error "Array is not contiguous" "" { target *-*-* } .-1 } + +end From patchwork Wed Feb 24 21:58:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Brown X-Patchwork-Id: 1444073 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 4Dm8vh6gRHz9sBy for ; Thu, 25 Feb 2021 08:59:12 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CA241395B821; Wed, 24 Feb 2021 21:58:56 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa1.mentor.iphmx.com (esa1.mentor.iphmx.com [68.232.129.153]) by sourceware.org (Postfix) with ESMTPS id 018EB3959E5D; Wed, 24 Feb 2021 21:58:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 018EB3959E5D 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: Ul5Eae6k/50hph9pUygbYFLd3Um+ChVZfTAYB2m8fvxmCbcNEuWFFy+lr56DaAxn7PHdH+cMP1 FTM0R5z2OWGk+G6ubz+Ys+VlHs8nt6YE0cwpyFpwlq0RQaHOW2S426QotF52eWtlY/JEWV3Rp3 o4o+9bDTSLQRVEaLih6RSLnvg3brTkTJxxbUFfy/4BvenLfsjA/VuO93gWJ+YZZ8wkIvt7fR1f Dbu9hslYriD7oB7sBQbIT62mHL8Rp0RRLx3/pej2vSg4aVvI4yV44+jw3qnVf8KscT/FkTX44I APg= X-IronPort-AV: E=Sophos;i="5.81,203,1610438400"; d="scan'208";a="60790699" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa1.mentor.iphmx.com with ESMTP; 24 Feb 2021 13:58:50 -0800 IronPort-SDR: 5HAHA1kXqFtXjd64QHcorZwHxwcyqeOGB21nEppX/YpnoDF8QSa9RJT56IQkj9r+H7AZv/JkHC QNPr1RZS8IMyCcMsU8K70DbWhJH74/P8o2MoI0itMVe3Q1X9Mnrs5SXucxJxp/bamWtBtCJHhc WRg8nvyKB9stJM1S4gfH5SV+XLJnrIlDWS+VdZeIrKWBfd78jlN3x/IKylNCnKqu2OtvWWo/SW 8vcBntgeyDoK+iDfJVrWzPKdIFDPNrg/GI03ChDkd1WQGgczx50qj6355Bh2xI8oGuKPVUdIlM kZk= From: Julian Brown To: Subject: [PATCH 6/7] [og10] openacc: Fix lowering for derived-type mappings through array elements Date: Wed, 24 Feb 2021 13:58:37 -0800 Message-ID: <20210224215838.130807-2-julian@codesourcery.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210224215838.130807-1-julian@codesourcery.com> References: <20210224215838.130807-1-julian@codesourcery.com> MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) 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, 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: Tobias Burnus , fortran@gcc.gnu.org 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, 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) --- gcc/ChangeLog.omp | 7 + gcc/fortran/ChangeLog.omp | 7 + gcc/fortran/trans-openmp.c | 192 ++++++++++-------- gcc/gimplify.c | 12 ++ gcc/testsuite/ChangeLog.omp | 13 ++ .../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 ++ .../gfortran.dg/goacc/derived-chartypes-1.f90 | 3 - .../gfortran.dg/goacc/derived-chartypes-2.f90 | 3 - .../goacc/derived-classtypes-1.f95 | 8 +- libgomp/ChangeLog.omp | 7 + .../derivedtypes-arrays-1.f90 | 109 ++++++++++ .../libgomp.oacc-fortran/update-dt-array.f90 | 53 +++++ 15 files changed, 378 insertions(+), 91 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 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/ChangeLog.omp b/gcc/ChangeLog.omp index ba959fb37a4f..a59c25b79763 100644 --- a/gcc/ChangeLog.omp +++ b/gcc/ChangeLog.omp @@ -1,3 +1,10 @@ +2021-02-24 Julian Brown + + Backport from mainline + + * gimplify.c (gimplify_scan_omp_clauses): Handle ATTACH_DETACH + for non-decls. + 2021-02-16 Tobias Burnus * doc/invoke.texi (nvptx's -misa): Update default to sm_35. diff --git a/gcc/fortran/ChangeLog.omp b/gcc/fortran/ChangeLog.omp index f99a11316f52..007855075563 100644 --- a/gcc/fortran/ChangeLog.omp +++ b/gcc/fortran/ChangeLog.omp @@ -1,3 +1,10 @@ +2021-02-24 Julian Brown + + Backport from mainline + + * trans-openmp.c (gfc_trans_omp_clauses): Handle element selection + for arrays of derived types. + 2021-02-24 Tobias Burnus Backport from mainline diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c index d0e299b02142..e3df4bbf84ec 100644 --- a/gcc/fortran/trans-openmp.c +++ b/gcc/fortran/trans-openmp.c @@ -2660,6 +2660,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)) @@ -2887,74 +2913,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) { @@ -2963,24 +2994,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); gcc_assert (POINTER_TYPE_P (TREE_TYPE (data))); @@ -3011,9 +3048,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. */ @@ -3107,27 +3143,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 4e99ee2d38af..bf2129c79580 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -9440,6 +9440,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/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp index 257981890982..98032a72d4b9 100644 --- a/gcc/testsuite/ChangeLog.omp +++ b/gcc/testsuite/ChangeLog.omp @@ -1,3 +1,16 @@ +2021-02-24 Julian Brown + + Backport from mainline + + * 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. + 2021-02-24 Tobias Burnus Backport from mainline 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 000000000000..4a3ff0ef3a75 --- /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 000000000000..dcb63657f2bb --- /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 000000000000..637d5f57e1c1 --- /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 000000000000..900587b7eaf6 --- /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-chartypes-1.f90 b/gcc/testsuite/gfortran.dg/goacc/derived-chartypes-1.f90 index f7aafbfc036f..e4d360e1262b 100644 --- a/gcc/testsuite/gfortran.dg/goacc/derived-chartypes-1.f90 +++ b/gcc/testsuite/gfortran.dg/goacc/derived-chartypes-1.f90 @@ -1,6 +1,3 @@ -! This currently ICEs. Avoid that. -! { dg-skip-if "PR98979" { *-*-* } } - type :: type1 character(len=35) :: a end type type1 diff --git a/gcc/testsuite/gfortran.dg/goacc/derived-chartypes-2.f90 b/gcc/testsuite/gfortran.dg/goacc/derived-chartypes-2.f90 index e22fc679df2b..cca6443e7fcf 100644 --- a/gcc/testsuite/gfortran.dg/goacc/derived-chartypes-2.f90 +++ b/gcc/testsuite/gfortran.dg/goacc/derived-chartypes-2.f90 @@ -1,6 +1,3 @@ -! This currently ICEs. Avoid that. -! { dg-skip-if "PR98979" { *-*-* } } - type :: type1 character(len=35,kind=4) :: a end type type1 diff --git a/gcc/testsuite/gfortran.dg/goacc/derived-classtypes-1.f95 b/gcc/testsuite/gfortran.dg/goacc/derived-classtypes-1.f95 index e6cf09c6d3c1..85a2e1d373d0 100644 --- a/gcc/testsuite/gfortran.dg/goacc/derived-classtypes-1.f95 +++ b/gcc/testsuite/gfortran.dg/goacc/derived-classtypes-1.f95 @@ -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/ChangeLog.omp b/libgomp/ChangeLog.omp index db6ac79fe123..0f862d1b573a 100644 --- a/libgomp/ChangeLog.omp +++ b/libgomp/ChangeLog.omp @@ -1,3 +1,10 @@ +2021-02-24 Julian Brown + + 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 Backport from mainline 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 000000000000..644ad1f6b2fc --- /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 000000000000..d796eddceda5 --- /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 Wed Feb 24 21:58:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Brown X-Patchwork-Id: 1444072 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 4Dm8vW750rz9sSC for ; Thu, 25 Feb 2021 08:59:03 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 913DB395BC12; Wed, 24 Feb 2021 21:58:55 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa1.mentor.iphmx.com (esa1.mentor.iphmx.com [68.232.129.153]) by sourceware.org (Postfix) with ESMTPS id 6FE83395B821; Wed, 24 Feb 2021 21:58:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6FE83395B821 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: Psk6za7pV3SVo3wAZN6yV9GIzgkjtNnYNQYNtvIO0qju78I+5e/t39Dgt994xfp+s7owF/chmX XIteCcUyHVD7CkwqSW6FZhNClvYD3O6xzeUw8Jnb3uJihLeta8ypFmDlITYBSTa7GYIwkY9h2u N3vAHE565FGVZtKOu2XevbixnAriHZ6cBs/m1EnEi5f2muL1L2/X4xrLObY3pijBdKE8i/7TPj IpvtE0JnInI3EQb9do9pH+6N8LJcP7gJi+clPQHkMrxT0vX8I2mn9gcZzHirlU3ckU5bIyf724 9iQ= X-IronPort-AV: E=Sophos;i="5.81,203,1610438400"; d="scan'208";a="60790700" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa1.mentor.iphmx.com with ESMTP; 24 Feb 2021 13:58:51 -0800 IronPort-SDR: cPHxWgqy8mvw5jZqce8Pj63b9wSlrSB+hqp2QdsNgS7tcEIyLs9wpRNNjPzBPctDzqZYMazn5t zRvgNXot7HZ7sts2Vrir2zqqhEIp2I/UKOoeJl/S9MMTPMrOo3+nmUXP36BW7xlTlorv4/Qtat 7Ib2ySKGh1sqbfBkBWX6tm9ujefTMtlm6tvMzLulRiOl0LfoiYtBh8eBYEslmW+RWgnancqYr/ 8S055FlPw/TnIg9xF6o62S807ReFRziffCnf+etH8i66fNjHv94IUmJ59Laj3MD3BGYqYGLr4f 3cY= From: Julian Brown To: Subject: [PATCH 7/7] [og10] openacc: Strided array sections and components of derived-type arrays Date: Wed, 24 Feb 2021 13:58:38 -0800 Message-ID: <20210224215838.130807-3-julian@codesourcery.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210224215838.130807-1-julian@codesourcery.com> References: <20210224215838.130807-1-julian@codesourcery.com> MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) 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, 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: Tobias Burnus , fortran@gcc.gnu.org Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" This patch disallows selecting components of array sections in update directives for OpenACC, as specified in OpenACC 3.0, "2.14.4. Update Directive": In Fortran, members of variables of derived type may appear, including 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. 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. * gfortran.dg/goacc/ref_inquiry.f90: Update expected errors. * gfortran.dg/gomp/ref_inquiry.f90: Likewise. libgomp/ * testsuite/libgomp.oacc-fortran/array-stride-dt-1.f90: Remove expected errors. (cherry picked from commit 366cf1127a547ff77024a551abb01bb1a6e963cd) --- gcc/fortran/ChangeLog.omp | 7 ++ gcc/fortran/openmp.c | 64 +++++++++++-------- gcc/testsuite/ChangeLog.omp | 10 +++ .../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 +- .../gfortran.dg/goacc/ref_inquiry.f90 | 8 --- .../gfortran.dg/gomp/ref_inquiry.f90 | 4 -- libgomp/ChangeLog.omp | 7 ++ .../array-stride-dt-1.f90 | 5 +- 10 files changed, 78 insertions(+), 46 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/goacc/array-with-dt-6.f90 diff --git a/gcc/fortran/ChangeLog.omp b/gcc/fortran/ChangeLog.omp index 007855075563..45c68a38914e 100644 --- a/gcc/fortran/ChangeLog.omp +++ b/gcc/fortran/ChangeLog.omp @@ -1,3 +1,10 @@ +2021-02-24 Julian Brown + + Backport from mainline + + * openmp.c (resolve_omp_clauses): Disallow selecting components + of arrays of derived type. + 2021-02-24 Julian Brown Backport from mainline diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c index 8d77f9e73510..7085caf772e1 100644 --- a/gcc/fortran/openmp.c +++ b/gcc/fortran/openmp.c @@ -4940,17 +4940,31 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses, "are allowed on ORDERED directive at %L", &n->where); } - gfc_ref *array_ref = NULL; + gfc_ref *lastref = NULL, *lastslice = NULL; bool resolved = false; if (n->expr) { - array_ref = n->expr->ref; + lastref = n->expr->ref; resolved = gfc_resolve_expr (n->expr); /* Look through component refs to find last array reference. */ if (resolved) { + for (gfc_ref *ref = n->expr->ref; ref; ref = ref->next) + if (ref->type == REF_COMPONENT + || ref->type == REF_SUBSTRING + || ref->type == REF_INQUIRY) + lastref = ref; + else if (ref->type == REF_ARRAY) + { + for (int i = 0; i < ref->u.ar.dimen; i++) + if (ref->u.ar.dimen_type[i] == DIMEN_RANGE) + lastslice = ref; + + lastref = ref; + } + /* The "!$acc cache" directive allows rectangular subarrays to be specified, with some restrictions on the form of bounds (not implemented). @@ -4958,53 +4972,51 @@ 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)) + && gfc_is_not_contiguous (n->expr) + && !(lastslice + && (lastslice->next + || lastslice->type != REF_ARRAY))) gfc_error ("Array is not contiguous at %L", &n->where); - - while (array_ref - && (array_ref->type == REF_COMPONENT - || (array_ref->type == REF_ARRAY - && array_ref->next - && (array_ref->next->type - == REF_COMPONENT)))) - array_ref = array_ref->next; } } - if (array_ref + if (lastref || (n->expr && (!resolved || n->expr->expr_type != EXPR_VARIABLE))) { - if (array_ref - && (array_ref->type == REF_SUBSTRING - || (array_ref->next - && array_ref->next->type == REF_SUBSTRING))) + if (!lastslice + && lastref + && lastref->type == REF_SUBSTRING) gfc_error ("Unexpected substring reference in %s clause " "at %L", name, &n->where); - else if (array_ref && array_ref->type == REF_INQUIRY) + else if (!lastslice + && lastref + && lastref->type == REF_INQUIRY) { - gcc_assert (array_ref->u.i == INQUIRY_RE - || array_ref->u.i == INQUIRY_IM); + gcc_assert (lastref->u.i == INQUIRY_RE + || lastref->u.i == INQUIRY_IM); gfc_error ("Unexpected complex-parts designator " "reference in %s clause at %L", name, &n->where); } else if (!resolved - || n->expr->expr_type != EXPR_VARIABLE - || array_ref->next - || array_ref->type != REF_ARRAY) + || n->expr->expr_type != EXPR_VARIABLE + || (lastslice + && (lastslice->next + || lastslice->type != 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 = &array_ref->u.ar; + gfc_array_ref *ar = &lastslice->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/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp index 98032a72d4b9..f056b3c8f23d 100644 --- a/gcc/testsuite/ChangeLog.omp +++ b/gcc/testsuite/ChangeLog.omp @@ -1,3 +1,13 @@ +2021-02-24 Julian Brown + + Backport from mainline + + * 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. + * gfortran.dg/goacc/ref_inquiry.f90: Update expected errors. + * gfortran.dg/gomp/ref_inquiry.f90: Likewise. + 2021-02-24 Julian Brown Backport from mainline diff --git a/gcc/testsuite/gfortran.dg/goacc/array-with-dt-2.f90 b/gcc/testsuite/gfortran.dg/goacc/array-with-dt-2.f90 index e4a6f319772c..807580d75a9c 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 specified 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/testsuite/gfortran.dg/goacc/array-with-dt-6.f90 new file mode 100644 index 000000000000..adac8e3945eb --- /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 section" } +!$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/testsuite/gfortran.dg/goacc/mapping-tests-2.f90 index 1372f6af53e9..6b414fb85249 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/gcc/testsuite/gfortran.dg/goacc/ref_inquiry.f90 b/gcc/testsuite/gfortran.dg/goacc/ref_inquiry.f90 index 69dd38e51974..7f3cc4ae2749 100644 --- a/gcc/testsuite/gfortran.dg/goacc/ref_inquiry.f90 +++ b/gcc/testsuite/gfortran.dg/goacc/ref_inquiry.f90 @@ -29,28 +29,20 @@ print *, is_contiguous(zz(:)%re) !$acc enter data copyin(z%re) ! { dg-error "Unexpected complex-parts designator" } !$acc enter data copyin(z%im) ! { dg-error "Unexpected complex-parts designator" } !$acc enter data copyin(zz%re) ! { dg-error "not a proper array section" } - ! { dg-error "Array is not contiguous" "" { target *-*-* } .-1 } !$acc enter data copyin(zz%im) ! { dg-error "not a proper array section" } - ! { dg-error "Array is not contiguous" "" { target *-*-* } .-1 } !$acc enter data copyin(x%z%re) ! { dg-error "Unexpected complex-parts designator" } !$acc enter data copyin(x%z%im) ! { dg-error "Unexpected complex-parts designator" } !$acc enter data copyin(x%zz%re) ! { dg-error "not a proper array section" } - ! { dg-error "Array is not contiguous" "" { target *-*-* } .-1 } !$acc enter data copyin(x%zz%im) ! { dg-error "not a proper array section" } - ! { dg-error "Array is not contiguous" "" { target *-*-* } .-1 } !$acc update self(z%re) ! { dg-error "Unexpected complex-parts designator" } !$acc update self(z%im) ! { dg-error "Unexpected complex-parts designator" } !$acc update self(zz%re) ! { dg-error "not a proper array section" } - ! { dg-error "Array is not contiguous" "" { target *-*-* } .-1 } !$acc update self(zz%im) ! { dg-error "not a proper array section" } - ! { dg-error "Array is not contiguous" "" { target *-*-* } .-1 } !$acc update self(x%z%re) ! { dg-error "Unexpected complex-parts designator" } !$acc update self(x%z%im) ! { dg-error "Unexpected complex-parts designator" } !$acc update self(x%zz%re) ! { dg-error "is not a proper array section" } - ! { dg-error "Array is not contiguous" "" { target *-*-* } .-1 } !$acc update self(x%zz%im) ! { dg-error "is not a proper array section" } - ! { dg-error "Array is not contiguous" "" { target *-*-* } .-1 } end diff --git a/gcc/testsuite/gfortran.dg/gomp/ref_inquiry.f90 b/gcc/testsuite/gfortran.dg/gomp/ref_inquiry.f90 index 374610405601..610d9ec0b950 100644 --- a/gcc/testsuite/gfortran.dg/gomp/ref_inquiry.f90 +++ b/gcc/testsuite/gfortran.dg/gomp/ref_inquiry.f90 @@ -25,15 +25,11 @@ print *, is_contiguous(zz(:)%re) !$omp target enter data map(to: z%re) ! { dg-error "Unexpected complex-parts designator" } !$omp target enter data map(to: z%im) ! { dg-error "Unexpected complex-parts designator" } !$omp target enter data map(to: zz%re) ! { dg-error "not a proper array section" } - ! { dg-error "Array is not contiguous" "" { target *-*-* } .-1 } !$omp target enter data map(to: zz%im) ! { dg-error "not a proper array section" } - ! { dg-error "Array is not contiguous" "" { target *-*-* } .-1 } !$omp target enter data map(to: x%z%re) ! { dg-error "Unexpected complex-parts designator" } !$omp target enter data map(to: x%z%im) ! { dg-error "Unexpected complex-parts designator" } !$omp target enter data map(to: x%zz%re) ! { dg-error "not a proper array section" } - ! { dg-error "Array is not contiguous" "" { target *-*-* } .-1 } !$omp target enter data map(to: x%zz%im) ! { dg-error "not a proper array section" } - ! { dg-error "Array is not contiguous" "" { target *-*-* } .-1 } end diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp index 0f862d1b573a..d1dcf203f5f0 100644 --- a/libgomp/ChangeLog.omp +++ b/libgomp/ChangeLog.omp @@ -1,3 +1,10 @@ +2021-02-24 Julian Brown + + Backport from mainline + + * testsuite/libgomp.oacc-fortran/array-stride-dt-1.f90: Remove + expected errors. + 2021-02-24 Julian Brown Backport from mainline 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 61250708197d..f04d76d583ab 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(:,:) = 5 -! TODO: Remove expected errors once this is supported. -!$acc update device(b(::2)) ! { dg-error "Stride should not be specified 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=1,20 !$acc exit data copyout(b(i)%A)