aboutsummaryrefslogtreecommitdiff
path: root/libgomp/oacc-mem.c
diff options
context:
space:
mode:
authorThomas Schwinge <thomas@codesourcery.com>2020-06-04 16:13:35 +0200
committerThomas Schwinge <thomas@codesourcery.com>2020-06-04 19:29:27 +0200
commit2c838a3e4ea06c69c856d074ae5b0400e08ae3c2 (patch)
tree36185d623c6b89469d77b9304cb8e536edda2c04 /libgomp/oacc-mem.c
parenta02f1adbfe619ab19cf142438e0a02950d3594da (diff)
[OpenACC 'exit data'] Evaluate 'copyfrom' individually for 'GOMP_MAP_STRUCT' entries
Currently, we don't at all evaluate 'copyfrom' for 'GOMP_MAP_STRUCT' entries. Fix this by copying/adapting the corresponding non-'GOMP_MAP_STRUCT' code. libgomp/ * oacc-mem.c (goacc_exit_data_internal) <GOMP_MAP_STRUCT>: Evaluate 'copyfrom' individually for each entry. * testsuite/libgomp.oacc-c-c++-common/struct-1.c: Update.
Diffstat (limited to 'libgomp/oacc-mem.c')
-rw-r--r--libgomp/oacc-mem.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/libgomp/oacc-mem.c b/libgomp/oacc-mem.c
index a34f4cf0e91..11419e692aa 100644
--- a/libgomp/oacc-mem.c
+++ b/libgomp/oacc-mem.c
@@ -1194,6 +1194,12 @@ goacc_exit_data_internal (struct gomp_device_descr *acc_dev, size_t mapnum,
|| 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];
@@ -1216,6 +1222,16 @@ goacc_exit_data_internal (struct gomp_device_descr *acc_dev, size_t mapnum,
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)