From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa4.mentor.iphmx.com (esa4.mentor.iphmx.com [68.232.137.252]) by sourceware.org (Postfix) with ESMTPS id D54A73851C30 for ; Fri, 5 Jun 2020 16:23:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D54A73851C30 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Thomas_Schwinge@mentor.com IronPort-SDR: +UBNyR4+docqshXKnugQpfnhO5e4aQwcoNr3l0dvO5tlEK7eFomO+EQznacECVecT4UG1oZbys L6R6pnqWRDG0KgdudaoPIKTMkVGD8tMmGT/22c9gYjDjaDXQWF0NQsZz5t5uwy4zbI56huFAtO EtFbztBNAFoYdcY+e+zQOMstlPazmbIbzQedZFUdUmKpq/bFHqPJ4GgIuFvcpNF+ftKEsypJZl Jm7PZzOrZlkTouDngpoBoVopbeF4E3TXWwrtACfc7ePQeNDPAF0uFOvQ+fQB8qVd5eFEJ8AnpB A50= X-IronPort-AV: E=Sophos;i="5.73,477,1583222400"; d="scan'208,223";a="49625350" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa4.mentor.iphmx.com with ESMTP; 05 Jun 2020 08:23:58 -0800 IronPort-SDR: iDC6jkKM0enUvcLkf+e1KHHiEgYFvZ+L0odUTrEKtUm+yL8N2XYAjuPWUuln87M0qp/K5t1KW6 W7X1XjpwSM8ftu3YJWhUH+1bAaiARqANZpdTyhjk5c05apKC7SNqkPQZ1UaKK4yblO9FZg6V03 mq2pehlLFPKhmMUIktaN0x0ewmDfM/AfbbCI74XoXlxUqw2ntRNHXqCYHhvW81dF9ZJKXcqphB 91BUQyc8B6tQLM/kHbr3u/vVzQ48YsfephFdrGQuyAu+8F8DHaKSXDjVX/RxcgrXgEgqBFL9Ds 7Xs= From: Thomas Schwinge To: Julian Brown , CC: Jakub Jelinek Subject: [OpenACC 'exit data'] Simplify 'GOMP_MAP_STRUCT' handling (was: [PATCH 07/13] OpenACC 2.6 deep copy: libgomp parts) In-Reply-To: <87r1vf7xr4.fsf@euler.schwinge.homeip.net> References: <65540b92dff74db1f15af930f87f7096d03e7efe.1576648001.git.julian@codesourcery.com> <87r1vf7xr4.fsf@euler.schwinge.homeip.net> User-Agent: Notmuch/0.29.1+93~g67ed7df (https://notmuchmail.org) Emacs/26.3 (x86_64-pc-linux-gnu) Date: Fri, 5 Jun 2020 18:23:45 +0200 Message-ID: <87y2p1qy5q.fsf@euler.schwinge.homeip.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_ASCII_DIVIDERS, KAM_DMARC_STATUS, KAM_LOTSOFHASH, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: , X-List-Received-Date: Fri, 05 Jun 2020 16:24:01 -0000 --=-=-= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Hi! On 2020-05-20T11:37:35+0200, I wrote: > Moving this over, from the "Fix component mappings with derived types for > OpenACC" thread, > , where > you propose to change this 'GOMP_MAP_STRUCT' handling code: > > On 2019-12-17T22:03:47-0800, Julian Brown wrote= : >> --- a/libgomp/oacc-mem.c >> +++ b/libgomp/oacc-mem.c > >> @@ -1075,6 +1119,39 @@ goacc_exit_data_internal (struct gomp_device_desc= r *acc_dev, size_t mapnum, >> gomp_remove_var_async (acc_dev, n, aq); >> } >> break; >> + >> + case GOMP_MAP_STRUCT: >> + { >> + int elems =3D sizes[i]; >> + for (int j =3D 1; j <=3D elems; j++) >> + { >> + struct splay_tree_key_s k; >> + k.host_start =3D (uintptr_t) hostaddrs[i + j]; >> + k.host_end =3D k.host_start + sizes[i + j]; >> + splay_tree_key str; >> + str =3D splay_tree_lookup (&acc_dev->mem_map, &k); >> + if (str) >> + { >> + if (finalize) >> + { >> + str->refcount -=3D str->virtual_refcount; >> + str->virtual_refcount =3D 0; >> + } >> + if (str->virtual_refcount > 0) >> + { >> + str->refcount--; >> + str->virtual_refcount--; >> + } >> + else if (str->refcount > 0) >> + str->refcount--; >> + if (str->refcount =3D=3D 0) >> + gomp_remove_var_async (acc_dev, str, aq); >> + } >> + } >> + i +=3D elems; >> + } >> + break; >> + >> default: >> gomp_fatal (">>>> goacc_exit_data_internal UNHANDLED kind 0x%.2x"= , >> kind); > > ... into an "empty 'case GOMP_MAP_STRUCT:' as a no-op [...] > I suppose we still need to unmap the "'GOMP_MAP_STRUCT' components", but > can do that individually, outside of the 'GOMP_MAP_STRUCT' context. You've answered my question with the patch submission; I've now pushed "[OpenACC 'exit data'] Simplify 'GOMP_MAP_STRUCT' handling" to master branch in commit 1809628fcff6f512206efd0ae03a3faccc4096f2, and releases/gcc-10 branch in commit 96d8d068f3d6f3efebdca65f0a7b86e0609ee66f, see attached. Gr=C3=BC=C3=9Fe Thomas ----------------- Mentor Graphics (Deutschland) GmbH, Arnulfstra=C3=9Fe 201, 80634 M=C3=BCnch= en / Germany Registergericht M=C3=BCnchen HRB 106955, Gesch=C3=A4ftsf=C3=BChrer: Thomas = Heurung, Alexander Walter --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename="0001-OpenACC-exit-data-Simplify-GOMP_MAP_STRUCT-handling.patch" >From 1809628fcff6f512206efd0ae03a3faccc4096f2 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Wed, 20 May 2020 10:53:33 +0200 Subject: [PATCH] [OpenACC 'exit data'] Simplify 'GOMP_MAP_STRUCT' handling libgomp/ * oacc-mem.c (goacc_exit_data_internal) : Simplify. Co-Authored-By: Julian Brown --- libgomp/oacc-mem.c | 83 ++-------------------------------------------- 1 file changed, 3 insertions(+), 80 deletions(-) diff --git a/libgomp/oacc-mem.c b/libgomp/oacc-mem.c index 11419e692aa2..1e3685a073da 100644 --- a/libgomp/oacc-mem.c +++ b/libgomp/oacc-mem.c @@ -1180,86 +1180,9 @@ goacc_exit_data_internal (struct gomp_device_descr *acc_dev, size_t mapnum, break; case GOMP_MAP_STRUCT: - { - int elems = sizes[i]; - for (int j = 1; j <= elems; j++) - { - assert (i + j < mapnum); - - kind = kinds[i + j] & 0xff; - - finalize = false; - if (kind == GOMP_MAP_FORCE_FROM - || kind == GOMP_MAP_DELETE - || kind == GOMP_MAP_FORCE_DETACH) - finalize = true; - - copyfrom = false; - if (kind == GOMP_MAP_FROM - || kind == GOMP_MAP_FORCE_FROM - || kind == GOMP_MAP_ALWAYS_FROM) - copyfrom = true; - - struct splay_tree_key_s k; - k.host_start = (uintptr_t) hostaddrs[i + j]; - k.host_end = k.host_start + sizes[i + j]; - splay_tree_key str; - str = splay_tree_lookup (&acc_dev->mem_map, &k); - if (str) - { - if (finalize) - { - if (str->refcount != REFCOUNT_INFINITY) - str->refcount -= str->virtual_refcount; - str->virtual_refcount = 0; - } - if (str->virtual_refcount > 0) - { - if (str->refcount != REFCOUNT_INFINITY) - str->refcount--; - str->virtual_refcount--; - } - else if (str->refcount > 0 - && str->refcount != REFCOUNT_INFINITY) - str->refcount--; - - if (copyfrom - && (kind != GOMP_MAP_FROM || str->refcount == 0)) - gomp_copy_dev2host (acc_dev, aq, (void *) k.host_start, - (void *) (str->tgt->tgt_start - + str->tgt_offset - + k.host_start - - str->host_start), - k.host_end - k.host_start); - - if (str->refcount == 0) - { - if (aq) - /* TODO We can't do the 'is_tgt_unmapped' checking -- - see the 'gomp_unref_tgt' comment in - ; - PR92881. */ - gomp_remove_var_async (acc_dev, str, aq); - else - { - size_t num_mappings = 0; - /* If the target_mem_desc represents a single data - mapping, we can check that it is freed when this - splay tree key's refcount reaches zero. - Otherwise (e.g. for a 'GOMP_MAP_STRUCT' mapping - with multiple members), fall back to skipping - the test. */ - for (size_t l_i = 0; l_i < str->tgt->list_count; ++l_i) - if (str->tgt->list[l_i].key) - ++num_mappings; - bool is_tgt_unmapped = gomp_remove_var (acc_dev, str); - assert (is_tgt_unmapped || num_mappings > 1); - } - } - } - } - i += elems; - } + /* Skip the 'GOMP_MAP_STRUCT' itself, and use the regular processing + for all its entries. TODO: don't generate these no-op + 'GOMP_MAP_STRUCT's. */ break; default: -- 2.26.2 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename="0001-OpenACC-exit-data-Simplify-GOMP_MAP_STRUCT-handl.g10.patch" >From 96d8d068f3d6f3efebdca65f0a7b86e0609ee66f Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Wed, 20 May 2020 10:53:33 +0200 Subject: [PATCH] [OpenACC 'exit data'] Simplify 'GOMP_MAP_STRUCT' handling libgomp/ * oacc-mem.c (goacc_exit_data_internal) : Simplify. Co-Authored-By: Julian Brown (cherry picked from commit 1809628fcff6f512206efd0ae03a3faccc4096f2) --- libgomp/oacc-mem.c | 83 ++-------------------------------------------- 1 file changed, 3 insertions(+), 80 deletions(-) diff --git a/libgomp/oacc-mem.c b/libgomp/oacc-mem.c index 11419e692aa2..1e3685a073da 100644 --- a/libgomp/oacc-mem.c +++ b/libgomp/oacc-mem.c @@ -1180,86 +1180,9 @@ goacc_exit_data_internal (struct gomp_device_descr *acc_dev, size_t mapnum, break; case GOMP_MAP_STRUCT: - { - int elems = sizes[i]; - for (int j = 1; j <= elems; j++) - { - assert (i + j < mapnum); - - kind = kinds[i + j] & 0xff; - - finalize = false; - if (kind == GOMP_MAP_FORCE_FROM - || kind == GOMP_MAP_DELETE - || kind == GOMP_MAP_FORCE_DETACH) - finalize = true; - - copyfrom = false; - if (kind == GOMP_MAP_FROM - || kind == GOMP_MAP_FORCE_FROM - || kind == GOMP_MAP_ALWAYS_FROM) - copyfrom = true; - - struct splay_tree_key_s k; - k.host_start = (uintptr_t) hostaddrs[i + j]; - k.host_end = k.host_start + sizes[i + j]; - splay_tree_key str; - str = splay_tree_lookup (&acc_dev->mem_map, &k); - if (str) - { - if (finalize) - { - if (str->refcount != REFCOUNT_INFINITY) - str->refcount -= str->virtual_refcount; - str->virtual_refcount = 0; - } - if (str->virtual_refcount > 0) - { - if (str->refcount != REFCOUNT_INFINITY) - str->refcount--; - str->virtual_refcount--; - } - else if (str->refcount > 0 - && str->refcount != REFCOUNT_INFINITY) - str->refcount--; - - if (copyfrom - && (kind != GOMP_MAP_FROM || str->refcount == 0)) - gomp_copy_dev2host (acc_dev, aq, (void *) k.host_start, - (void *) (str->tgt->tgt_start - + str->tgt_offset - + k.host_start - - str->host_start), - k.host_end - k.host_start); - - if (str->refcount == 0) - { - if (aq) - /* TODO We can't do the 'is_tgt_unmapped' checking -- - see the 'gomp_unref_tgt' comment in - ; - PR92881. */ - gomp_remove_var_async (acc_dev, str, aq); - else - { - size_t num_mappings = 0; - /* If the target_mem_desc represents a single data - mapping, we can check that it is freed when this - splay tree key's refcount reaches zero. - Otherwise (e.g. for a 'GOMP_MAP_STRUCT' mapping - with multiple members), fall back to skipping - the test. */ - for (size_t l_i = 0; l_i < str->tgt->list_count; ++l_i) - if (str->tgt->list[l_i].key) - ++num_mappings; - bool is_tgt_unmapped = gomp_remove_var (acc_dev, str); - assert (is_tgt_unmapped || num_mappings > 1); - } - } - } - } - i += elems; - } + /* Skip the 'GOMP_MAP_STRUCT' itself, and use the regular processing + for all its entries. TODO: don't generate these no-op + 'GOMP_MAP_STRUCT's. */ break; default: -- 2.26.2 --=-=-=--