From patchwork Wed Dec 11 17:08:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 1207776 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-515709-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="CMY4k3+w"; 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 47Y3L11KDtz9sSL for ; Thu, 12 Dec 2019 04:08:40 +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:mime-version:content-type; q=dns; s=default; b=fVX4oO0zPGP/x0GUjifcfXPlhtbqp9N4g5YBTAV7drXqtzgG+u WE+JCzdRN8Z3WIy1+D1nP96FoQAbT01eLzefOx+HVLfUiANaRqGe8EYqP6whu1e/ 77ghbRI+yHyKbXqCJkO7buje7n9pFXhfqMvr19yy3Gq6ro9GihIZRVSb0= 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:mime-version:content-type; s= default; bh=BZHQPO3Q8Ad1ARgVAlgD+EnQhh0=; b=CMY4k3+wA2z/aYAqN7EI NnAXh5XOP2/m/VM4Kfgdp77aPztS05ixWeJbhg4KDxFYTgbUPfhro46zpJJfSkSj Kk+BdPxS3VPrej8dt+e3hstdQufdbaZzT+YvdbOx5JhkkCumBY5Q01xanBr+x30X IuXji7xCk2VjNbpZ6bll60U= Received: (qmail 49469 invoked by alias); 11 Dec 2019 17:08:32 -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 49460 invoked by uid 89); 11 Dec 2019 17:08:31 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.0 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=qid, launching X-HELO: esa4.mentor.iphmx.com Received: from esa4.mentor.iphmx.com (HELO esa4.mentor.iphmx.com) (68.232.137.252) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 11 Dec 2019 17:08:29 +0000 IronPort-SDR: /G/Pw5atjcd9JquuawtcV48M+r9+9UKQfFVp6U67lQ5FND6ie9U1iExFgmHZlsBlkEHo7H5BCg 2no8unCIfdRUpAzTeSWVRofCOlp40H5c6NGfz4fsJCWlkcvnCI7dzAF6VRoUjllz1Ypg0pqq/A hDG4x7AeFo0kzs6bduZEh3BdU2MR5Cucagz0i0Nj5X6DOaZ40GEYq1f7iEAaMHXcwa/kQcsM43 u5xuUrm5dVvLHiHwtZB3TcVFQpf62EV2vF/0ASYOe8WgEzZrRWO56QrOJTd+vE48FvlrhQkqi5 wFM= Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa4.mentor.iphmx.com with ESMTP; 11 Dec 2019 09:08:28 -0800 IronPort-SDR: yLFiLS82l0cBnIuP2cDL/aysNK4w5KZFff2VFm1Qq146vtklRWUpdoont8X/elq3mKwWf81oFk b4qt5NjuGVT5c6igiFZvtvGWeNJxONeFXreThunJP/JiaMUy2hKR7ek9B6aH7MrwLGyRbcH1rB rsXNVDMNMxRIhw4XhtTKz73uHNrS7OJe+/MWllsBv4Hqil8f8sSG0mKHY0OORkUgxmpt2+qHeZ fU+nYw7HophqDPCxTCe0nNDSyrSBWBjeLtMNEJGyjdW/ZHGuXJHblq6009ZXgk8mJm6jn0vlx6 Hv0= From: Thomas Schwinge To: CC: Julian Brown , Chung-Lin Tang Subject: [OpenACC] Consolidate 'async'/'wait' code in 'libgomp/oacc-async.c' User-Agent: Notmuch/0.29.1+93~g67ed7df (https://notmuchmail.org) Emacs/26.1 (x86_64-pc-linux-gnu) Date: Wed, 11 Dec 2019 18:08:17 +0100 Message-ID: <87eexa23jy.fsf@euler.schwinge.homeip.net> MIME-Version: 1.0 Hi! As a preparational patch/general refactoring, see attached "[OpenACC] Consolidate 'async'/'wait' code in 'libgomp/oacc-async.c'"; committed to trunk in r279232. Grüße Thomas From 2b04bb7b4c9a13b6eadc7d9723245dd58f0f4f04 Mon Sep 17 00:00:00 2001 From: tschwinge Date: Wed, 11 Dec 2019 16:49:08 +0000 Subject: [PATCH] [OpenACC] Consolidate 'async'/'wait' code in 'libgomp/oacc-async.c' libgomp/ * oacc-parallel.c (GOACC_wait, goacc_wait): Move... * oacc-async.c: ... here. * oacc-int.h (goacc_wait): Declare. * libgomp_g.h: Update git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@279232 138bc75d-0d04-0410-961f-82ee72b054a4 --- libgomp/ChangeLog | 5 +++ libgomp/libgomp_g.h | 5 ++- libgomp/oacc-async.c | 71 ++++++++++++++++++++++++++++++++++++++++ libgomp/oacc-int.h | 1 + libgomp/oacc-parallel.c | 72 ----------------------------------------- 5 files changed, 81 insertions(+), 73 deletions(-) diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index 404722e20e3..f7d9ae98616 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,5 +1,10 @@ 2019-12-11 Thomas Schwinge + * oacc-parallel.c (GOACC_wait, goacc_wait): Move... + * oacc-async.c: ... here. + * oacc-int.h (goacc_wait): Declare. + * libgomp_g.h: Update + PR libgomp/92854 * testsuite/libgomp.oacc-c-c++-common/acc_map_data-device_already-1.c: New file. diff --git a/libgomp/libgomp_g.h b/libgomp/libgomp_g.h index dfb55fb66dc..beb1689180d 100644 --- a/libgomp/libgomp_g.h +++ b/libgomp/libgomp_g.h @@ -357,6 +357,10 @@ extern void GOMP_teams (unsigned int, unsigned int); extern void GOMP_teams_reg (void (*) (void *), void *, unsigned, unsigned, unsigned); +/* oacc-async.c */ + +extern void GOACC_wait (int, int, ...); + /* oacc-parallel.c */ extern void GOACC_parallel_keyed (int, void (*) (void *), size_t, @@ -370,7 +374,6 @@ extern void GOACC_enter_exit_data (int, size_t, void **, size_t *, unsigned short *, int, int, ...); extern void GOACC_update (int, size_t, void **, size_t *, unsigned short *, int, int, ...); -extern void GOACC_wait (int, int, ...); extern int GOACC_get_num_threads (void); extern int GOACC_get_thread_num (void); extern void GOACC_declare (int, size_t, void **, size_t *, unsigned short *); diff --git a/libgomp/oacc-async.c b/libgomp/oacc-async.c index 2b24ae7adc2..6dfc3bdeb8e 100644 --- a/libgomp/oacc-async.c +++ b/libgomp/oacc-async.c @@ -354,6 +354,77 @@ acc_wait_all_async (int async) gomp_fatal ("wait all async(%d) failed", async); } +void +GOACC_wait (int async, int num_waits, ...) +{ + goacc_lazy_initialize (); + + struct goacc_thread *thr = goacc_thread (); + + /* No nesting. */ + assert (thr->prof_info == NULL); + assert (thr->api_info == NULL); + acc_prof_info prof_info; + acc_api_info api_info; + bool profiling_p = GOACC_PROFILING_SETUP_P (thr, &prof_info, &api_info); + if (profiling_p) + { + prof_info.async = async; + prof_info.async_queue = prof_info.async; + } + + if (num_waits) + { + va_list ap; + + va_start (ap, num_waits); + goacc_wait (async, num_waits, &ap); + va_end (ap); + } + else if (async == acc_async_sync) + acc_wait_all (); + else + acc_wait_all_async (async); + + if (profiling_p) + { + thr->prof_info = NULL; + thr->api_info = NULL; + } +} + +attribute_hidden void +goacc_wait (int async, int num_waits, va_list *ap) +{ + while (num_waits--) + { + int qid = va_arg (*ap, int); + + /* Waiting on ACC_ASYNC_NOVAL maps to 'wait all'. */ + if (qid == acc_async_noval) + { + if (async == acc_async_sync) + acc_wait_all (); + else + acc_wait_all_async (async); + break; + } + + if (acc_async_test (qid)) + continue; + + if (async == acc_async_sync) + acc_wait (qid); + else if (qid == async) + /* If we're waiting on the same asynchronous queue as we're + launching on, the queue itself will order work as + required, so there's no need to wait explicitly. */ + ; + else + acc_wait_async (qid, async); + } +} + attribute_hidden void goacc_async_free (struct gomp_device_descr *devicep, struct goacc_asyncqueue *aq, void *ptr) diff --git a/libgomp/oacc-int.h b/libgomp/oacc-int.h index 9dc6c8a5713..81cb15c605f 100644 --- a/libgomp/oacc-int.h +++ b/libgomp/oacc-int.h @@ -113,6 +113,7 @@ void goacc_restore_bind (void); void goacc_lazy_initialize (void); void goacc_host_init (void); +void goacc_wait (int, int, va_list *); void goacc_init_asyncqueues (struct gomp_device_descr *); bool goacc_fini_asyncqueues (struct gomp_device_descr *); void goacc_async_free (struct gomp_device_descr *, struct goacc_asyncqueue *, diff --git a/libgomp/oacc-parallel.c b/libgomp/oacc-parallel.c index 68a60de24fa..1faca5d562f 100644 --- a/libgomp/oacc-parallel.c +++ b/libgomp/oacc-parallel.c @@ -111,8 +111,6 @@ handle_ftn_pointers (size_t mapnum, void **hostaddrs, size_t *sizes, } } -static void goacc_wait (int async, int num_waits, va_list *ap); - /* Launch a possibly offloaded function with FLAGS. FN is the host fn address. MAPNUM, HOSTADDRS, SIZES & KINDS describe the memory @@ -814,38 +812,6 @@ GOACC_enter_exit_data (int flags_m, size_t mapnum, } } -static void -goacc_wait (int async, int num_waits, va_list *ap) -{ - while (num_waits--) - { - int qid = va_arg (*ap, int); - - /* Waiting on ACC_ASYNC_NOVAL maps to 'wait all'. */ - if (qid == acc_async_noval) - { - if (async == acc_async_sync) - acc_wait_all (); - else - acc_wait_all_async (async); - break; - } - - if (acc_async_test (qid)) - continue; - - if (async == acc_async_sync) - acc_wait (qid); - else if (qid == async) - /* If we're waiting on the same asynchronous queue as we're - launching on, the queue itself will order work as - required, so there's no need to wait explicitly. */ - ; - else - acc_wait_async (qid, async); - } -} - void GOACC_update (int flags_m, size_t mapnum, void **hostaddrs, size_t *sizes, unsigned short *kinds, @@ -1002,44 +968,6 @@ GOACC_update (int flags_m, size_t mapnum, } } -void -GOACC_wait (int async, int num_waits, ...) -{ - goacc_lazy_initialize (); - - struct goacc_thread *thr = goacc_thread (); - - /* No nesting. */ - assert (thr->prof_info == NULL); - assert (thr->api_info == NULL); - acc_prof_info prof_info; - acc_api_info api_info; - bool profiling_p = GOACC_PROFILING_SETUP_P (thr, &prof_info, &api_info); - if (profiling_p) - { - prof_info.async = async; - prof_info.async_queue = prof_info.async; - } - - if (num_waits) - { - va_list ap; - - va_start (ap, num_waits); - goacc_wait (async, num_waits, &ap); - va_end (ap); - } - else if (async == acc_async_sync) - acc_wait_all (); - else - acc_wait_all_async (async); - - if (profiling_p) - { - thr->prof_info = NULL; - thr->api_info = NULL; - } -} /* Legacy entry point (GCC 5). */ -- 2.17.1