Commit 5031b619 by Thomas Schwinge Committed by Thomas Schwinge

[OpenACC] Refactor 'goacc_remove_pointer' interface

No functional changes.

	libgomp/
	* oacc-mem.c (goacc_remove_pointer): Refactor interface.  Adjust
	all users.

From-SVN: r279538
parent 1a79b578
2019-12-18 Thomas Schwinge <thomas@codesourcery.com> 2019-12-18 Thomas Schwinge <thomas@codesourcery.com>
* oacc-mem.c (goacc_remove_pointer): Refactor interface. Adjust
all users.
* oacc-mem.c (GOACC_enter_exit_data): Refactor code to call * oacc-mem.c (GOACC_enter_exit_data): Refactor code to call
'goacc_enter_data', 'goacc_exit_data'. 'goacc_enter_data', 'goacc_exit_data'.
......
...@@ -873,8 +873,8 @@ acc_update_self_async (void *h, size_t s, int async) ...@@ -873,8 +873,8 @@ acc_update_self_async (void *h, size_t s, int async)
/* Special handling for 'GOMP_MAP_POINTER', 'GOMP_MAP_TO_PSET'. /* Special handling for 'GOMP_MAP_POINTER', 'GOMP_MAP_TO_PSET'.
Only the first mapping is considered in reference counting; the following Only the first mapping is considered in reference counting; the following
ones implicitly follow suit. Similarly, 'copyout' ('force_copyfrom') is ones implicitly follow suit. Similarly, 'copyout' is done only for the
done only for the first mapping. */ first mapping. */
static void static void
goacc_insert_pointer (size_t mapnum, void **hostaddrs, size_t *sizes, goacc_insert_pointer (size_t mapnum, void **hostaddrs, size_t *sizes,
...@@ -925,9 +925,10 @@ goacc_insert_pointer (size_t mapnum, void **hostaddrs, size_t *sizes, ...@@ -925,9 +925,10 @@ goacc_insert_pointer (size_t mapnum, void **hostaddrs, size_t *sizes,
} }
static void static void
goacc_remove_pointer (void *h, size_t s, bool force_copyfrom, int async, goacc_remove_pointer (void *h, size_t s, unsigned short kind, int async)
int finalize)
{ {
kind &= 0xff;
struct goacc_thread *thr = goacc_thread (); struct goacc_thread *thr = goacc_thread ();
struct gomp_device_descr *acc_dev = thr->dev; struct gomp_device_descr *acc_dev = thr->dev;
splay_tree_key n; splay_tree_key n;
...@@ -958,6 +959,8 @@ goacc_remove_pointer (void *h, size_t s, bool force_copyfrom, int async, ...@@ -958,6 +959,8 @@ goacc_remove_pointer (void *h, size_t s, bool force_copyfrom, int async,
gomp_fatal ("Dynamic reference counting assert fail\n"); gomp_fatal ("Dynamic reference counting assert fail\n");
} }
bool finalize = (kind == GOMP_MAP_DELETE
|| kind == GOMP_MAP_FORCE_FROM);
if (finalize) if (finalize)
{ {
n->refcount -= n->dynamic_refcount; n->refcount -= n->dynamic_refcount;
...@@ -973,11 +976,12 @@ goacc_remove_pointer (void *h, size_t s, bool force_copyfrom, int async, ...@@ -973,11 +976,12 @@ goacc_remove_pointer (void *h, size_t s, bool force_copyfrom, int async,
{ {
goacc_aq aq = get_goacc_asyncqueue (async); goacc_aq aq = get_goacc_asyncqueue (async);
if (force_copyfrom) bool copyout = (kind == GOMP_MAP_FROM
|| kind == GOMP_MAP_FORCE_FROM);
if (copyout)
{ {
void *d = (void *) (t->tgt_start + n->tgt_offset void *d = (void *) (t->tgt_start + n->tgt_offset
+ (uintptr_t) h - n->host_start); + (uintptr_t) h - n->host_start);
gomp_copy_dev2host (acc_dev, aq, h, d, s); gomp_copy_dev2host (acc_dev, aq, h, d, s);
} }
...@@ -1194,12 +1198,11 @@ GOACC_enter_exit_data (int flags_m, size_t mapnum, void **hostaddrs, ...@@ -1194,12 +1198,11 @@ GOACC_enter_exit_data (int flags_m, size_t mapnum, void **hostaddrs,
else else
for (i = 0; i < mapnum; ++i) for (i = 0; i < mapnum; ++i)
{ {
unsigned char kind = kinds[i] & 0xff;
int pointer = find_pointer (i, mapnum, kinds); int pointer = find_pointer (i, mapnum, kinds);
if (!pointer) if (!pointer)
{ {
unsigned char kind = kinds[i] & 0xff;
switch (kind) switch (kind)
{ {
case GOMP_MAP_RELEASE: case GOMP_MAP_RELEASE:
...@@ -1217,12 +1220,7 @@ GOACC_enter_exit_data (int flags_m, size_t mapnum, void **hostaddrs, ...@@ -1217,12 +1220,7 @@ GOACC_enter_exit_data (int flags_m, size_t mapnum, void **hostaddrs,
} }
else else
{ {
bool finalize = (kind == GOMP_MAP_DELETE goacc_remove_pointer (hostaddrs[i], sizes[i], kinds[i], async);
|| kind == GOMP_MAP_FORCE_FROM);
bool copyfrom = (kind == GOMP_MAP_FORCE_FROM
|| kind == GOMP_MAP_FROM);
goacc_remove_pointer (hostaddrs[i], sizes[i], copyfrom, async,
finalize);
/* See the above comment. */ /* See the above comment. */
i += pointer - 1; i += pointer - 1;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment