public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Thomas Schwinge <thomas@codesourcery.com>
To: Julian Brown <julian@codesourcery.com>
Cc: <gcc-patches@gcc.gnu.org>, Jakub Jelinek <jakub@redhat.com>
Subject: [OpenACC] Use 'tgt' returned from 'gomp_map_vars' (was: [PATCH 02/13] OpenACC reference count overhaul)
Date: Thu, 4 Jun 2020 20:13:07 +0200	[thread overview]
Message-ID: <87mu5isnrg.fsf@euler.schwinge.homeip.net> (raw)
In-Reply-To: <877dx89bj5.fsf@euler.schwinge.homeip.net>

[-- Attachment #1: Type: text/plain, Size: 2008 bytes --]

Hi!

On 2020-05-19T17:42:22+0200, I wrote:
> On 2019-12-17T22:02:27-0800, Julian Brown <julian@codesourcery.com> wrote:
>> --- a/libgomp/oacc-mem.c
>> +++ b/libgomp/oacc-mem.c
>
>> @@ -571,14 +570,16 @@ present_create_copy (unsigned f, void *h, size_t s, int async)
>>
>>        goacc_aq aq = get_goacc_asyncqueue (async);
>>
>> -      tgt = gomp_map_vars_async (acc_dev, aq, mapnum, &hostaddrs, NULL, &s,
>> -                             &kinds, true, GOMP_MAP_VARS_OPENACC);
>> -      n = tgt->list[0].key;
>> -      assert (n->refcount == 1);
>> -      assert (n->dynamic_refcount == 0);
>> -      n->dynamic_refcount++;
>> +      gomp_map_vars_async (acc_dev, aq, mapnum, &hostaddrs, NULL, &s, &kinds,
>> +                       true, GOMP_MAP_VARS_OPENACC_ENTER_DATA);
>>
>> -      d = tgt->to_free;
>> +      gomp_mutex_lock (&acc_dev->lock);
>> +      n = lookup_host (acc_dev, h, s);
>> +      assert (n != NULL);
>> +      assert (n->tgt_offset == 0);
>> +      assert ((uintptr_t) h == n->host_start);
>> +      d = (void *) n->tgt->tgt_start;
>> +      gomp_mutex_unlock (&acc_dev->lock);
>>      }
>
> [...], is there a reason that you changed this code to look up
> 'n = lookup_host ([...])'?  This is the case that 'gomp_map_vars' enters
> a new mapping, so by construction, 'n = tgt->list[0].key' must hold?  I
> tested the following: [...], and don't see any regressions.

You've included something similar (even slightly better!) in a bigger
other patch that you've sent, so I've now combined/split that out, and
pushed "[OpenACC] Use 'tgt' returned from 'gomp_map_vars'" to master
branch in commit f233418ccf6a16eb3bf53018852c5f8926780143, and
releases/gcc-10 branch in commit
c44c9858962ab8045d57d531a83b430dd7be8d5a, see attached.


Grüße
 Thomas


-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-OpenACC-Use-tgt-returned-from-gomp_map_vars.patch --]
[-- Type: text/x-diff, Size: 2517 bytes --]

From f233418ccf6a16eb3bf53018852c5f8926780143 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Thu, 14 May 2020 15:49:52 +0200
Subject: [PATCH] [OpenACC] Use 'tgt' returned from 'gomp_map_vars'

	libgomp/
	* oacc-mem.c (goacc_enter_datum): Use 'tgt' returned from
	'gomp_map_vars'.
	 (acc_map_data): Clean up accordingly.

Co-Authored-By: Julian Brown <julian@codesourcery.com>
---
 libgomp/oacc-mem.c | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/libgomp/oacc-mem.c b/libgomp/oacc-mem.c
index 6713846c9429..e2fb651a2334 100644
--- a/libgomp/oacc-mem.c
+++ b/libgomp/oacc-mem.c
@@ -355,7 +355,6 @@ acc_is_present (void *h, size_t s)
 void
 acc_map_data (void *h, void *d, size_t s)
 {
-  struct target_mem_desc *tgt = NULL;
   size_t mapnum = 1;
   void *hostaddrs = h;
   void *devaddrs = d;
@@ -402,10 +401,13 @@ acc_map_data (void *h, void *d, size_t s)
 
       gomp_mutex_unlock (&acc_dev->lock);
 
-      tgt = gomp_map_vars (acc_dev, mapnum, &hostaddrs, &devaddrs, &sizes,
-			   &kinds, true, GOMP_MAP_VARS_ENTER_DATA);
+      struct target_mem_desc *tgt
+	= gomp_map_vars (acc_dev, mapnum, &hostaddrs, &devaddrs, &sizes,
+			 &kinds, true, GOMP_MAP_VARS_ENTER_DATA);
       assert (tgt);
+      assert (tgt->list_count == 1);
       splay_tree_key n = tgt->list[0].key;
+      assert (n);
       assert (n->refcount == 1);
       assert (n->virtual_refcount == 0);
       /* Special reference counting behavior.  */
@@ -555,16 +557,17 @@ goacc_enter_datum (void **hostaddrs, size_t *sizes, void *kinds, int async)
 
       goacc_aq aq = get_goacc_asyncqueue (async);
 
-      gomp_map_vars_async (acc_dev, aq, mapnum, hostaddrs, NULL, sizes, kinds,
-			   true, GOMP_MAP_VARS_OPENACC_ENTER_DATA);
+      struct target_mem_desc *tgt
+	= gomp_map_vars_async (acc_dev, aq, mapnum, hostaddrs, NULL, sizes,
+			       kinds, true, GOMP_MAP_VARS_OPENACC_ENTER_DATA);
+      assert (tgt);
+      assert (tgt->list_count == 1);
+      n = tgt->list[0].key;
+      assert (n);
+      assert (n->refcount == 1);
+      assert (n->virtual_refcount == 0);
 
-      gomp_mutex_lock (&acc_dev->lock);
-      n = lookup_host (acc_dev, hostaddrs[0], sizes[0]);
-      assert (n != NULL);
-      assert (n->tgt_offset == 0);
-      assert ((uintptr_t) hostaddrs[0] == n->host_start);
-      d = (void *) n->tgt->tgt_start;
-      gomp_mutex_unlock (&acc_dev->lock);
+      d = (void *) tgt->tgt_start;
     }
 
   if (profiling_p)
-- 
2.26.2


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0001-OpenACC-Use-tgt-returned-from-gomp_map_vars.g10.patch --]
[-- Type: text/x-diff, Size: 2586 bytes --]

From c44c9858962ab8045d57d531a83b430dd7be8d5a Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Thu, 14 May 2020 15:49:52 +0200
Subject: [PATCH] [OpenACC] Use 'tgt' returned from 'gomp_map_vars'

	libgomp/
	* oacc-mem.c (goacc_enter_datum): Use 'tgt' returned from
	'gomp_map_vars'.
	 (acc_map_data): Clean up accordingly.

Co-Authored-By: Julian Brown <julian@codesourcery.com>
(cherry picked from commit f233418ccf6a16eb3bf53018852c5f8926780143)
---
 libgomp/oacc-mem.c | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/libgomp/oacc-mem.c b/libgomp/oacc-mem.c
index 6713846c9429..e2fb651a2334 100644
--- a/libgomp/oacc-mem.c
+++ b/libgomp/oacc-mem.c
@@ -355,7 +355,6 @@ acc_is_present (void *h, size_t s)
 void
 acc_map_data (void *h, void *d, size_t s)
 {
-  struct target_mem_desc *tgt = NULL;
   size_t mapnum = 1;
   void *hostaddrs = h;
   void *devaddrs = d;
@@ -402,10 +401,13 @@ acc_map_data (void *h, void *d, size_t s)
 
       gomp_mutex_unlock (&acc_dev->lock);
 
-      tgt = gomp_map_vars (acc_dev, mapnum, &hostaddrs, &devaddrs, &sizes,
-			   &kinds, true, GOMP_MAP_VARS_ENTER_DATA);
+      struct target_mem_desc *tgt
+	= gomp_map_vars (acc_dev, mapnum, &hostaddrs, &devaddrs, &sizes,
+			 &kinds, true, GOMP_MAP_VARS_ENTER_DATA);
       assert (tgt);
+      assert (tgt->list_count == 1);
       splay_tree_key n = tgt->list[0].key;
+      assert (n);
       assert (n->refcount == 1);
       assert (n->virtual_refcount == 0);
       /* Special reference counting behavior.  */
@@ -555,16 +557,17 @@ goacc_enter_datum (void **hostaddrs, size_t *sizes, void *kinds, int async)
 
       goacc_aq aq = get_goacc_asyncqueue (async);
 
-      gomp_map_vars_async (acc_dev, aq, mapnum, hostaddrs, NULL, sizes, kinds,
-			   true, GOMP_MAP_VARS_OPENACC_ENTER_DATA);
+      struct target_mem_desc *tgt
+	= gomp_map_vars_async (acc_dev, aq, mapnum, hostaddrs, NULL, sizes,
+			       kinds, true, GOMP_MAP_VARS_OPENACC_ENTER_DATA);
+      assert (tgt);
+      assert (tgt->list_count == 1);
+      n = tgt->list[0].key;
+      assert (n);
+      assert (n->refcount == 1);
+      assert (n->virtual_refcount == 0);
 
-      gomp_mutex_lock (&acc_dev->lock);
-      n = lookup_host (acc_dev, hostaddrs[0], sizes[0]);
-      assert (n != NULL);
-      assert (n->tgt_offset == 0);
-      assert ((uintptr_t) hostaddrs[0] == n->host_start);
-      d = (void *) n->tgt->tgt_start;
-      gomp_mutex_unlock (&acc_dev->lock);
+      d = (void *) tgt->tgt_start;
     }
 
   if (profiling_p)
-- 
2.26.2


  reply	other threads:[~2020-06-04 18:13 UTC|newest]

Thread overview: 81+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-10 17:11 [PATCH 0/3] OpenACC 2.6 manual deep copy support (attach/detach) Julian Brown
2018-11-10 17:11 ` [PATCH 1/3] Host-to-device transfer coalescing & magic offset value self-documentation Julian Brown
2018-12-21 10:56   ` libgomp/target.c magic constants self-documentation Thomas Schwinge
2019-05-29 14:48     ` Thomas Schwinge
2018-11-10 17:11 ` [PATCH 2/3] Factor out duplicate code in gimplify_scan_omp_clauses Julian Brown
2018-12-18 14:16   ` Julian Brown
2018-12-18 14:50   ` Jakub Jelinek
2018-11-10 17:12 ` [PATCH 3/3] OpenACC 2.6 manual deep copy support (attach/detach) Julian Brown
2018-11-11 17:04   ` Bernhard Reutner-Fischer
2018-11-30 11:41   ` [PATCH] " Julian Brown
2018-12-03 17:03     ` Julian Brown
2018-12-07 13:50     ` Jakub Jelinek
2018-12-10 19:42       ` Julian Brown
2018-12-13 10:57         ` Jakub Jelinek
2018-12-14 19:00           ` Julian Brown
2018-12-18 12:25             ` Jakub Jelinek
2018-12-22 13:37             ` Thomas Schwinge
2019-10-18 17:20         ` Thomas Schwinge
2019-11-06 18:44           ` Julian Brown
2019-11-22 23:54             ` Julian Brown
2019-11-25 10:53               ` Tobias Burnus
2019-11-26  2:54                 ` Julian Brown
2019-12-17 12:16                   ` Thomas Schwinge
2019-12-17 17:28                     ` [WIP] OpenACC 'acc_attach*', 'acc_detach*' runtime library routines (was: [PATCH] OpenACC 2.6 manual deep copy support (attach/detach)) Thomas Schwinge
2019-12-18  6:03                   ` [PATCH 00/13] OpenACC 2.6 manual deep copy support Julian Brown
2019-12-18  6:03                     ` [PATCH 01/13] Use aux struct in libgomp for infrequently-used/API-specific data Julian Brown
2019-12-18  6:03                     ` [PATCH 03/13] OpenACC reference count consistency checking Julian Brown
2019-12-18  6:03                     ` [PATCH 02/13] OpenACC reference count overhaul Julian Brown
2020-05-19 15:42                       ` Thomas Schwinge
2020-06-04 18:13                         ` Thomas Schwinge [this message]
2020-05-19 15:49                       ` Thomas Schwinge
2020-05-19 15:58                       ` Thomas Schwinge
2020-06-25 11:03                         ` Thomas Schwinge
2020-07-03 15:29                           ` Thomas Schwinge
2019-12-18  6:04                     ` [PATCH 06/13] OpenACC 2.6 deep copy: attach/detach API routines Julian Brown
2019-12-18  6:04                     ` [PATCH 09/13] OpenACC 2.6 deep copy: C and C++ front-end parts Julian Brown
2019-12-24  5:05                       ` Thomas Schwinge
2019-12-26 19:04                       ` Jason Merrill
2021-06-10 11:03                       ` Thomas Schwinge
2019-12-18  6:04                     ` [PATCH 04/13] Use gomp_map_val for OpenACC host-to-device address translation Julian Brown
2019-12-18  6:04                     ` [PATCH 05/13] Factor out duplicate code in gimplify_scan_omp_clauses Julian Brown
2019-12-18  6:04                     ` [PATCH 08/13] OpenACC 2.6 deep copy: middle-end parts Julian Brown
2019-12-21 21:51                       ` Thomas Schwinge
2019-12-18  6:05                     ` [PATCH 12/13] OpenACC 2.6 deep copy: Fortran execution tests Julian Brown
2019-12-18  6:05                     ` [PATCH 07/13] OpenACC 2.6 deep copy: libgomp parts Julian Brown
2019-12-21 23:37                       ` Thomas Schwinge
2020-01-03 12:26                         ` Julian Brown
2020-05-20  9:37                       ` Thomas Schwinge
2020-06-05 16:23                         ` [OpenACC 'exit data'] Simplify 'GOMP_MAP_STRUCT' handling (was: [PATCH 07/13] OpenACC 2.6 deep copy: libgomp parts) Thomas Schwinge
2020-06-05 16:36                         ` [OpenACC 'exit data'] Strip 'GOMP_MAP_STRUCT' mappings " Thomas Schwinge
2020-05-20 14:52                       ` [PATCH 07/13] OpenACC 2.6 deep copy: libgomp parts Thomas Schwinge
2020-05-20 19:11                         ` Julian Brown
2020-06-04 18:35                           ` [OpenACC] Repair/restore 'is_tgt_unmapped' checking (was: [PATCH 07/13] OpenACC 2.6 deep copy: libgomp parts) Thomas Schwinge
2020-06-04 18:53                       ` [PATCH 07/13] OpenACC 2.6 deep copy: libgomp parts Thomas Schwinge
2020-06-05 10:39                       ` Thomas Schwinge
2020-06-05 20:28                         ` Julian Brown
2020-06-05 11:17                       ` Thomas Schwinge
2020-06-05 20:31                         ` Julian Brown
2020-06-09 10:41                           ` OpenACC 'attach'/'detach' has no business affecting user-visible reference counting (was: [PATCH 07/13] OpenACC 2.6 deep copy: libgomp parts) Thomas Schwinge
2020-06-09 12:23                             ` Julian Brown
2020-06-18 18:21                             ` Julian Brown
2020-07-16  8:35                               ` OpenACC 'attach'/'detach' has no business affecting user-visible reference counting Thomas Schwinge
2020-06-26  9:20                       ` [PATCH 07/13] OpenACC 2.6 deep copy: libgomp parts Thomas Schwinge
2020-07-16  9:35                         ` Thomas Schwinge
2020-07-16 21:21                           ` Julian Brown
2020-07-17  9:12                             ` Thomas Schwinge
2020-06-30 15:58                       ` Thomas Schwinge
2019-12-18  6:05                     ` [PATCH 11/13] OpenACC 2.6 deep copy: C and C++ execution tests Julian Brown
2020-06-04 18:43                       ` Fix 'sizeof' usage in 'libgomp.oacc-c-c++-common/deep-copy-{7, 8}.c' (was: [PATCH 11/13] OpenACC 2.6 deep copy: C and C++ execution tests) Thomas Schwinge
2023-10-31 14:00                       ` Add OpenACC 'acc_map_data' variant to 'libgomp.oacc-c-c++-common/deep-copy-8.c' " Thomas Schwinge
2019-12-18  6:05                     ` [PATCH 13/13] Fortran polymorphic class-type support for OpenACC Julian Brown
2019-12-18  7:20                     ` [PATCH 10/13] OpenACC 2.6 deep copy: Fortran front-end parts Julian Brown
2019-12-18 23:30                       ` Tobias Burnus
2019-12-20 12:25                         ` [committed] Improve is-coindexed check for OpenACC/OpenMP (was: [PATCH 10/13] OpenACC 2.6 deep copy: Fortran front-end parts) Tobias Burnus
2019-12-20 13:25                         ` [PATCH 10/13] OpenACC 2.6 deep copy: Fortran front-end parts Tobias Burnus
2019-12-20 10:08                       ` [patch,committed] Fix testsuite-fallout of OpenACC deep-copy patch (was: [PATCH 10/13] OpenACC 2.6 deep copy: Fortran front-end parts) Tobias Burnus
2019-12-18 18:24                     ` [PATCH 00/13] OpenACC 2.6 manual deep copy support Thomas Schwinge
2019-12-20  1:21                       ` Julian Brown
2019-12-20 14:36                     ` OpenACC regression and development pace Thomas Koenig
2020-06-04 18:07                     ` [OpenACC] XFAIL behavior of over-eager 'finalize' clause (was: [PATCH 00/13] OpenACC 2.6 manual deep copy support) Thomas Schwinge
2019-12-17 16:53             ` In 'libgomp/target.c', 'struct splay_tree_key_s', use 'struct splay_tree_aux' for infrequently-used or API-specific data (was: [PATCH] OpenACC 2.6 manual deep copy support (attach/detach)) Thomas Schwinge

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mu5isnrg.fsf@euler.schwinge.homeip.net \
    --to=thomas@codesourcery.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=julian@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).