Index: openmp/tools/multiplex/ompt-multiplex.h =================================================================== --- openmp/tools/multiplex/ompt-multiplex.h +++ openmp/tools/multiplex/ompt-multiplex.h @@ -30,6 +30,7 @@ static ompt_set_callback_t ompt_multiplex_set_callback; static ompt_get_task_info_t ompt_multiplex_get_task_info; +static ompt_get_unique_id_t ompt_multiplex_get_unique_id; static ompt_get_thread_data_t ompt_multiplex_get_thread_data; static ompt_get_parallel_info_t ompt_multiplex_get_parallel_info; @@ -63,9 +64,6 @@ macro(callback_task_create, ompt_callback_task_create_t, 5); \ macro(callback_task_schedule, ompt_callback_task_schedule_t, 6); \ macro(callback_implicit_task, ompt_callback_implicit_task_t, 7); \ - macro(callback_target, ompt_callback_target_t, 8); \ - macro(callback_target_data_op, ompt_callback_target_data_op_t, 9); \ - macro(callback_target_submit, ompt_callback_target_submit_t, 10); \ macro(callback_control_tool, ompt_callback_control_tool_t, 11); \ macro(callback_device_initialize, ompt_callback_device_initialize_t, 12); \ macro(callback_device_finalize, ompt_callback_device_finalize_t, 13); \ @@ -77,7 +75,6 @@ macro(callback_task_dependence, ompt_callback_task_dependence_t, 19); \ macro(callback_work, ompt_callback_work_t, 20); \ macro(callback_masked, ompt_callback_masked_t, 21); \ - macro(callback_target_map, ompt_callback_target_map_t, 22); \ macro(callback_sync_region, ompt_callback_sync_region_t, 23); \ macro(callback_lock_init, ompt_callback_mutex_acquire_t, 24); \ macro(callback_lock_destroy, ompt_callback_mutex_t, 25); \ @@ -94,11 +91,17 @@ macro(callback_target_map_emi, ompt_callback_target_map_emi_t, 36); \ macro(callback_error, ompt_callback_error_t, 37); +#define OMPT_LOAD_CLIENT_FOREACH_OMPT_EVENT_NOEMI(macro) \ + macro(callback_target, ompt_callback_target_t, 8); \ + macro(callback_target_data_op, ompt_callback_target_data_op_t, 9); \ + macro(callback_target_submit, ompt_callback_target_submit_t, 10); \ + macro(callback_target_map, ompt_callback_target_map_t, 22); typedef struct ompt_multiplex_callbacks_s { #define ompt_event_macro(event, callback, eventid) callback ompt_##event OMPT_LOAD_CLIENT_FOREACH_OMPT_EVENT(ompt_event_macro) + OMPT_LOAD_CLIENT_FOREACH_OMPT_EVENT_NOEMI(ompt_event_macro) #undef ompt_event_macro } ompt_multiplex_callbacks_t; @@ -107,6 +110,7 @@ #define ompt_event_macro(event, callback, eventid) int ompt_##event OMPT_LOAD_CLIENT_FOREACH_OMPT_EVENT(ompt_event_macro) + OMPT_LOAD_CLIENT_FOREACH_OMPT_EVENT_NOEMI(ompt_event_macro) #undef ompt_event_macro } ompt_multiplex_callback_implementation_status_t; @@ -852,6 +856,27 @@ } } +static void ompt_callback_target_emi_wrapper_own( + ompt_target_t kind, ompt_scope_endpoint_t endpoint, int device_num, + ompt_data_t *task_data, ompt_data_t *target_task_data, + ompt_data_t *target_data, const void *codeptr_ra) { + if (endpoint == ompt_scope_begin || endpoint == ompt_scope_beginend) { + target_data->value = ompt_multiplex_get_unique_id(); + } + ompt_multiplex_own_callbacks.ompt_callback_target( + kind, endpoint, device_num, task_data, target_data->value, codeptr_ra); +} + +static void ompt_callback_target_emi_wrapper_client( + ompt_target_t kind, ompt_scope_endpoint_t endpoint, int device_num, + ompt_data_t *task_data, ompt_data_t *target_task_data, + ompt_data_t *target_data, const void *codeptr_ra) { + if (endpoint == ompt_scope_begin || endpoint == ompt_scope_beginend) { + target_data->value = ompt_multiplex_get_unique_id(); + } + ompt_multiplex_client_callbacks.ompt_callback_target( + kind, endpoint, device_num, task_data, target_data->value, codeptr_ra); +} static void ompt_multiplex_callback_target_emi( ompt_target_t kind, ompt_scope_endpoint_t endpoint, int device_num, @@ -930,6 +955,40 @@ } } +static void ompt_callback_target_data_op_emi_wrapper_own( + ompt_scope_endpoint_t endpoint, ompt_data_t *target_task_data, + ompt_data_t *target_data, ompt_id_t *host_op_id, + ompt_target_data_op_t optype, void *src_addr, int src_device_num, + void *dest_addr, int dest_device_num, size_t bytes, + const void *codeptr_ra) { + if (endpoint == ompt_scope_begin || endpoint == ompt_scope_beginend) { + if (*host_op_id == 0) + *host_op_id = ompt_multiplex_get_unique_id(); + } + if (endpoint == ompt_scope_end || endpoint == ompt_scope_beginend) { + ompt_multiplex_own_callbacks.ompt_callback_target_data_op( + target_data->value, *host_op_id, optype, src_addr, src_device_num, + dest_addr, dest_device_num, bytes, codeptr_ra); + } +} + +static void ompt_callback_target_data_op_emi_wrapper_client( + ompt_scope_endpoint_t endpoint, ompt_data_t *target_task_data, + ompt_data_t *target_data, ompt_id_t *host_op_id, + ompt_target_data_op_t optype, void *src_addr, int src_device_num, + void *dest_addr, int dest_device_num, size_t bytes, + const void *codeptr_ra) { + if (endpoint == ompt_scope_begin || endpoint == ompt_scope_beginend) { + if (*host_op_id == 0) + *host_op_id = ompt_multiplex_get_unique_id(); + } + if (endpoint == ompt_scope_end || endpoint == ompt_scope_beginend) { + ompt_multiplex_client_callbacks.ompt_callback_target_data_op( + target_data->value, *host_op_id, optype, src_addr, src_device_num, + dest_addr, dest_device_num, bytes, codeptr_ra); + } +} + static void ompt_multiplex_callback_target_data_op_emi( ompt_scope_endpoint_t endpoint, ompt_data_t *target_task_data, ompt_data_t *target_data, ompt_id_t *host_op_id, @@ -952,6 +1011,28 @@ } } +static void ompt_callback_target_submit_emi_wrapper_own( + ompt_scope_endpoint_t endpoint, ompt_data_t *target_data, + ompt_id_t *host_op_id, unsigned int requested_num_teams) { + if (endpoint == ompt_scope_begin || endpoint == ompt_scope_beginend) { + if (*host_op_id == 0) + *host_op_id = ompt_multiplex_get_unique_id(); + ompt_multiplex_own_callbacks.ompt_callback_target_submit( + target_data->value, *host_op_id, requested_num_teams); + } +} + +static void ompt_callback_target_submit_emi_wrapper_client( + ompt_scope_endpoint_t endpoint, ompt_data_t *target_data, + ompt_id_t *host_op_id, unsigned int requested_num_teams) { + if (endpoint == ompt_scope_begin || endpoint == ompt_scope_beginend) { + if (*host_op_id == 0) + *host_op_id = ompt_multiplex_get_unique_id(); + ompt_multiplex_client_callbacks.ompt_callback_target_submit( + target_data->value, *host_op_id, requested_num_teams); + } +} + static void ompt_multiplex_callback_target_submit_emi( ompt_scope_endpoint_t endpoint, ompt_data_t *target_data, ompt_id_t *host_op_id, unsigned int requested_num_teams) { @@ -967,6 +1048,24 @@ } } +static void ompt_callback_target_map_emi_wrapper_own( + ompt_data_t *target_data, unsigned int nitems, void **host_addr, + void **device_addr, size_t *bytes, unsigned int *mapping_flags, + const void *codeptr_ra) { + ompt_multiplex_own_callbacks.ompt_callback_target_map( + target_data->value, nitems, host_addr, device_addr, bytes, mapping_flags, + codeptr_ra); +} + +static void ompt_callback_target_map_emi_wrapper_client( + ompt_data_t *target_data, unsigned int nitems, void **host_addr, + void **device_addr, size_t *bytes, unsigned int *mapping_flags, + const void *codeptr_ra) { + ompt_multiplex_client_callbacks.ompt_callback_target_map( + target_data->value, nitems, host_addr, device_addr, bytes, mapping_flags, + codeptr_ra); +} + static void ompt_multiplex_callback_target_map_emi( ompt_data_t *target_data, unsigned int nitems, void **host_addr, void **device_addr, size_t *bytes, unsigned int *mapping_flags, @@ -996,7 +1095,6 @@ } } - // runtime entry functions int ompt_multiplex_own_get_task_info(int ancestor_level, int *type, @@ -1108,6 +1206,23 @@ #undef ompt_event_macro +#define ompt_event_macro(event_name, callback_type, event_id) \ + case ompt_##event_name: \ + ompt_multiplex_own_callbacks.ompt_##event_name = (callback_type)callback; \ + ompt_multiplex_own_callbacks.ompt_##event_name##_emi = \ + ompt_##event_name##_emi_wrapper_own; \ + if (ompt_multiplex_implementation_status.ompt_##event_name##_emi == -1) \ + return ompt_multiplex_implementation_status.ompt_##event_name##_emi = \ + ompt_multiplex_set_callback( \ + ompt_##event_name##_emi, \ + (ompt_callback_t)&ompt_multiplex_##event_name##_emi); \ + else \ + return ompt_multiplex_implementation_status.ompt_##event_name##_emi + + OMPT_LOAD_CLIENT_FOREACH_OMPT_EVENT_NOEMI(ompt_event_macro) + +#undef ompt_event_macro + default: return ompt_set_error; } @@ -1134,6 +1249,24 @@ #undef ompt_event_macro +#define ompt_event_macro(event_name, callback_type, event_id) \ + case ompt_##event_name: \ + ompt_multiplex_client_callbacks.ompt_##event_name = \ + (callback_type)callback; \ + ompt_multiplex_client_callbacks.ompt_##event_name##_emi = \ + ompt_##event_name##_emi_wrapper_client; \ + if (ompt_multiplex_implementation_status.ompt_##event_name##_emi == -1) \ + return ompt_multiplex_implementation_status.ompt_##event_name##_emi = \ + ompt_multiplex_set_callback( \ + ompt_##event_name##_emi, \ + (ompt_callback_t)&ompt_multiplex_##event_name##_emi); \ + else \ + return ompt_multiplex_implementation_status.ompt_##event_name##_emi + + OMPT_LOAD_CLIENT_FOREACH_OMPT_EVENT_NOEMI(ompt_event_macro) + +#undef ompt_event_macro + default: return ompt_set_error; } @@ -1172,6 +1305,8 @@ (ompt_set_callback_t)lookup("ompt_set_callback"); ompt_multiplex_get_task_info = (ompt_get_task_info_t)lookup("ompt_get_task_info"); + ompt_multiplex_get_unique_id = + (ompt_get_unique_id_t)lookup("ompt_get_unique_id"); ompt_multiplex_get_thread_data = (ompt_get_thread_data_t)lookup("ompt_get_thread_data"); ompt_multiplex_get_parallel_info =