From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1534) id D4CFB3858434; Wed, 15 Feb 2023 10:48:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D4CFB3858434 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1676458130; bh=D2dSiMKsHRwsgKfEx6xugDdUWt4/o2y+AQ6KExx4z2U=; h=From:To:Subject:Date:From; b=SKesqqNrIxuuJlOUqhYKZDI3eejciKJyPmvjryFu2ZTWYaj5LFvRGW+8HGkNACOFb uMq4zYbrB0D7sKmKWkgxa0EmhQQTuPO57useD4+/B+On5aUNrHaTtRxDMrxgSY7MqB 4XmYlC3qBSA9eyo2SC3up9blqnjqJafH77ahQqKY= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Tobias Burnus To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/omp/gcc-12] libgomp: Fix reverse-offload for GOMP_MAP_TO_PSET X-Act-Checkin: gcc X-Git-Author: Tobias Burnus X-Git-Refname: refs/heads/devel/omp/gcc-12 X-Git-Oldrev: ec6bf735cf752818b5fd5b53100552ee3d06f62e X-Git-Newrev: 32fa844bb90ed67f5ce6d79a41a88966c73b5256 Message-Id: <20230215104850.D4CFB3858434@sourceware.org> Date: Wed, 15 Feb 2023 10:48:50 +0000 (GMT) List-Id: https://gcc.gnu.org/g:32fa844bb90ed67f5ce6d79a41a88966c73b5256 commit 32fa844bb90ed67f5ce6d79a41a88966c73b5256 Author: Tobias Burnus Date: Wed Feb 15 11:42:00 2023 +0100 libgomp: Fix reverse-offload for GOMP_MAP_TO_PSET libgomp/ * target.c (gomp_target_rev): Dereference ptr to get device address. * testsuite/libgomp.fortran/reverse-offload-5.f90: Add test for unallocated allocatable. (cherry picked from commit edaf1d607860075c5ff4ade20c58b3f578ed5489) Diff: --- libgomp/ChangeLog.omp | 10 ++++++++++ libgomp/target.c | 8 +++++++- libgomp/testsuite/libgomp.fortran/reverse-offload-5.f90 | 6 ++++-- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp index 6216ea41b2e..b638cdbb41e 100644 --- a/libgomp/ChangeLog.omp +++ b/libgomp/ChangeLog.omp @@ -1,3 +1,13 @@ +2023-02-15 Tobias Burnus + + Backported from master: + 2023-02-15 Tobias Burnus + + * target.c (gomp_target_rev): Dereference ptr + to get device address. + * testsuite/libgomp.fortran/reverse-offload-5.f90: Add test + for unallocated allocatable. + 2023-02-15 Tobias Burnus Backported from master: diff --git a/libgomp/target.c b/libgomp/target.c index ea7a1c3c097..1b911c9bdb9 100644 --- a/libgomp/target.c +++ b/libgomp/target.c @@ -3829,8 +3829,14 @@ gomp_target_rev (uint64_t fn_ptr, uint64_t mapnum, uint64_t devaddrs_ptr, } int k; n2 = NULL; - cdata[i].present = true; + /* Dereference devaddrs[j] to get the device addr. */ + assert (devaddrs[j] - sizes[j] == cdata[i].devaddr); + devaddrs[j] = *(uint64_t *) (uintptr_t) (devaddrs[i] + + sizes[j]); + cdata[j].present = true; cdata[j].devaddr = devaddrs[j]; + if (devaddrs[j] == 0) + continue; k = gomp_map_cdata_lookup (cdata, devaddrs, kinds, sizes, j, devaddrs[j], devaddrs[j] + sizeof (void*), diff --git a/libgomp/testsuite/libgomp.fortran/reverse-offload-5.f90 b/libgomp/testsuite/libgomp.fortran/reverse-offload-5.f90 index ef7eb7bdd52..16810eb47de 100644 --- a/libgomp/testsuite/libgomp.fortran/reverse-offload-5.f90 +++ b/libgomp/testsuite/libgomp.fortran/reverse-offload-5.f90 @@ -24,7 +24,7 @@ s2 = 55 !$omp target map(to: A, A2, s1, s2) block - integer, allocatable :: ai(:), ai2(:), si1, si2 + integer, allocatable :: ai(:), ai2(:), ai3(:), si1, si2, si3 a = a * 2 a2 = a2 * 3 @@ -38,7 +38,7 @@ block !$omp target device (ancestor:1) & !$omp& map(to: A, s1, ai, si1) map(always, to: a2, s2) & - !$omp& map(tofrom: ai2, si2) + !$omp& map(tofrom: ai2, si2, ai3, si3) if (shared_mem) then if (any (a /= 2 * [1,2,3,4])) stop 1 if (s1 /= 4 * 532) stop 2 @@ -52,6 +52,7 @@ block if (any (ai2 /= [8,4,7,1])) stop 8 if (si1 /= 64) stop 9 if (si2 /= 765) stop 10 + if (allocated (ai3) .or. allocated(si3)) stop 26 a = a*3 a2 = a2*7 @@ -80,6 +81,7 @@ block endif if (any (ai2 /= 21 * [8,4,7,1])) stop 24 if (si2 /= 31 * 765) stop 25 + if (allocated (ai3) .or. allocated(si3)) stop 27 deallocate (ai, ai2, si1, si2) end block