[PATCH 02/13] OpenACC reference count overhaul
Thomas Schwinge
thomas@codesourcery.com
Tue May 19 15:42:22 GMT 2020
Hi Julian!
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);
> }
Notwithstanding the open question of the "'gomp_map_vars' locking
protocol" (discussed in a different thread, to be resolved
independently), 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:
--- libgomp/oacc-mem.c
+++ libgomp/oacc-mem.c
@@ -555,16 +555,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);
+ n = tgt->list[0].key;
+ 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);
}
..., and don't see any regressions. If approving this patch, please
respond with "Reviewed-by: NAME <EMAIL>" so that your effort will be
recorded in the commit log, see <https://gcc.gnu.org/wiki/Reviewed-by>.
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
More information about the Gcc-patches
mailing list