diff options
author | Thomas Schwinge <thomas@codesourcery.com> | 2019-12-09 23:52:36 +0100 |
---|---|---|
committer | Thomas Schwinge <tschwinge@gcc.gnu.org> | 2019-12-09 23:52:36 +0100 |
commit | e103542bc8606e7b5033631e33bdfb9e29191b24 (patch) | |
tree | 2f4ee534dbefc291c0850e7ef69e927f05801dc5 /libgomp/oacc-mem.c | |
parent | 49070d06708a8d8ae3af767f89ac40c4c12dca7b (diff) |
[PR92840] [OpenACC] Refuse 'acc_unmap_data' unless mapped by 'acc_map_data'
libgomp/
PR libgomp/92840
* oacc-mem.c (acc_map_data): Clarify reference counting behavior.
(acc_unmap_data): Add error case for 'REFCOUNT_INFINITY'.
* testsuite/libgomp.oacc-c-c++-common/acc_unmap_data-pr92840-1.c:
New file.
* testsuite/libgomp.oacc-c-c++-common/acc_unmap_data-pr92840-2.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/acc_unmap_data-pr92840-3.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/clauses-1.c: Adjust.
* testsuite/libgomp.oacc-c-c++-common/nested-1.c: Adjust.
From-SVN: r279145
Diffstat (limited to 'libgomp/oacc-mem.c')
-rw-r--r-- | libgomp/oacc-mem.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/libgomp/oacc-mem.c b/libgomp/oacc-mem.c index 55c195bd819..480b9fbb71b 100644 --- a/libgomp/oacc-mem.c +++ b/libgomp/oacc-mem.c @@ -407,7 +407,11 @@ acc_map_data (void *h, void *d, size_t s) tgt = gomp_map_vars (acc_dev, mapnum, &hostaddrs, &devaddrs, &sizes, &kinds, true, GOMP_MAP_VARS_OPENACC); - tgt->list[0].key->refcount = REFCOUNT_INFINITY; + splay_tree_key n = tgt->list[0].key; + assert (n->refcount == 1); + assert (n->dynamic_refcount == 0); + /* Special reference counting behavior. */ + n->refcount = REFCOUNT_INFINITY; if (profiling_p) { @@ -459,6 +463,18 @@ acc_unmap_data (void *h) gomp_fatal ("[%p,%d] surrounds %p", (void *) n->host_start, (int) host_size, (void *) h); } + /* TODO This currently doesn't catch 'REFCOUNT_INFINITY' usage different from + 'acc_map_data'. Maybe 'dynamic_refcount' can be used for disambiguating + the different 'REFCOUNT_INFINITY' cases, or simply separate + 'REFCOUNT_INFINITY' values per different usage ('REFCOUNT_ACC_MAP_DATA' + etc.)? */ + else if (n->refcount != REFCOUNT_INFINITY) + { + gomp_mutex_unlock (&acc_dev->lock); + gomp_fatal ("refusing to unmap block [%p,+%d] that has not been mapped" + " by 'acc_map_data'", + (void *) h, (int) host_size); + } /* Mark for removal. */ n->refcount = 1; |