From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa2.mentor.iphmx.com (esa2.mentor.iphmx.com [68.232.141.98]) by sourceware.org (Postfix) with ESMTPS id 5A0B1385B835 for ; Fri, 17 Apr 2020 15:57:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 5A0B1385B835 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Tobias_Burnus@mentor.com IronPort-SDR: 0pmqOe/bgajkvfmOnU6EW0NJj3h8UYLJBmzHXIRGs+lzc2fAOpGb0gqz3JryxiM+P2bHomuAUh a/xW27RVXGYPshwXgtzRtceKoZ40DnhPsjiHm2zimfLzj55SZ9Hbztqb51J3B++pm8dw/kjEEZ GVOPbSRgd0FvWDgCbczCzk1vro0ahu+iobTEeOiTI2PSI+2QWQG1IqTqTFH5rIeZByUNj8lKPp OVEVkojcAudZQqy2hPsEBMSqHknsKLEk5DlOlghQR1WtBmABbw1O/prwAW+V7pk00LU0cU8a6e YKA= X-IronPort-AV: E=Sophos;i="5.72,395,1580803200"; d="diff'?scan'208";a="47829910" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa2.mentor.iphmx.com with ESMTP; 17 Apr 2020 07:57:17 -0800 IronPort-SDR: X2M2LVCQxj2+OfFCxkFQj7e12gkwKlqOhKJQwnePBB7T1N7mhiAV22bt9L0Qm6MLz5NMgNN4j8 6OPXH6Rg2bhq8aSqtcZF8aERWRJRwYq9STxncGI0cST1NLtweqVMS5wfNayixlG+dTfiCugltY 6XSv9cmNfveSknTRd8pBQBD3rYfJ9oYYDcGbPFYFTSTFAfV6svALIvs5I/e4AI1V7wQdCpVWwM vMXAJqP//XnzOqCbP9AUTGaFOz5SL2WVnojDmeCZZjPnGkRGucj/Ph3/BAPSRGI3cSial5/3vI IL8= Subject: Re: [Patch][OpenMP] Fix 'omp exit data' for Fortran arrays (PR 94635) From: Tobias Burnus To: gcc-patches , Jakub Jelinek References: <1cef2b3b-f03f-888a-050e-e80176ad41d4@codesourcery.com> Message-ID: <509fa878-db1f-1bbd-4ce9-8a62c2605d56@codesourcery.com> Date: Fri, 17 Apr 2020 17:57:06 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <1cef2b3b-f03f-888a-050e-e80176ad41d4@codesourcery.com> Content-Type: multipart/mixed; boundary="------------C6BA29F3FDFB3FEF821D1D76" Content-Language: en-US X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-06.mgc.mentorg.com (139.181.222.6) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-Spam-Status: No, score=-24.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_NONE, 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: , X-List-Received-Date: Fri, 17 Apr 2020 15:57:19 -0000 --------------C6BA29F3FDFB3FEF821D1D76 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: quoted-printable Next try =E2=80=93 with the proper patch instead of a full test case. On 4/17/20 5:54 PM, Tobias Burnus wrote: > It turned out that doing > omp enter data map(alloc:FortranArray) > omp exit data map(delete:FortranArray) > left the array descriptor (fortranarray [as opposed to > fortranarray.data]) > on the device. (cf. -fdump-tree-omplower in the PR.) > > Mapping FortranArray again (e.g. "map(tofrom:FortranArray)") > then failed by returning garbage. > > This patch now removes the descriptor with 'data exit', > which was passed as MAP_TO_PSET clause to the middle end, > but got removed. Instead, the clause is now turned into MAP_DELETE. > > Build on x86-64-gnu-linux and tested without and with AMDGCN > as offloading device. OK for the trunk? > > Tobias > ----------------- Mentor Graphics (Deutschland) GmbH, Arnulfstra=C3=9Fe 201, 80634 M=C3=BCnch= en / Germany Registergericht M=C3=BCnchen HRB 106955, Gesch=C3=A4ftsf=C3=BChrer: Thomas = Heurung, Alexander Walter --------------C6BA29F3FDFB3FEF821D1D76 Content-Type: text/x-patch; charset="UTF-8"; name="exit_data.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="exit_data.diff" [OpenMP] Fix 'omp exit data' for Fortran arrays (PR 94635) PR middle-end/94635 * gimplify.c (gimplify_scan_omp_clauses): Turn MAP_TO_PSET to MAP_DELETE. PR middle-end/94635 * testsuite/libgomp.fortran/target-enter-data-2.F90: New. gcc/gimplify.c | 14 +++++--- .../libgomp.fortran/target-enter-data-2.F90 | 40 ++++++++++++++++++++++ 2 files changed, 49 insertions(+), 5 deletions(-) diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 8cdfae26510..6fd8196f01c 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -8785,11 +8785,15 @@ gimplify_scan_omp_clauses (tree *list_p, gimple_seq *pre_p, 'exit data' - and in particular for 'delete:' - having an 'alloc:' does not make sense. Likewise, for 'update' only transferring the data itself is needed as the rest has been handled in previous - directives. */ - if ((code == OMP_TARGET_EXIT_DATA || code == OMP_TARGET_UPDATE) - && (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_POINTER - || OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_TO_PSET)) - remove = true; + directives. However, for 'exit data', the array descriptor needs + to be delete; hence, we turn the MAP_TO_PSET into a MAP_DELETE. */ + if (code == OMP_TARGET_EXIT_DATA + && OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_TO_PSET) + OMP_CLAUSE_SET_MAP_KIND (c, GOMP_MAP_DELETE); + else if ((code == OMP_TARGET_EXIT_DATA || code == OMP_TARGET_UPDATE) + && (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_POINTER + || OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_TO_PSET)) + remove = true; if (remove) break; diff --git a/libgomp/testsuite/libgomp.fortran/target-enter-data-2.F90 b/libgomp/testsuite/libgomp.fortran/target-enter-data-2.F90 new file mode 100644 index 00000000000..320d8bf419f --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/target-enter-data-2.F90 @@ -0,0 +1,40 @@ +! { dg-additional-options "-DMEM_SHARED" { target offload_device_shared_as } } +! +! PR middle-end/94635 + implicit none + integer, parameter :: N = 20 + integer, allocatable, dimension(:) :: my1DPtr + integer, dimension(N) :: my1DArr + integer :: i + + allocate(my1DPtr(N)) + my1DPtr = 43 + + !$omp target enter data map(alloc: my1DPtr) + !$omp target + my1DPtr = [(i , i = 1, N)] + !$omp end target + + !$omp target map(from: my1DArr) + my1DArr = my1DPtr + !$omp end target + !$omp target exit data map(delete: my1DPtr) + + if (any (my1DArr /= [(i, i = 1, N)])) stop 1 +#if MEM_SHARED + if (any (my1DArr /= my1DPtr)) stop 2 +#else + if (any (43 /= my1DPtr)) stop 3 +#endif + + my1DPtr = [(2*N-i, i = 1, N)] + my1DArr = 42 + + !$omp target map(tofrom: my1DArr) map(tofrom: my1DPtr(:)) + my1DArr = my1DPtr + my1DPtr = 20 + !$omp end target + + if (any (my1DArr /= [(2*N-i, i = 1, N)])) stop 4 + if (any (20 /= my1DPtr)) stop 6 +end --------------C6BA29F3FDFB3FEF821D1D76--