gomp_mutex_unlock (&acc_dev->lock);
}
-struct async_prof_callback_info *
-queue_async_prof_dispatch (struct gomp_device_descr *devicep, goacc_aq aq,
- acc_prof_info *prof_info, acc_event_info *event_info,
- acc_api_info *api_info,
- struct async_prof_callback_info *prev_info);
-
static void
goacc_enter_exit_data_internal (int flags_m, size_t mapnum, void **hostaddrs,
size_t *sizes, unsigned short *kinds,
struct goacc_thread *thr;
struct gomp_device_descr *acc_dev;
- struct async_prof_callback_info *data_start_info = NULL;
goacc_lazy_initialize ();
api_info.async_handle = NULL;
}
- goacc_aq aq = get_goacc_asyncqueue (async);
-
if (profiling_p)
- {
- if (aq)
- data_start_info
- = queue_async_prof_dispatch (acc_dev, aq, &prof_info,
- &enter_exit_data_event_info, &api_info,
- NULL);
- else
- goacc_profiling_dispatch (&prof_info, &enter_exit_data_event_info,
- &api_info);
- }
+ goacc_profiling_dispatch (&prof_info, &enter_exit_data_event_info,
+ &api_info);
if ((acc_dev->capabilities & GOMP_OFFLOAD_CAP_SHARED_MEM)
|| (flags & GOACC_FLAG_HOST_FALLBACK))
if (num_waits)
goacc_wait (async, num_waits, ap);
+ goacc_aq aq = get_goacc_asyncqueue (async);
+
if (data_enter)
goacc_enter_data_internal (acc_dev, mapnum, hostaddrs, sizes, kinds, aq);
else
prof_info.event_type
= data_enter ? acc_ev_enter_data_end : acc_ev_exit_data_end;
enter_exit_data_event_info.other_event.event_type = prof_info.event_type;
- if (aq)
- queue_async_prof_dispatch (acc_dev, aq, &prof_info,
- &enter_exit_data_event_info, &api_info,
- data_start_info);
- else
- goacc_profiling_dispatch (&prof_info, &enter_exit_data_event_info,
- &api_info);
+ goacc_profiling_dispatch (&prof_info, &enter_exit_data_event_info,
+ &api_info);
thr->prof_info = NULL;
thr->api_info = NULL;
}
-struct async_prof_callback_info {
- acc_prof_info prof_info;
- acc_event_info event_info;
- acc_api_info api_info;
- struct async_prof_callback_info *start_info;
-};
-
-static void
-async_prof_dispatch (void *ptr)
-{
- struct async_prof_callback_info *info
- = (struct async_prof_callback_info *) ptr;
-
- if (info->start_info)
- {
- /* The TOOL_INFO must be preserved from a start event to the
- corresponding end event. Copy that here. */
- void *tool_info = info->start_info->event_info.other_event.tool_info;
- info->event_info.other_event.tool_info = tool_info;
- }
-
- goacc_profiling_dispatch (&info->prof_info, &info->event_info,
- &info->api_info);
-
- /* The async_prof_dispatch function is (so far) always used for start/end
- profiling event pairs: the start and end parts are queued, then each is
- dispatched (or the dispatches might be interleaved before the end part is
- queued).
- In any case, it's not safe to delete either info structure before the
- whole bracketed event is complete. */
-
- if (info->start_info)
- {
- free (info->start_info);
- free (info);
- }
-}
-
-struct async_prof_callback_info *
-queue_async_prof_dispatch (struct gomp_device_descr *devicep, goacc_aq aq,
- acc_prof_info *prof_info, acc_event_info *event_info,
- acc_api_info *api_info,
- struct async_prof_callback_info *prev_info)
-{
- struct async_prof_callback_info *info = malloc (sizeof (*info));
-
- info->prof_info = *prof_info;
- info->event_info = *event_info;
- info->api_info = *api_info;
- info->start_info = prev_info;
-
- devicep->openacc.async.queue_callback_func (aq, async_prof_dispatch,
- (void *) info);
- return info;
-}
-
/* Launch a possibly offloaded function with FLAGS. FN is the host fn
address. MAPNUM, HOSTADDRS, SIZES & KINDS describe the memory
blocks to be copied to/from the device. Varadic arguments are
unsigned dims[GOMP_DIM_MAX];
unsigned tag;
struct goacc_ncarray_info *nca_info = NULL;
- struct async_prof_callback_info *comp_start_info = NULL,
- *data_start_info = NULL;
#ifdef HAVE_INTTYPES_H
gomp_debug (0, "%s: mapnum=%"PRIu64", hostaddrs=%p, size=%p, kinds=%p\n",
api_info.async_handle = NULL;
}
+ if (profiling_p)
+ goacc_profiling_dispatch (&prof_info, &compute_construct_event_info,
+ &api_info);
+
handle_ftn_pointers (mapnum, hostaddrs, sizes, kinds);
+ /* Host fallback if "if" clause is false or if the current device is set to
+ the host. */
+ if (flags & GOACC_FLAG_HOST_FALLBACK)
+ {
+ prof_info.device_type = acc_device_host;
+ api_info.device_type = prof_info.device_type;
+ goacc_save_and_set_bind (acc_device_host);
+ fn (hostaddrs);
+ goacc_restore_bind ();
+ goto out_prof;
+ }
+ else if (acc_device_type (acc_dev->type) == acc_device_host)
+ {
+ fn (hostaddrs);
+ goto out_prof;
+ }
+ else if (profiling_p)
+ api_info.device_api = acc_device_api_cuda;
+
/* Default: let the runtime choose. */
for (i = 0; i != GOMP_DIM_MAX; i++)
dims[i] = 0;
if (async == GOMP_LAUNCH_OP_MAX)
async = va_arg (ap, unsigned);
- /* Set async number in profiling data, unless the device is the
- host or we're doing host fallback. */
- if (profiling_p
- && !(flags & GOACC_FLAG_HOST_FALLBACK)
- && acc_device_type (acc_dev->type) != acc_device_host)
- prof_info.async = prof_info.async_queue = async;
+ if (profiling_p)
+ {
+ prof_info.async = async;
+ prof_info.async_queue = prof_info.async;
+ }
break;
}
va_end (ap);
- goacc_aq aq = get_goacc_asyncqueue (async);
-
- if (profiling_p)
- {
- if (aq)
- comp_start_info
- = queue_async_prof_dispatch (acc_dev, aq, &prof_info,
- &compute_construct_event_info,
- &api_info, NULL);
- else
- goacc_profiling_dispatch (&prof_info, &compute_construct_event_info,
- &api_info);
- }
-
- /* Host fallback if "if" clause is false or if the current device is set to
- the host. */
- if (flags & GOACC_FLAG_HOST_FALLBACK)
- {
- prof_info.device_type = acc_device_host;
- api_info.device_type = prof_info.device_type;
- goacc_save_and_set_bind (acc_device_host);
- fn (hostaddrs);
- goacc_restore_bind ();
- goto out_prof;
- }
- else if (acc_device_type (acc_dev->type) == acc_device_host)
- {
- fn (hostaddrs);
- goto out_prof;
- }
- else if (profiling_p)
- api_info.device_api = acc_device_api_cuda;
-
if (!(acc_dev->capabilities & GOMP_OFFLOAD_CAP_NATIVE_EXEC))
{
k.host_start = (uintptr_t) fn;
= compute_construct_event_info.other_event.parent_construct;
enter_exit_data_event_info.other_event.implicit = 1;
enter_exit_data_event_info.other_event.tool_info = NULL;
- if (aq)
- data_start_info
- = queue_async_prof_dispatch (acc_dev, aq, &prof_info,
- &enter_exit_data_event_info, &api_info,
- NULL);
- else
- goacc_profiling_dispatch (&prof_info, &enter_exit_data_event_info,
- &api_info);
+ goacc_profiling_dispatch (&prof_info, &enter_exit_data_event_info,
+ &api_info);
}
+ goacc_aq aq = get_goacc_asyncqueue (async);
+
tgt = gomp_map_vars_openacc (acc_dev, aq, mapnum, hostaddrs, sizes, kinds,
nca_info);
free (nca_info);
prof_info.event_type = acc_ev_enter_data_end;
enter_exit_data_event_info.other_event.event_type
= prof_info.event_type;
- if (aq)
- queue_async_prof_dispatch (acc_dev, aq, &prof_info,
- &enter_exit_data_event_info, &api_info,
- data_start_info);
- else
- goacc_profiling_dispatch (&prof_info, &enter_exit_data_event_info,
- &api_info);
+ goacc_profiling_dispatch (&prof_info, &enter_exit_data_event_info,
+ &api_info);
}
devaddrs = gomp_alloca (sizeof (void *) * mapnum);
prof_info.event_type = acc_ev_exit_data_start;
enter_exit_data_event_info.other_event.event_type = prof_info.event_type;
enter_exit_data_event_info.other_event.tool_info = NULL;
- if (aq)
- data_start_info
- = queue_async_prof_dispatch (acc_dev, aq, &prof_info,
- &enter_exit_data_event_info, &api_info,
- NULL);
- else
- goacc_profiling_dispatch (&prof_info, &enter_exit_data_event_info,
- &api_info);
+ goacc_profiling_dispatch (&prof_info, &enter_exit_data_event_info,
+ &api_info);
}
/* If running synchronously (aq == NULL), this will unmap immediately. */
{
prof_info.event_type = acc_ev_exit_data_end;
enter_exit_data_event_info.other_event.event_type = prof_info.event_type;
- if (aq)
- queue_async_prof_dispatch (acc_dev, aq, &prof_info,
- &enter_exit_data_event_info, &api_info,
- data_start_info);
- else
- goacc_profiling_dispatch (&prof_info, &enter_exit_data_event_info,
- &api_info);
+ goacc_profiling_dispatch (&prof_info, &enter_exit_data_event_info,
+ &api_info);
}
out_prof:
prof_info.event_type = acc_ev_compute_construct_end;
compute_construct_event_info.other_event.event_type
= prof_info.event_type;
- if (aq)
- queue_async_prof_dispatch (acc_dev, aq, &prof_info,
- &compute_construct_event_info, &api_info,
- comp_start_info);
- else
- goacc_profiling_dispatch (&prof_info, &compute_construct_event_info,
- &api_info);
+ goacc_profiling_dispatch (&prof_info, &compute_construct_event_info,
+ &api_info);
thr->prof_info = NULL;
thr->api_info = NULL;
struct goacc_thread *thr = goacc_thread ();
struct gomp_device_descr *acc_dev = thr->dev;
- goacc_aq aq = NULL;
- struct async_prof_callback_info *update_start_info = NULL;
bool profiling_p = GOACC_PROFILING_DISPATCH_P (true);
}
if (profiling_p)
- {
- aq = get_goacc_asyncqueue (async);
- if (aq)
- update_start_info
- = queue_async_prof_dispatch (acc_dev, aq, &prof_info,
- &update_event_info, &api_info, NULL);
- else
- goacc_profiling_dispatch (&prof_info, &update_event_info, &api_info);
- }
+ goacc_profiling_dispatch (&prof_info, &update_event_info, &api_info);
if ((acc_dev->capabilities & GOMP_OFFLOAD_CAP_SHARED_MEM)
|| (flags & GOACC_FLAG_HOST_FALLBACK))
{
prof_info.event_type = acc_ev_update_end;
update_event_info.other_event.event_type = prof_info.event_type;
- if (aq)
- queue_async_prof_dispatch (acc_dev, aq, &prof_info, &update_event_info,
- &api_info, update_start_info);
- else
- goacc_profiling_dispatch (&prof_info, &update_event_info, &api_info);
+ goacc_profiling_dispatch (&prof_info, &update_event_info, &api_info);
thr->prof_info = NULL;
thr->api_info = NULL;
{
DEBUG_printf ("%s\n", __FUNCTION__);
- assert (state == 5
+ assert (state == 7
#if ASYNC_EXIT_DATA
- || state == 105
+ || state == 107
#endif
);
STATE_OP (state, ++);
{
DEBUG_printf ("%s\n", __FUNCTION__);
- assert (state == 6
+ assert (state == 8
#if ASYNC_EXIT_DATA
- || state == 106
+ || state == 108
#endif
);
STATE_OP (state, ++);
assert (prof_info->device_type == acc_device_type);
assert (prof_info->device_number == acc_device_num);
assert (prof_info->thread_id == -1);
- if (acc_device_type == acc_device_host)
- assert (prof_info->async == acc_async_sync);
- else
- assert (prof_info->async == acc_async);
+ assert (prof_info->async == /* TODO acc_async */ acc_async_sync);
assert (prof_info->async_queue == prof_info->async);
assert (prof_info->src_file == NULL);
assert (prof_info->func_name == NULL);
{
/* Compensate for the missing 'acc_ev_enter_data_end'. */
state += 1;
+ /* Compensate for the missing 'acc_ev_enqueue_launch_start' and
+ 'acc_ev_enqueue_launch_end'. */
+ state += 2;
/* Compensate for the missing 'acc_ev_exit_data_start' and
'acc_ev_exit_data_end'. */
state += 2;
state += 2;
}
#endif
- assert (state == 7
- || state == 107);
+ assert (state == 9
+ || state == 109);
STATE_OP (state, ++);
assert (tool_info != NULL);
assert (acc_device_type != acc_device_host);
+ assert (state == 5
+ || state == 105);
+ STATE_OP (state, ++);
+
+ assert (tool_info != NULL);
+ assert (tool_info->event_info.other_event.event_type == acc_ev_compute_construct_start);
+ assert (tool_info->nested == NULL);
+ tool_info->nested = (struct tool_info *) malloc(sizeof *tool_info);
+ assert (tool_info->nested != NULL);
+ tool_info->nested->nested = NULL;
+
assert (prof_info->event_type == acc_ev_enqueue_launch_start);
assert (prof_info->valid_bytes == _ACC_PROF_INFO_VALID_BYTES);
assert (prof_info->version == _ACC_PROF_INFO_VERSION);
assert (api_info->device_handle == NULL);
assert (api_info->context_handle == NULL);
assert (api_info->async_handle == NULL);
+
+ tool_info->nested->event_info.launch_event.event_type = event_info->launch_event.event_type;
+ tool_info->nested->event_info.launch_event.kernel_name = strdup (event_info->launch_event.kernel_name);
+ tool_info->nested->event_info.launch_event.num_gangs = event_info->launch_event.num_gangs;
+ tool_info->nested->event_info.launch_event.num_workers = event_info->launch_event.num_workers;
+ tool_info->nested->event_info.launch_event.vector_length = event_info->launch_event.vector_length;
+ event_info->other_event.tool_info = tool_info->nested;
}
static void cb_enqueue_launch_end (acc_prof_info *prof_info, acc_event_info *event_info, acc_api_info *api_info)
assert (acc_device_type != acc_device_host);
+ assert (state == 6
+ || state == 106);
+ STATE_OP (state, ++);
+
+ assert (tool_info != NULL);
+ assert (tool_info->event_info.other_event.event_type == acc_ev_compute_construct_start);
+ assert (tool_info->nested != NULL);
+ assert (tool_info->nested->event_info.launch_event.event_type == acc_ev_enqueue_launch_start);
+ assert (tool_info->nested->event_info.launch_event.kernel_name != NULL);
+ assert (tool_info->nested->event_info.launch_event.num_gangs >= 1);
+ assert (tool_info->nested->event_info.launch_event.num_workers >= 1);
+ assert (tool_info->nested->event_info.launch_event.vector_length >= 1);
+
assert (prof_info->event_type == acc_ev_enqueue_launch_end);
assert (prof_info->valid_bytes == _ACC_PROF_INFO_VALID_BYTES);
assert (prof_info->version == _ACC_PROF_INFO_VERSION);
assert (event_info->launch_event.valid_bytes == _ACC_LAUNCH_EVENT_INFO_VALID_BYTES);
assert (event_info->launch_event.parent_construct == acc_construct_parallel);
assert (event_info->launch_event.implicit == 1);
+ assert (event_info->launch_event.tool_info == tool_info->nested);
assert (event_info->launch_event.kernel_name != NULL);
+ assert (strcmp (event_info->launch_event.kernel_name, tool_info->nested->event_info.launch_event.kernel_name) == 0);
+ assert (event_info->launch_event.num_gangs == tool_info->nested->event_info.launch_event.num_gangs);
+ assert (event_info->launch_event.num_workers == tool_info->nested->event_info.launch_event.num_workers);
+ assert (event_info->launch_event.vector_length == tool_info->nested->event_info.launch_event.vector_length);
if (acc_device_type == acc_device_host)
assert (api_info->device_api == acc_device_api_none);
assert (api_info->device_handle == NULL);
assert (api_info->context_handle == NULL);
assert (api_info->async_handle == NULL);
+
+ free ((void *) tool_info->nested->event_info.launch_event.kernel_name);
+ free (tool_info->nested);
+ tool_info->nested = NULL;
}
}
assert (state_init == 4);
}
- assert (state == 8);
+ assert (state == 10);
STATE_OP (state, = 100);
#pragma acc wait
assert (state_init == 104);
}
- assert (state == 108);
+ assert (state == 110);
return 0;
}