From patchwork Tue Jun 18 22:37:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 1118373 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-503223-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="IAZSnp3X"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45T2z75VGzz9s3l for ; Wed, 19 Jun 2019 08:37:55 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:in-reply-to:references:date:message-id:mime-version :content-type; q=dns; s=default; b=LAetsOf7PTVY7cQ4FcOZHFZyz/E6J KedSapgB9u2Zr6ij36PtMup4x3LT8YEClEffiYdCB5kHKPozm8iTeLKuTOglIGS5 U7gazjDS5Q8RcTgxRusmO0y+Mxc3+0eDVZp863JYU7cozeOFAq+tn7vWYO4odeqa 24O52GvHv0cCLg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:in-reply-to:references:date:message-id:mime-version :content-type; s=default; bh=Skxl4ifn+1+7pKMevc8XujH36Qg=; b=IAZ Snp3X204XPCVnMvyMbSAFGuQDM8zo9u0boaAxHmf3ZBQoS1TmnEamL2B5R5g7mFm q2EVzXNRT94mRh/ICYBvsiujlIkTiw6UnnryN1PWoJv68jCcfAwaBaZGn9uKsdgh TynJMVSrC6k5B61pUHWXukvdy0USPaXm+v8oMMxk= Received: (qmail 1296 invoked by alias); 18 Jun 2019 22:37:47 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 1280 invoked by uid 89); 18 Jun 2019 22:37:46 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-16.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=No, !$acc, r272447 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 18 Jun 2019 22:37:44 +0000 Received: from svr-orw-mbx-06.mgc.mentorg.com ([147.34.90.206]) by relay1.mentorg.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256) id 1hdMjV-0003UR-2F from Thomas_Schwinge@mentor.com ; Tue, 18 Jun 2019 15:37:41 -0700 Received: from svr-orw-mbx-03.mgc.mentorg.com (147.34.90.203) by SVR-ORW-MBX-06.mgc.mentorg.com (147.34.90.206) with Microsoft SMTP Server (TLS) id 15.0.1320.4; Tue, 18 Jun 2019 15:37:38 -0700 Received: from tftp-cs (147.34.91.1) by svr-orw-mbx-03.mgc.mentorg.com (147.34.90.203) with Microsoft SMTP Server id 15.0.1320.4 via Frontend Transport; Tue, 18 Jun 2019 15:37:38 -0700 Received: by tftp-cs (Postfix, from userid 49978) id 283D9C2212; Tue, 18 Jun 2019 15:37:38 -0700 (PDT) From: Thomas Schwinge To: Jakub Jelinek , , Subject: [committed] [PR90743] Fortran 'allocatable' with OpenACC data/OpenMP 'target' 'map' clauses In-Reply-To: <20190605103212.GD19695@tucnak> References: <87y32ggz9o.fsf@euler.schwinge.homeip.net> <20190605100025.GC19695@tucnak> <87lfygfhuv.fsf@euler.schwinge.homeip.net> <20190605103212.GD19695@tucnak> User-Agent: Notmuch/0.9-125-g4686d11 (http://notmuchmail.org) Emacs/26.1 (x86_64-pc-linux-gnu) Date: Wed, 19 Jun 2019 00:37:29 +0200 Message-ID: <87wohifrkm.fsf@euler.schwinge.homeip.net> MIME-Version: 1.0 Hi! On Wed, 5 Jun 2019 12:32:12 +0200, Jakub Jelinek wrote: > On Wed, Jun 05, 2019 at 12:26:32PM +0200, Thomas Schwinge wrote: > > On Wed, 5 Jun 2019 12:00:25 +0200, Jakub Jelinek wrote: > > > On Wed, Jun 05, 2019 at 11:25:07AM +0200, Thomas Schwinge wrote: > > > > + !$omp target map(to: a) map(tofrom: b, c, d) map(from: e) > > > > + !$acc parallel copyin(a) copy(b, c, d) copyout(e) > > > > > > Is mixing OpenMP and OpenACC construct this way defined at all? > > > > It's not. I'm using this just to avoid duplicating the test case file, > > that is, '-fopenacc' and '-fopenmp' aren't enabled at the same time. > > I think it is better to duplicate the test, it avoids confusion. I committed to trunk in r272447 "[PR90743] Fortran 'allocatable' with OpenACC data/OpenMP 'target' 'map' clauses", see attached. That however doesn't resolve this topic: more test cases are needed, and code changes, too, to support other clauses. Grüße Thomas From 561ffc69c504b2c897fc2991cf0bb99defa80efb Mon Sep 17 00:00:00 2001 From: tschwinge Date: Tue, 18 Jun 2019 22:14:24 +0000 Subject: [PATCH] [PR90743] Fortran 'allocatable' with OpenACC data/OpenMP 'target' 'map' clauses Test what OpenMP 5.0 has to say on this topic. And, do the same for OpenACC. libgomp/ PR fortran/90743 * oacc-parallel.c (GOACC_parallel_keyed): Handle NULL mapping case. * testsuite/libgomp.fortran/target-allocatable-1-1.f90: New file. * testsuite/libgomp.fortran/target-allocatable-1-2.f90: Likewise. * testsuite/libgomp.oacc-fortran/allocatable-1-1.f90: Likewise. * testsuite/libgomp.oacc-fortran/allocatable-1-2.f90: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@272447 138bc75d-0d04-0410-961f-82ee72b054a4 --- libgomp/ChangeLog | 8 ++ libgomp/oacc-parallel.c | 9 +- .../target-allocatable-1-1.f90 | 69 ++++++++++++++++ .../target-allocatable-1-2.f90 | 82 +++++++++++++++++++ .../libgomp.oacc-fortran/allocatable-1-1.f90 | 68 +++++++++++++++ .../libgomp.oacc-fortran/allocatable-1-2.f90 | 81 ++++++++++++++++++ 6 files changed, 314 insertions(+), 3 deletions(-) create mode 100644 libgomp/testsuite/libgomp.fortran/target-allocatable-1-1.f90 create mode 100644 libgomp/testsuite/libgomp.fortran/target-allocatable-1-2.f90 create mode 100644 libgomp/testsuite/libgomp.oacc-fortran/allocatable-1-1.f90 create mode 100644 libgomp/testsuite/libgomp.oacc-fortran/allocatable-1-2.f90 diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index 1a0d363e4ba2..62c45828a009 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,5 +1,13 @@ 2019-06-18 Thomas Schwinge + PR fortran/90743 + * oacc-parallel.c (GOACC_parallel_keyed): Handle NULL mapping + case. + * testsuite/libgomp.fortran/target-allocatable-1-1.f90: New file. + * testsuite/libgomp.fortran/target-allocatable-1-2.f90: Likewise. + * testsuite/libgomp.oacc-fortran/allocatable-1-1.f90: Likewise. + * testsuite/libgomp.oacc-fortran/allocatable-1-2.f90: Likewise. + PR testsuite/90861 * testsuite/libgomp.oacc-c-c++-common/declare-vla.c: Update. diff --git a/libgomp/oacc-parallel.c b/libgomp/oacc-parallel.c index e56330f6226b..0c2cfa05a438 100644 --- a/libgomp/oacc-parallel.c +++ b/libgomp/oacc-parallel.c @@ -325,9 +325,12 @@ GOACC_parallel_keyed (int flags_m, void (*fn) (void *), devaddrs = gomp_alloca (sizeof (void *) * mapnum); for (i = 0; i < mapnum; i++) - devaddrs[i] = (void *) (tgt->list[i].key->tgt->tgt_start - + tgt->list[i].key->tgt_offset - + tgt->list[i].offset); + if (tgt->list[i].key != NULL) + devaddrs[i] = (void *) (tgt->list[i].key->tgt->tgt_start + + tgt->list[i].key->tgt_offset + + tgt->list[i].offset); + else + devaddrs[i] = NULL; if (aq == NULL) acc_dev->openacc.exec_func (tgt_fn, mapnum, hostaddrs, devaddrs, dims, tgt); diff --git a/libgomp/testsuite/libgomp.fortran/target-allocatable-1-1.f90 b/libgomp/testsuite/libgomp.fortran/target-allocatable-1-1.f90 new file mode 100644 index 000000000000..429a855a20b2 --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/target-allocatable-1-1.f90 @@ -0,0 +1,69 @@ +! Test 'allocatable' with OpenMP 'target' 'map' clauses. + +! See also '../libgomp.oacc-fortran/allocatable-1-1.f90'. + +! { dg-do run } +! { dg-additional-options "-cpp" } +! { dg-additional-options "-DMEM_SHARED" { target offload_device_shared_as } } + +program main + implicit none + integer, allocatable :: a, b, c, d, e + + allocate (a) + a = 11 + + b = 25 ! Implicit allocation. + + c = 52 ! Implicit allocation. + + !No 'allocate (d)' here. + + !No 'allocate (e)' here. + + !$omp target map(to: a) map(tofrom: b, c, d) map(from: e) + + if (.not. allocated (a)) stop 1 + if (a .ne. 11) stop 2 + a = 33 + + if (.not. allocated (b)) stop 3 + if (b .ne. 25) stop 4 + + if (.not. allocated (c)) stop 5 + if (c .ne. 52) stop 6 + c = 10 + + if (allocated (d)) stop 7 + d = 42 ! Implicit allocation, but on device only. + if (.not. allocated (d)) stop 8 + deallocate (d) ! OpenMP requires must be "unallocated upon exit from the region". + + if (allocated (e)) stop 9 + e = 24 ! Implicit allocation, but on device only. + if (.not. allocated (e)) stop 10 + deallocate (e) ! OpenMP requires must be "unallocated upon exit from the region". + + !$omp end target + + if (.not. allocated (a)) stop 20 +#ifdef MEM_SHARED + if (a .ne. 33) stop 21 +#else + if (a .ne. 11) stop 22 +#endif + deallocate (a) + + if (.not. allocated (b)) stop 23 + if (b .ne. 25) stop 24 + deallocate (b) + + if (.not. allocated (c)) stop 25 + if (c .ne. 10) stop 26 + deallocate (c) + + if (allocated (d)) stop 27 + + if (allocated (e)) stop 28 + +end program main diff --git a/libgomp/testsuite/libgomp.fortran/target-allocatable-1-2.f90 b/libgomp/testsuite/libgomp.fortran/target-allocatable-1-2.f90 new file mode 100644 index 000000000000..5301c8eeffbd --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/target-allocatable-1-2.f90 @@ -0,0 +1,82 @@ +! Test 'allocatable' with OpenMP 'target' 'map' clauses, subroutine in module, +! pass by reference. + +! See also '../libgomp.oacc-fortran/allocatable-1-2.f90'. + +! { dg-do run } +! { dg-additional-options "-cpp" } +! { dg-additional-options "-DMEM_SHARED" { target offload_device_shared_as } } + +module m +contains + subroutine r (a, b, c, d, e) + implicit none + integer, allocatable :: a, b, c, d, e + + !$omp target map(to: a) map(tofrom: b, c, d) map(from: e) + + if (.not. allocated (a)) stop 1 + if (a .ne. 11) stop 2 + a = 33 + + if (.not. allocated (b)) stop 3 + if (b .ne. 25) stop 4 + + if (.not. allocated (c)) stop 5 + if (c .ne. 52) stop 6 + c = 10 + + if (allocated (d)) stop 7 + d = 42 ! Implicit allocation, but on device only. + if (.not. allocated (d)) stop 8 + deallocate (d) ! OpenMP requires must be "unallocated upon exit from the region". + + if (allocated (e)) stop 9 + e = 24 ! Implicit allocation, but on device only. + if (.not. allocated (e)) stop 10 + deallocate (e) ! OpenMP requires must be "unallocated upon exit from the region". + + !$omp end target + + end subroutine r +end module m + +program main + use m + implicit none + integer, allocatable :: a, b, c, d, e + + allocate (a) + a = 11 + + b = 25 ! Implicit allocation. + + c = 52 ! Implicit allocation. + + !No 'allocate (d)' here. + + !No 'allocate (e)' here. + + call r(a, b, c, d, e) + + if (.not. allocated (a)) stop 20 +#ifdef MEM_SHARED + if (a .ne. 33) stop 21 +#else + if (a .ne. 11) stop 22 +#endif + deallocate (a) + + if (.not. allocated (b)) stop 23 + if (b .ne. 25) stop 24 + deallocate (b) + + if (.not. allocated (c)) stop 25 + if (c .ne. 10) stop 26 + deallocate (c) + + if (allocated (d)) stop 27 + + if (allocated (e)) stop 28 + +end program main diff --git a/libgomp/testsuite/libgomp.oacc-fortran/allocatable-1-1.f90 b/libgomp/testsuite/libgomp.oacc-fortran/allocatable-1-1.f90 new file mode 100644 index 000000000000..e5981312f148 --- /dev/null +++ b/libgomp/testsuite/libgomp.oacc-fortran/allocatable-1-1.f90 @@ -0,0 +1,68 @@ +! Test 'allocatable' with OpenACC data clauses. + +! See also '../libgomp.fortran/target-allocatable-1-1.f90'. + +! { dg-do run } +! { dg-additional-options "-cpp" } + +program main + implicit none + integer, allocatable :: a, b, c, d, e + + allocate (a) + a = 11 + + b = 25 ! Implicit allocation. + + c = 52 ! Implicit allocation. + + !No 'allocate (d)' here. + + !No 'allocate (e)' here. + + !$acc parallel copyin(a) copy(b, c, d) copyout(e) + + if (.not. allocated (a)) stop 1 + if (a .ne. 11) stop 2 + a = 33 + + if (.not. allocated (b)) stop 3 + if (b .ne. 25) stop 4 + + if (.not. allocated (c)) stop 5 + if (c .ne. 52) stop 6 + c = 10 + + if (allocated (d)) stop 7 + d = 42 ! Implicit allocation, but on device only. + if (.not. allocated (d)) stop 8 + deallocate (d) ! OpenMP requires must be "unallocated upon exit from the region". + + if (allocated (e)) stop 9 + e = 24 ! Implicit allocation, but on device only. + if (.not. allocated (e)) stop 10 + deallocate (e) ! OpenMP requires must be "unallocated upon exit from the region". + + !$acc end parallel + + if (.not. allocated (a)) stop 20 +#if ACC_MEM_SHARED + if (a .ne. 33) stop 21 +#else + if (a .ne. 11) stop 22 +#endif + deallocate (a) + + if (.not. allocated (b)) stop 23 + if (b .ne. 25) stop 24 + deallocate (b) + + if (.not. allocated (c)) stop 25 + if (c .ne. 10) stop 26 + deallocate (c) + + if (allocated (d)) stop 27 + + if (allocated (e)) stop 28 + +end program main diff --git a/libgomp/testsuite/libgomp.oacc-fortran/allocatable-1-2.f90 b/libgomp/testsuite/libgomp.oacc-fortran/allocatable-1-2.f90 new file mode 100644 index 000000000000..2faf0f8078f0 --- /dev/null +++ b/libgomp/testsuite/libgomp.oacc-fortran/allocatable-1-2.f90 @@ -0,0 +1,81 @@ +! Test 'allocatable' with OpenACC data clauses, subroutine in module, pass by +! reference. + +! See also '../libgomp.fortran/target-allocatable-1-2.f90'. + +! { dg-do run } +! { dg-additional-options "-cpp" } + +module m +contains + subroutine r (a, b, c, d, e) + implicit none + integer, allocatable :: a, b, c, d, e + + !$acc parallel copyin(a) copy(b, c, d) copyout(e) + + if (.not. allocated (a)) stop 1 + if (a .ne. 11) stop 2 + a = 33 + + if (.not. allocated (b)) stop 3 + if (b .ne. 25) stop 4 + + if (.not. allocated (c)) stop 5 + if (c .ne. 52) stop 6 + c = 10 + + if (allocated (d)) stop 7 + d = 42 ! Implicit allocation, but on device only. + if (.not. allocated (d)) stop 8 + deallocate (d) ! OpenMP requires must be "unallocated upon exit from the region". + + if (allocated (e)) stop 9 + e = 24 ! Implicit allocation, but on device only. + if (.not. allocated (e)) stop 10 + deallocate (e) ! OpenMP requires must be "unallocated upon exit from the region". + + !$acc end parallel + + end subroutine r +end module m + +program main + use m + implicit none + integer, allocatable :: a, b, c, d, e + + allocate (a) + a = 11 + + b = 25 ! Implicit allocation. + + c = 52 ! Implicit allocation. + + !No 'allocate (d)' here. + + !No 'allocate (e)' here. + + call r(a, b, c, d, e) + + if (.not. allocated (a)) stop 20 +#if ACC_MEM_SHARED + if (a .ne. 33) stop 21 +#else + if (a .ne. 11) stop 22 +#endif + deallocate (a) + + if (.not. allocated (b)) stop 23 + if (b .ne. 25) stop 24 + deallocate (b) + + if (.not. allocated (c)) stop 25 + if (c .ne. 10) stop 26 + deallocate (c) + + if (allocated (d)) stop 27 + + if (allocated (e)) stop 28 + +end program main -- 2.20.1