From patchwork Sun Oct 6 22:32:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Brown X-Patchwork-Id: 1172585 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-510371-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="wc1mmn75"; 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 46mdgK6pJvz9sP7 for ; Mon, 7 Oct 2019 09:33:33 +1100 (AEDT) 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:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; q=dns; s= default; b=a+F/pYL7SjbTGlcIsnuh0F2BDiZ+v4aEHtmW+XHxJKmrGVcK5Y4q7 KYLo4nrgtA/ZlBdvp6+fggJ2FO06Zv4H7XWoOrHGUSDH79Y8+++umIcm3tOKQPAn +9ofPb7B8+xDVcmdi3ilBIGUXPWA00rK+l+XiDmoiyGq6gPHZkCOIw= 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:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s=default; bh=uY1hf/2VQ//VlOXls6fu5t83ODo=; b=wc1mmn75xNSxKCNkU7hWVY1DvRLl IiLkQUdesUi/+WnErCqzvAOCeLw2deb6z1ty3I4zEyyPlRnnCbYApjIQlc0nyIJQ JRq03a+Okids8oNo8zjUgHn08x4oQCfi1g+Rcx0BYXTOEpVPzZWvmMhtSTugI25M EtD88ouyAsY+BlM= Received: (qmail 20819 invoked by alias); 6 Oct 2019 22:33:01 -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 20734 invoked by uid 89); 6 Oct 2019 22:33:01 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.1 spammy=ifdef, device, HContent-Transfer-Encoding:8bit X-HELO: esa3.mentor.iphmx.com Received: from esa3.mentor.iphmx.com (HELO esa3.mentor.iphmx.com) (68.232.137.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 06 Oct 2019 22:32:59 +0000 IronPort-SDR: 3BFjqcZJkUkJ80WGTws+Iqdp5aDl8b2NnRAiJcnIjcO2N3IXSnCtd2UXdY97yEq64K5EkYkXZH 9rfIfQCLqUNqEdaEQGMqZMi/zAQ0TZiM8S4rz+DCARBWf5lFI5ocEEMxMSBxYmUl+02tVW6srN /0ta5dpkWdbgmdClOYwZVBKFDfPLj3pyG7raeV1l8EvENgcL9EQ/KQz/msxGfIq+qZaDVpV0/r iXdmrFXUxCoRmioVPfUSevAd5/ya+xgPbj2hrOaaNk2DbXW+DPn+av9AC4dBG0ZxZ8rTcB5bdX R4I= Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa3.mentor.iphmx.com with ESMTP; 06 Oct 2019 14:32:58 -0800 IronPort-SDR: CW8AGCWAz6aClO0Jluu3ujOy2a363QDXWMV6EYxXnTXDAR7hSxQANble4zfrRMQZK8wqILxWI7 XBzsqmhudrHM9FEkJfMgk0jhFLV4ogiClALsMWUjVOKX03bVQAMiTUNCqXXdIgqoe1wFMCDkGc 2cFeGDdxhfHCwPiFFJ+WELOITGwNy9y406SJtRO86iaTGCizmlzAmxrk/L9Nm2fCrj9IKG8gG+ Jcevj8fH7oZ3jEEnennMp3I53mFqxdzLupk+Aov/ZxEOEuu7vqJuGWJUWxst7dPH5jk4vfsvZq hjw= From: Julian Brown To: CC: , Subject: [PATCH 2/4] Use gomp_map_val for OpenACC host-to-device address translation Date: Sun, 6 Oct 2019 15:32:35 -0700 Message-ID: <20191006223237.81842-3-julian@codesourcery.com> In-Reply-To: <20191006223237.81842-1-julian@codesourcery.com> References: <20191006223237.81842-1-julian@codesourcery.com> MIME-Version: 1.0 X-IsSubscribed: yes This patch uses gomp_map_val for OpenACC host-to-device address translation instead of open-coding the device address calculation. OK for trunk? Thanks, Julian ChangeLog libgomp/ * libgomp.h (gomp_map_val): Add prototype. * oacc-parallel.c (GOACC_parallel_keyed): Use gomp_map_val instead of open-coding device-address calculation. * target.c (gomp_map_val): Make global. --- libgomp/libgomp.h | 1 + libgomp/oacc-parallel.c | 8 ++------ libgomp/target.c | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/libgomp/libgomp.h b/libgomp/libgomp.h index 19553a37c13..6870ee34224 100644 --- a/libgomp/libgomp.h +++ b/libgomp/libgomp.h @@ -1095,6 +1095,7 @@ extern void gomp_copy_host2dev (struct gomp_device_descr *, extern void gomp_copy_dev2host (struct gomp_device_descr *, struct goacc_asyncqueue *, void *, const void *, size_t); +extern uintptr_t gomp_map_val (struct target_mem_desc *, void **, size_t); #ifdef RC_CHECKING extern void dump_tgt (const char *, struct target_mem_desc *); diff --git a/libgomp/oacc-parallel.c b/libgomp/oacc-parallel.c index 18feac5f31c..02472c56270 100644 --- a/libgomp/oacc-parallel.c +++ b/libgomp/oacc-parallel.c @@ -350,12 +350,8 @@ GOACC_parallel_keyed (int flags_m, void (*fn) (void *), devaddrs = gomp_alloca (sizeof (void *) * mapnum); for (i = 0; i < mapnum; i++) - 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; + devaddrs[i] = (void *) gomp_map_val (tgt, hostaddrs, i); + if (aq == NULL) acc_dev->openacc.exec_func (tgt_fn, mapnum, hostaddrs, devaddrs, dims, tgt); diff --git a/libgomp/target.c b/libgomp/target.c index 29cb7ca8348..aa7a1df1e46 100644 --- a/libgomp/target.c +++ b/libgomp/target.c @@ -670,7 +670,7 @@ gomp_map_fields_existing (struct target_mem_desc *tgt, (void *) cur_node.host_end); } -static inline uintptr_t +uintptr_t gomp_map_val (struct target_mem_desc *tgt, void **hostaddrs, size_t i) { if (tgt->list[i].key != NULL)