summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Schwinge <thomas@codesourcery.com>2019-12-11 17:49:08 +0100
committerThomas Schwinge <tschwinge@gcc.gnu.org>2019-12-11 17:49:08 +0100
commitc5578b56b632bb21aac5dfdab09c3d24aba41c44 (patch)
treeb5db9791c7d903505188ae82bee3a60402d4af1e
parent3d1b5e710e5573416bb13113b6593307e6b008e2 (diff)
[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
-rw-r--r--libgomp/ChangeLog5
-rw-r--r--libgomp/libgomp_g.h5
-rw-r--r--libgomp/oacc-async.c71
-rw-r--r--libgomp/oacc-int.h1
-rw-r--r--libgomp/oacc-parallel.c72
5 files changed, 81 insertions, 73 deletions
diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog
index 404722e20e3..f7d9ae98616 100644
--- a/libgomp/ChangeLog
+++ b/libgomp/ChangeLog
@@ -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.
diff --git a/libgomp/libgomp_g.h b/libgomp/libgomp_g.h
index dfb55fb66dc..beb1689180d 100644
--- a/libgomp/libgomp_g.h
+++ b/libgomp/libgomp_g.h
@@ -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 *);
diff --git a/libgomp/oacc-async.c b/libgomp/oacc-async.c
index 2b24ae7adc2..6dfc3bdeb8e 100644
--- a/libgomp/oacc-async.c
+++ b/libgomp/oacc-async.c
@@ -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)
diff --git a/libgomp/oacc-int.h b/libgomp/oacc-int.h
index 9dc6c8a5713..81cb15c605f 100644
--- a/libgomp/oacc-int.h
+++ b/libgomp/oacc-int.h
@@ -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 *,
diff --git a/libgomp/oacc-parallel.c b/libgomp/oacc-parallel.c
index 68a60de24fa..1faca5d562f 100644
--- a/libgomp/oacc-parallel.c
+++ b/libgomp/oacc-parallel.c
@@ -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). */