diff options
author | Thomas Schwinge <thomas@codesourcery.com> | 2019-05-17 21:13:36 +0200 |
---|---|---|
committer | Thomas Schwinge <tschwinge@gcc.gnu.org> | 2019-05-17 21:13:36 +0200 |
commit | 5fae049dc272144f8e61af94ee0ba42b270915e5 (patch) | |
tree | 6108e18ecb0a9f9190bb4d03730bba8cd80654f1 /libgomp/oacc-async.c | |
parent | b48f44bf77a39fefc238a16cf1225c6464c82406 (diff) |
OpenACC Profiling Interface (incomplete)
libgomp/
* acc_prof.h: New file.
* oacc-profiling.c: Likewise.
* Makefile.am (nodist_libsubinclude_HEADERS, libgomp_la_SOURCES):
Add these, respectively.
* Makefile.in: Regenerate.
* env.c (initialize_env): Call goacc_profiling_initialize.
* oacc-plugin.c (GOMP_PLUGIN_goacc_thread)
(GOMP_PLUGIN_goacc_profiling_dispatch): New functions.
* oacc-plugin.h (GOMP_PLUGIN_goacc_thread)
(GOMP_PLUGIN_goacc_profiling_dispatch): Declare.
* libgomp.map (OACC_2.5.1): Add acc_prof_lookup,
acc_prof_register, acc_prof_unregister, and acc_register_library.
(GOMP_PLUGIN_1.3): Add GOMP_PLUGIN_goacc_profiling_dispatch, and
GOMP_PLUGIN_goacc_thread.
* oacc-int.h (struct goacc_thread): Add prof_info, api_info,
prof_callbacks_enabled members.
(goacc_prof_enabled, goacc_profiling_initialize)
(_goacc_profiling_dispatch_p, _goacc_profiling_setup_p)
(goacc_profiling_dispatch): Declare.
(GOACC_PROF_ENABLED, GOACC_PROFILING_DISPATCH_P)
(GOACC_PROFILING_SETUP_P): Define.
* oacc-async.c (acc_async_test, acc_async_test_all, acc_wait)
(acc_wait_async, acc_wait_all, acc_wait_all_async): Update for
OpenACC Profiling Interface.
* oacc-cuda.c (acc_get_current_cuda_device)
(acc_get_current_cuda_context, acc_get_cuda_stream)
(acc_set_cuda_stream): Likewise.
* oacc-init.c (acc_init_1, goacc_attach_host_thread_to_device)
(acc_init, acc_set_device_type, acc_get_device_type)
(acc_get_device_num, goacc_lazy_initialize): Likewise.
* oacc-mem.c (acc_malloc, acc_free, memcpy_tofrom_device)
(acc_deviceptr, acc_hostptr, acc_is_present, acc_map_data)
(acc_unmap_data, present_create_copy, delete_copyout)
(update_dev_host): Likewise.
* oacc-parallel.c (GOACC_parallel_keyed, GOACC_data_start)
(GOACC_data_end, GOACC_enter_exit_data, GOACC_update, GOACC_wait):
Likewise.
* plugin/plugin-nvptx.c (nvptx_exec, nvptx_alloc, nvptx_free)
(GOMP_OFFLOAD_openacc_exec, GOMP_OFFLOAD_openacc_async_exec):
Likewise.
* libgomp.texi: Update.
* testsuite/libgomp.oacc-c-c++-common/acc_prof-dispatch-1.c: New
file.
* testsuite/libgomp.oacc-c-c++-common/acc_prof-init-1.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/acc_prof-kernels-1.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/acc_prof-parallel-1.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/acc_prof-valid_bytes-1.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/acc_prof-version-1.c:
Likewise.
From-SVN: r271346
Diffstat (limited to 'libgomp/oacc-async.c')
-rw-r--r-- | libgomp/oacc-async.c | 121 |
1 files changed, 100 insertions, 21 deletions
diff --git a/libgomp/oacc-async.c b/libgomp/oacc-async.c index 51bb676610c..1760e8c90c6 100644 --- a/libgomp/oacc-async.c +++ b/libgomp/oacc-async.c @@ -43,17 +43,6 @@ get_goacc_thread (void) return thr; } -static struct gomp_device_descr * -get_goacc_thread_device (void) -{ - struct goacc_thread *thr = goacc_thread (); - - if (!thr || !thr->dev) - gomp_fatal ("no device active"); - - return thr->dev; -} - static int validate_async_val (int async) { @@ -76,7 +65,10 @@ validate_async_val (int async) /* Return the asyncqueue to be used for OpenACC async-argument ASYNC. This might return NULL if no asyncqueue is to be used. Otherwise, if CREATE, - create the asyncqueue if it doesn't exist yet. */ + create the asyncqueue if it doesn't exist yet. + + Unless CREATE, this will not generate any OpenACC Profiling Interface + events. */ attribute_hidden struct goacc_asyncqueue * lookup_goacc_asyncqueue (struct goacc_thread *thr, bool create, int async) @@ -152,8 +144,25 @@ acc_async_test (int async) goacc_aq aq = lookup_goacc_asyncqueue (thr, false, async); if (!aq) return 1; - else - return thr->dev->openacc.async.test_func (aq); + + 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; + } + + int res = thr->dev->openacc.async.test_func (aq); + + if (profiling_p) + { + thr->prof_info = NULL; + thr->api_info = NULL; + } + + return res; } int @@ -161,6 +170,10 @@ acc_async_test_all (void) { struct goacc_thread *thr = get_goacc_thread (); + acc_prof_info prof_info; + acc_api_info api_info; + bool profiling_p = GOACC_PROFILING_SETUP_P (thr, &prof_info, &api_info); + int ret = 1; gomp_mutex_lock (&thr->dev->openacc.async.lock); for (goacc_aq_list l = thr->dev->openacc.async.active; l; l = l->next) @@ -170,6 +183,13 @@ acc_async_test_all (void) break; } gomp_mutex_unlock (&thr->dev->openacc.async.lock); + + if (profiling_p) + { + thr->prof_info = NULL; + thr->api_info = NULL; + } + return ret; } @@ -179,8 +199,26 @@ acc_wait (int async) struct goacc_thread *thr = get_goacc_thread (); goacc_aq aq = lookup_goacc_asyncqueue (thr, false, async); - if (aq && !thr->dev->openacc.async.synchronize_func (aq)) + if (!aq) + return; + + 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 (!thr->dev->openacc.async.synchronize_func (aq)) gomp_fatal ("wait on %d failed", async); + + if (profiling_p) + { + thr->prof_info = NULL; + thr->api_info = NULL; + } } /* acc_async_wait is an OpenACC 1.0 compatibility name for acc_wait. */ @@ -205,10 +243,19 @@ acc_wait_async (int async1, int async2) if (!aq1) return; + 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 = async2; + prof_info.async_queue = prof_info.async; + } + goacc_aq aq2 = lookup_goacc_asyncqueue (thr, true, async2); /* An async queue is always synchronized with itself. */ if (aq1 == aq2) - return; + goto out_prof; if (aq2) { @@ -222,18 +269,35 @@ acc_wait_async (int async1, int async2) if (!thr->dev->openacc.async.synchronize_func (aq1)) gomp_fatal ("wait on %d failed", async1); } + + out_prof: + if (profiling_p) + { + thr->prof_info = NULL; + thr->api_info = NULL; + } } void acc_wait_all (void) { - struct gomp_device_descr *dev = get_goacc_thread_device (); + struct goacc_thread *thr = goacc_thread (); + + acc_prof_info prof_info; + acc_api_info api_info; + bool profiling_p = GOACC_PROFILING_SETUP_P (thr, &prof_info, &api_info); bool ret = true; - gomp_mutex_lock (&dev->openacc.async.lock); - for (goacc_aq_list l = dev->openacc.async.active; l; l = l->next) - ret &= dev->openacc.async.synchronize_func (l->aq); - gomp_mutex_unlock (&dev->openacc.async.lock); + gomp_mutex_lock (&thr->dev->openacc.async.lock); + for (goacc_aq_list l = thr->dev->openacc.async.active; l; l = l->next) + ret &= thr->dev->openacc.async.synchronize_func (l->aq); + gomp_mutex_unlock (&thr->dev->openacc.async.lock); + + if (profiling_p) + { + thr->prof_info = NULL; + thr->api_info = NULL; + } if (!ret) gomp_fatal ("wait all failed"); @@ -255,6 +319,15 @@ acc_wait_all_async (int async) { struct goacc_thread *thr = get_goacc_thread (); + 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; + } + goacc_aq waiting_queue = lookup_goacc_asyncqueue (thr, true, async); bool ret = true; @@ -270,6 +343,12 @@ acc_wait_all_async (int async) } gomp_mutex_unlock (&thr->dev->openacc.async.lock); + if (profiling_p) + { + thr->prof_info = NULL; + thr->api_info = NULL; + } + if (!ret) gomp_fatal ("wait all async(%d) failed", async); } |