Commit 34cfe31e by Thomas Schwinge Committed by Thomas Schwinge

[OpenACC] Refactor 'delete_copyout' into 'goacc_exit_data'

Change 'FLAG_COPYOUT', 'FLAG_FINALIZE' into the usual map kind.

No functional changes.

	libgomp/
	* oacc-mem.c (delete_copyout): Refactor into...
	(goacc_exit_data): ... this.  Adjust all users.

From-SVN: r279536
parent aaf0e9d7
2019-12-18 Thomas Schwinge <thomas@codesourcery.com> 2019-12-18 Thomas Schwinge <thomas@codesourcery.com>
* oacc-mem.c (delete_copyout): Refactor into...
(goacc_exit_data): ... this. Adjust all users.
* oacc-mem.c (present_create_copy): Refactor into... * oacc-mem.c (present_create_copy): Refactor into...
(goacc_enter_data): ... this. Adjust all users. (goacc_enter_data): ... this. Adjust all users.
......
...@@ -636,15 +636,17 @@ acc_pcopyin (void *h, size_t s) ...@@ -636,15 +636,17 @@ acc_pcopyin (void *h, size_t s)
} }
#endif #endif
#define FLAG_COPYOUT (1 << 0)
#define FLAG_FINALIZE (1 << 1) /* Exit a dynamic mapping. */
static void static void
delete_copyout (unsigned f, void *h, size_t s, int async, const char *libfnname) goacc_exit_data (void *h, size_t s, unsigned short kind, int async)
{ {
/* No need to call lazy open, as the data must already have been /* No need to call lazy open, as the data must already have been
mapped. */ mapped. */
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;
...@@ -683,7 +685,9 @@ delete_copyout (unsigned f, void *h, size_t s, int async, const char *libfnname) ...@@ -683,7 +685,9 @@ delete_copyout (unsigned f, void *h, size_t s, int async, const char *libfnname)
gomp_fatal ("Dynamic reference counting assert fail\n"); gomp_fatal ("Dynamic reference counting assert fail\n");
} }
if (f & FLAG_FINALIZE) bool finalize = (kind == GOMP_MAP_DELETE
|| kind == GOMP_MAP_FORCE_FROM);
if (finalize)
{ {
if (n->refcount != REFCOUNT_INFINITY) if (n->refcount != REFCOUNT_INFINITY)
n->refcount -= n->dynamic_refcount; n->refcount -= n->dynamic_refcount;
...@@ -700,7 +704,9 @@ delete_copyout (unsigned f, void *h, size_t s, int async, const char *libfnname) ...@@ -700,7 +704,9 @@ delete_copyout (unsigned f, void *h, size_t s, int async, const char *libfnname)
{ {
goacc_aq aq = get_goacc_asyncqueue (async); goacc_aq aq = get_goacc_asyncqueue (async);
if (f & FLAG_COPYOUT) bool copyout = (kind == GOMP_MAP_FROM
|| kind == GOMP_MAP_FORCE_FROM);
if (copyout)
{ {
void *d = (void *) (n->tgt->tgt_start + n->tgt_offset void *d = (void *) (n->tgt->tgt_start + n->tgt_offset
+ (uintptr_t) h - n->host_start); + (uintptr_t) h - n->host_start);
...@@ -733,50 +739,49 @@ delete_copyout (unsigned f, void *h, size_t s, int async, const char *libfnname) ...@@ -733,50 +739,49 @@ delete_copyout (unsigned f, void *h, size_t s, int async, const char *libfnname)
void void
acc_delete (void *h , size_t s) acc_delete (void *h , size_t s)
{ {
delete_copyout (0, h, s, acc_async_sync, __FUNCTION__); goacc_exit_data (h, s, GOMP_MAP_RELEASE, acc_async_sync);
} }
void void
acc_delete_async (void *h , size_t s, int async) acc_delete_async (void *h , size_t s, int async)
{ {
delete_copyout (0, h, s, async, __FUNCTION__); goacc_exit_data (h, s, GOMP_MAP_RELEASE, async);
} }
void void
acc_delete_finalize (void *h , size_t s) acc_delete_finalize (void *h , size_t s)
{ {
delete_copyout (FLAG_FINALIZE, h, s, acc_async_sync, __FUNCTION__); goacc_exit_data (h, s, GOMP_MAP_DELETE, acc_async_sync);
} }
void void
acc_delete_finalize_async (void *h , size_t s, int async) acc_delete_finalize_async (void *h , size_t s, int async)
{ {
delete_copyout (FLAG_FINALIZE, h, s, async, __FUNCTION__); goacc_exit_data (h, s, GOMP_MAP_DELETE, async);
} }
void void
acc_copyout (void *h, size_t s) acc_copyout (void *h, size_t s)
{ {
delete_copyout (FLAG_COPYOUT, h, s, acc_async_sync, __FUNCTION__); goacc_exit_data (h, s, GOMP_MAP_FROM, acc_async_sync);
} }
void void
acc_copyout_async (void *h, size_t s, int async) acc_copyout_async (void *h, size_t s, int async)
{ {
delete_copyout (FLAG_COPYOUT, h, s, async, __FUNCTION__); goacc_exit_data (h, s, GOMP_MAP_FROM, async);
} }
void void
acc_copyout_finalize (void *h, size_t s) acc_copyout_finalize (void *h, size_t s)
{ {
delete_copyout (FLAG_COPYOUT | FLAG_FINALIZE, h, s, acc_async_sync, goacc_exit_data (h, s, GOMP_MAP_FORCE_FROM, acc_async_sync);
__FUNCTION__);
} }
void void
acc_copyout_finalize_async (void *h, size_t s, int async) acc_copyout_finalize_async (void *h, size_t s, int async)
{ {
delete_copyout (FLAG_COPYOUT | FLAG_FINALIZE, h, s, async, __FUNCTION__); goacc_exit_data (h, s, GOMP_MAP_FORCE_FROM, async);
} }
static void static void
......
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