[OpenACC] Consolidate 'async'/'wait' code in 'libgomp/oacc-async.c'
libgomp/ * oacc-parallel.c (GOACC_wait, goacc_wait): Move... * oacc-async.c: ... here. * oacc-int.h (goacc_wait): Declare. * libgomp_g.h: Update From-SVN: r279232
This commit is contained in:
parent
3d1b5e710e
commit
c5578b56b6
5 changed files with 81 additions and 73 deletions
|
@ -1,5 +1,10 @@
|
|||
2019-12-11 Thomas Schwinge <thomas@codesourcery.com>
|
||||
|
||||
* oacc-parallel.c (GOACC_wait, goacc_wait): Move...
|
||||
* oacc-async.c: ... here.
|
||||
* oacc-int.h (goacc_wait): Declare.
|
||||
* libgomp_g.h: Update
|
||||
|
||||
PR libgomp/92854
|
||||
* testsuite/libgomp.oacc-c-c++-common/acc_map_data-device_already-1.c:
|
||||
New file.
|
||||
|
|
|
@ -357,6 +357,10 @@ extern void GOMP_teams (unsigned int, unsigned int);
|
|||
extern void GOMP_teams_reg (void (*) (void *), void *, unsigned, unsigned,
|
||||
unsigned);
|
||||
|
||||
/* oacc-async.c */
|
||||
|
||||
extern void GOACC_wait (int, int, ...);
|
||||
|
||||
/* oacc-parallel.c */
|
||||
|
||||
extern void GOACC_parallel_keyed (int, void (*) (void *), size_t,
|
||||
|
@ -370,7 +374,6 @@ extern void GOACC_enter_exit_data (int, size_t, void **,
|
|||
size_t *, unsigned short *, int, int, ...);
|
||||
extern void GOACC_update (int, size_t, void **, size_t *,
|
||||
unsigned short *, int, int, ...);
|
||||
extern void GOACC_wait (int, int, ...);
|
||||
extern int GOACC_get_num_threads (void);
|
||||
extern int GOACC_get_thread_num (void);
|
||||
extern void GOACC_declare (int, size_t, void **, size_t *, unsigned short *);
|
||||
|
|
|
@ -354,6 +354,77 @@ acc_wait_all_async (int async)
|
|||
gomp_fatal ("wait all async(%d) failed", async);
|
||||
}
|
||||
|
||||
void
|
||||
GOACC_wait (int async, int num_waits, ...)
|
||||
{
|
||||
goacc_lazy_initialize ();
|
||||
|
||||
struct goacc_thread *thr = goacc_thread ();
|
||||
|
||||
/* No nesting. */
|
||||
assert (thr->prof_info == NULL);
|
||||
assert (thr->api_info == NULL);
|
||||
acc_prof_info prof_info;
|
||||
acc_api_info api_info;
|
||||
bool profiling_p = GOACC_PROFILING_SETUP_P (thr, &prof_info, &api_info);
|
||||
if (profiling_p)
|
||||
{
|
||||
prof_info.async = async;
|
||||
prof_info.async_queue = prof_info.async;
|
||||
}
|
||||
|
||||
if (num_waits)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start (ap, num_waits);
|
||||
goacc_wait (async, num_waits, &ap);
|
||||
va_end (ap);
|
||||
}
|
||||
else if (async == acc_async_sync)
|
||||
acc_wait_all ();
|
||||
else
|
||||
acc_wait_all_async (async);
|
||||
|
||||
if (profiling_p)
|
||||
{
|
||||
thr->prof_info = NULL;
|
||||
thr->api_info = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
attribute_hidden void
|
||||
goacc_wait (int async, int num_waits, va_list *ap)
|
||||
{
|
||||
while (num_waits--)
|
||||
{
|
||||
int qid = va_arg (*ap, int);
|
||||
|
||||
/* Waiting on ACC_ASYNC_NOVAL maps to 'wait all'. */
|
||||
if (qid == acc_async_noval)
|
||||
{
|
||||
if (async == acc_async_sync)
|
||||
acc_wait_all ();
|
||||
else
|
||||
acc_wait_all_async (async);
|
||||
break;
|
||||
}
|
||||
|
||||
if (acc_async_test (qid))
|
||||
continue;
|
||||
|
||||
if (async == acc_async_sync)
|
||||
acc_wait (qid);
|
||||
else if (qid == async)
|
||||
/* If we're waiting on the same asynchronous queue as we're
|
||||
launching on, the queue itself will order work as
|
||||
required, so there's no need to wait explicitly. */
|
||||
;
|
||||
else
|
||||
acc_wait_async (qid, async);
|
||||
}
|
||||
}
|
||||
|
||||
attribute_hidden void
|
||||
goacc_async_free (struct gomp_device_descr *devicep,
|
||||
struct goacc_asyncqueue *aq, void *ptr)
|
||||
|
|
|
@ -113,6 +113,7 @@ void goacc_restore_bind (void);
|
|||
void goacc_lazy_initialize (void);
|
||||
void goacc_host_init (void);
|
||||
|
||||
void goacc_wait (int, int, va_list *);
|
||||
void goacc_init_asyncqueues (struct gomp_device_descr *);
|
||||
bool goacc_fini_asyncqueues (struct gomp_device_descr *);
|
||||
void goacc_async_free (struct gomp_device_descr *, struct goacc_asyncqueue *,
|
||||
|
|
|
@ -111,8 +111,6 @@ handle_ftn_pointers (size_t mapnum, void **hostaddrs, size_t *sizes,
|
|||
}
|
||||
}
|
||||
|
||||
static void goacc_wait (int async, int num_waits, va_list *ap);
|
||||
|
||||
|
||||
/* Launch a possibly offloaded function with FLAGS. FN is the host fn
|
||||
address. MAPNUM, HOSTADDRS, SIZES & KINDS describe the memory
|
||||
|
@ -814,38 +812,6 @@ GOACC_enter_exit_data (int flags_m, size_t mapnum,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
goacc_wait (int async, int num_waits, va_list *ap)
|
||||
{
|
||||
while (num_waits--)
|
||||
{
|
||||
int qid = va_arg (*ap, int);
|
||||
|
||||
/* Waiting on ACC_ASYNC_NOVAL maps to 'wait all'. */
|
||||
if (qid == acc_async_noval)
|
||||
{
|
||||
if (async == acc_async_sync)
|
||||
acc_wait_all ();
|
||||
else
|
||||
acc_wait_all_async (async);
|
||||
break;
|
||||
}
|
||||
|
||||
if (acc_async_test (qid))
|
||||
continue;
|
||||
|
||||
if (async == acc_async_sync)
|
||||
acc_wait (qid);
|
||||
else if (qid == async)
|
||||
/* If we're waiting on the same asynchronous queue as we're
|
||||
launching on, the queue itself will order work as
|
||||
required, so there's no need to wait explicitly. */
|
||||
;
|
||||
else
|
||||
acc_wait_async (qid, async);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
GOACC_update (int flags_m, size_t mapnum,
|
||||
void **hostaddrs, size_t *sizes, unsigned short *kinds,
|
||||
|
@ -1002,44 +968,6 @@ GOACC_update (int flags_m, size_t mapnum,
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
GOACC_wait (int async, int num_waits, ...)
|
||||
{
|
||||
goacc_lazy_initialize ();
|
||||
|
||||
struct goacc_thread *thr = goacc_thread ();
|
||||
|
||||
/* No nesting. */
|
||||
assert (thr->prof_info == NULL);
|
||||
assert (thr->api_info == NULL);
|
||||
acc_prof_info prof_info;
|
||||
acc_api_info api_info;
|
||||
bool profiling_p = GOACC_PROFILING_SETUP_P (thr, &prof_info, &api_info);
|
||||
if (profiling_p)
|
||||
{
|
||||
prof_info.async = async;
|
||||
prof_info.async_queue = prof_info.async;
|
||||
}
|
||||
|
||||
if (num_waits)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start (ap, num_waits);
|
||||
goacc_wait (async, num_waits, &ap);
|
||||
va_end (ap);
|
||||
}
|
||||
else if (async == acc_async_sync)
|
||||
acc_wait_all ();
|
||||
else
|
||||
acc_wait_all_async (async);
|
||||
|
||||
if (profiling_p)
|
||||
{
|
||||
thr->prof_info = NULL;
|
||||
thr->api_info = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Legacy entry point (GCC 5). */
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue