From patchwork Mon Apr 3 14:39:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 1764473 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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+incoming=patchwork.ozlabs.org@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 ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Pqtpb2Nhfz1yZT for ; Tue, 4 Apr 2023 00:40:05 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2C8013858C39 for ; Mon, 3 Apr 2023 14:40:02 +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 27E603858D37 for ; Mon, 3 Apr 2023 14:39:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 27E603858D37 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="5.98,314,1673942400"; d="scan'208,223";a="1258165" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa4.mentor.iphmx.com with ESMTP; 03 Apr 2023 06:39:45 -0800 IronPort-SDR: CU3uBsdPnmFXzYQG6+rbTnb4CgngIGH2ENVzA8ifGrktW14J+4W6gjpQivBtFGJVcqs8RKGLFr cwqk1aTwcXYsWw0yTiu5TL67SQwa2AyJjF5tn+IG9oNDjMJHCsL7BbH5mKVgf1hHmdgdkODWJD VxFZF60mIE3v67NNCUc3ppSVbAP+EKZRfB8HHON45lQWY94+eXAO7t3rvuQaZb5aBoiAgXtmdT U+7XNi8GaADr2VmHwIQV0/iHQ2WAUuPDduq+lWs7esm/DvGCAniRYj5wzmnMvgzEgV9e6DMHBl PRU= From: Thomas Schwinge To: Chung-Lin Tang , Subject: [og12] OpenACC: Pass pre-allocated 'ptrblock' to 'goacc_noncontig_array_create_ptrblock' [PR76739] (was: [PATCH, OpenACC, v3] Non-contiguous array support for OpenACC data clauses) In-Reply-To: <6b17767f-9b7d-50a7-c52f-e80bf1be991e@mentor.com> References: <6b17767f-9b7d-50a7-c52f-e80bf1be991e@mentor.com> User-Agent: Notmuch/0.29.3+94~g74c3f1b (https://notmuchmail.org) Emacs/28.2 (x86_64-pc-linux-gnu) Date: Mon, 3 Apr 2023 16:39:36 +0200 Message-ID: <87cz4lxc5z.fsf@euler.schwinge.homeip.net> MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) To svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) X-Spam-Status: No, score=-11.9 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.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Hi! On 2019-11-26T22:49:21+0800, Chung-Lin Tang wrote: > this is a reorg of the last non-contiguous arrays patch. (Sorry, this is still not the master branch integration email...) Just a small clean-up, to simplify other changes that I'm working on: On 2019-11-26T22:49:21+0800, Chung-Lin Tang wrote: > --- libgomp/oacc-parallel.c (revision 278656) > +++ libgomp/oacc-parallel.c (working copy) > +void * > +goacc_noncontig_array_create_ptrblock (struct goacc_ncarray *nca, > + void *tgt_ptrblock_addr) > +{ > + [...] > + void *ptrblock = gomp_malloc (nca->ptrblock_size); > --- libgomp/target.c (revision 278656) > +++ libgomp/target.c (working copy) > @@ -1044,6 +1114,98 @@ gomp_map_vars_internal (struct gomp_device_descr * > + /* Now we have the target memory allocated, and target offsets of all > + row blocks assigned and calculated, we can construct the > + accelerator side ptrblock and copy it in. */ > + if (nca->ptrblock_size) > + { > + void *ptrblock = goacc_noncontig_array_create_ptrblock > + (nca, target_ptrblock); > + gomp_copy_host2dev (devicep, aq, target_ptrblock, ptrblock, > + nca->ptrblock_size, cbufp); > + free (ptrblock); > + } Pushed to devel/omp/gcc-12 branch commit c58b28cb650995a41e1ab0166169799f3991bdd6 "OpenACC: Pass pre-allocated 'ptrblock' to 'goacc_noncontig_array_create_ptrblock' [PR76739]", see attached. Grüße Thomas ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955 From c58b28cb650995a41e1ab0166169799f3991bdd6 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Wed, 15 Mar 2023 14:32:12 +0100 Subject: [PATCH] OpenACC: Pass pre-allocated 'ptrblock' to 'goacc_noncontig_array_create_ptrblock' [PR76739] ... to simplify later changes. No functional change. Follow-up for og12 commit 15d0f61a7fecdc8fd12857c40879ea3730f6d99f "Merge non-contiguous array support patches". PR other/76739 libgomp/ * target.c (gomp_map_vars_internal): Pass pre-allocated 'ptrblock' to 'goacc_noncontig_array_create_ptrblock'. * oacc-parallel.c (goacc_noncontig_array_create_ptrblock): Adjust. * oacc-int.h (goacc_noncontig_array_create_ptrblock): Adjust. --- libgomp/ChangeLog.omp | 6 ++++++ libgomp/oacc-int.h | 3 ++- libgomp/oacc-parallel.c | 5 ++--- libgomp/target.c | 5 +++-- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp index d8a7e476090..7afb5f43c04 100644 --- a/libgomp/ChangeLog.omp +++ b/libgomp/ChangeLog.omp @@ -1,5 +1,11 @@ 2023-04-03 Thomas Schwinge + PR other/76739 + * target.c (gomp_map_vars_internal): Pass pre-allocated 'ptrblock' + to 'goacc_noncontig_array_create_ptrblock'. + * oacc-parallel.c (goacc_noncontig_array_create_ptrblock): Adjust. + * oacc-int.h (goacc_noncontig_array_create_ptrblock): Adjust. + * libgomp.texi (AMD Radeon, nvptx): Document OpenMP 'pinned' memory. diff --git a/libgomp/oacc-int.h b/libgomp/oacc-int.h index d86aeb82dfa..28a6118873a 100644 --- a/libgomp/oacc-int.h +++ b/libgomp/oacc-int.h @@ -213,7 +213,8 @@ struct goacc_ncarray_info struct goacc_ncarray ncarray[]; }; -extern void *goacc_noncontig_array_create_ptrblock (struct goacc_ncarray *, void *); +extern void goacc_noncontig_array_create_ptrblock (struct goacc_ncarray *, + void *, void *); #ifdef HAVE_ATTRIBUTE_VISIBILITY diff --git a/libgomp/oacc-parallel.c b/libgomp/oacc-parallel.c index 136702d6e61..8d1c2cce836 100644 --- a/libgomp/oacc-parallel.c +++ b/libgomp/oacc-parallel.c @@ -165,13 +165,13 @@ goacc_process_noncontiguous_arrays (size_t mapnum, void **hostaddrs, return nca_info; } -void * +void goacc_noncontig_array_create_ptrblock (struct goacc_ncarray *nca, + void *ptrblock, void *tgt_ptrblock_addr) { struct goacc_ncarray_descr_type *descr = nca->descr; void **tgt_data_rows = nca->tgt_data_rows; - void *ptrblock = gomp_malloc (nca->ptrblock_size); void **curr_dim_ptrblock = (void **) ptrblock; size_t n = 1; @@ -210,7 +210,6 @@ goacc_noncontig_array_create_ptrblock (struct goacc_ncarray *nca, curr_dim_ptrblock = next_dim_ptrblock; } assert (n == nca->data_row_num); - return ptrblock; } /* Handle the mapping pair that are presented when a diff --git a/libgomp/target.c b/libgomp/target.c index de3facb6428..b88b1ebaa13 100644 --- a/libgomp/target.c +++ b/libgomp/target.c @@ -1939,8 +1939,9 @@ gomp_map_vars_internal (struct gomp_device_descr *devicep, accelerator side ptrblock and copy it in. */ if (nca->ptrblock_size) { - void *ptrblock = goacc_noncontig_array_create_ptrblock - (nca, target_ptrblock); + void *ptrblock = gomp_malloc (nca->ptrblock_size); + goacc_noncontig_array_create_ptrblock + (nca, ptrblock, target_ptrblock); gomp_copy_host2dev (devicep, aq, target_ptrblock, ptrblock, nca->ptrblock_size, false, cbufp); if (aq) -- 2.25.1