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.
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,
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 *);
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)
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 *,
}
}
-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
}
}
-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,
}
}
-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). */