From 2bb827bd90aa0231f89330cd9b9341a83e0015a3 Mon Sep 17 00:00:00 2001 From: Nathan Hjelm Date: Wed, 11 Apr 2018 10:22:03 -0600 Subject: [PATCH 01/23] Modify PERUSE code to implement MPI_T Events based on MPI 4.0 proposal. Signed-off-by: Nathan Hjelm Signed-off-by: Kingshuk Haldar --- ompi/include/mpi.h.in | 35 +- ompi/mca/osc/rdma/osc_rdma.h | 28 + ompi/mca/osc/rdma/osc_rdma_active_target.c | 16 + ompi/mca/osc/rdma/osc_rdma_comm.c | 9 +- ompi/mca/osc/rdma/osc_rdma_component.c | 83 +++ ompi/mca/osc/rdma/osc_rdma_passive_target.c | 25 + ompi/mca/pml/ob1/pml_ob1.c | 15 +- ompi/mca/pml/ob1/pml_ob1.h | 29 + ompi/mca/pml/ob1/pml_ob1_component.c | 113 +++- ompi/mca/pml/ob1/pml_ob1_irecv.c | 27 +- ompi/mca/pml/ob1/pml_ob1_isend.c | 17 +- ompi/mca/pml/ob1/pml_ob1_recvfrag.c | 48 +- ompi/mca/pml/ob1/pml_ob1_recvreq.c | 58 +- ompi/mca/pml/ob1/pml_ob1_recvreq.h | 36 +- ompi/mca/pml/ob1/pml_ob1_sendreq.c | 39 +- ompi/mca/pml/ob1/pml_ob1_sendreq.h | 10 +- ompi/mpi/tool/event_callback_get_info.c | 28 +- ompi/mpi/tool/event_callback_set_info.c | 17 +- ompi/mpi/tool/event_copy.c | 12 +- ompi/mpi/tool/event_get_index.c | 23 +- ompi/mpi/tool/event_get_info.c | 91 ++- ompi/mpi/tool/event_get_num.c | 13 +- ompi/mpi/tool/event_get_source.c | 13 +- ompi/mpi/tool/event_get_timestamp.c | 18 +- ompi/mpi/tool/event_handle_alloc.c | 37 +- ompi/mpi/tool/event_handle_free.c | 30 +- ompi/mpi/tool/event_handle_get_info.c | 27 +- ompi/mpi/tool/event_handle_set_info.c | 16 +- ompi/mpi/tool/event_read.c | 16 +- ompi/mpi/tool/event_register_callback.c | 22 +- ompi/mpi/tool/event_set_dropped_handler.c | 18 +- ompi/mpi/tool/mpit-internal.h | 7 +- ompi/mpi/tool/source_get_info.c | 47 +- ompi/mpi/tool/source_get_num.c | 13 +- ompi/mpi/tool/source_get_timestamp.c | 23 +- opal/mca/base/Makefile.am | 11 +- opal/mca/base/mca_base_event.c | 648 ++++++++++++++++++++ opal/mca/base/mca_base_event.h | 230 +++++++ opal/mca/base/mca_base_source.c | 238 +++++++ opal/mca/base/mca_base_source.h | 68 ++ opal/mca/base/mca_base_var.c | 9 + opal/mca/base/mca_base_var_enum.c | 37 ++ opal/mca/base/mca_base_var_enum.h | 3 + opal/mca/base/mca_base_var_group.c | 59 +- opal/mca/base/mca_base_var_group.h | 3 + opal/mca/base/mca_base_vari.h | 11 +- opal/runtime/opal_info_support.c | 53 +- 47 files changed, 2156 insertions(+), 273 deletions(-) create mode 100644 opal/mca/base/mca_base_event.c create mode 100644 opal/mca/base/mca_base_event.h create mode 100644 opal/mca/base/mca_base_source.c create mode 100644 opal/mca/base/mca_base_source.h diff --git a/ompi/include/mpi.h.in b/ompi/include/mpi.h.in index 15025e73391..e0b910306d9 100644 --- a/ompi/include/mpi.h.in +++ b/ompi/include/mpi.h.in @@ -454,8 +454,8 @@ typedef struct ompi_mpit_cvar_handle_t *MPI_T_cvar_handle; typedef struct mca_base_pvar_handle_t *MPI_T_pvar_handle; typedef struct mca_base_pvar_session_t *MPI_T_pvar_session; typedef struct ompi_instance_t *MPI_Session; -typedef unsigned long *MPI_T_event_instance; -typedef unsigned long *MPI_T_event_registration; +typedef struct mca_base_raised_event_t *MPI_T_event_instance; +typedef struct mca_base_event_registration_t *MPI_T_event_registration; /* * MPI_Status @@ -917,29 +917,23 @@ enum { /* * MPIT callback safety levels - * - * Values are set in configure.ac for consistency with mca_base_event.h */ -#undef OPAL_MCA_BASE_CB_REQUIRE_NONE -#undef OPAL_MCA_BASE_CB_REQUIRE_MPI_RESTRICTED -#undef OPAL_MCA_BASE_CB_REQUIRE_THREAD_SAFE -#undef OPAL_MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE typedef enum { - MPI_T_CB_REQUIRE_NONE = OPAL_MCA_BASE_CB_REQUIRE_NONE, - MPI_T_CB_REQUIRE_MPI_RESTRICTED = OPAL_MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, - MPI_T_CB_REQUIRE_THREAD_SAFE = OPAL_MCA_BASE_CB_REQUIRE_THREAD_SAFE, - MPI_T_CB_REQUIRE_ASYNC_SIGNAL_SAFE = OPAL_MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE + MPI_T_CB_REQUIRE_NONE, + MPI_T_CB_REQUIRE_MPI_RESTRICTED, + MPI_T_CB_REQUIRE_THREAD_SAFE, + MPI_T_CB_REQUIRE_ASYNC_SIGNAL_SAFE } MPI_T_cb_safety; /* * MPIT source ordering */ -enum ompi_mpi_t_source_order_t { +enum ompi_mpi_t_order_t { MPI_T_ORDERED, MPI_T_UNORDERED, }; -typedef enum ompi_mpi_t_source_order_t MPI_T_source_order; +typedef enum ompi_mpi_t_order_t MPI_T_order; /* * MPI Tool event functions @@ -947,9 +941,8 @@ typedef enum ompi_mpi_t_source_order_t MPI_T_source_order; typedef void (*MPI_T_event_free_cb_function) (MPI_T_event_registration handle, MPI_T_cb_safety cb_safety, void *user_data); -typedef void (*MPI_T_event_dropped_cb_function) (MPI_Count count, +typedef void (*MPI_T_event_dropped_cb_function) (int count, MPI_T_event_registration handle, - int source_index, MPI_T_cb_safety cb_safety, void *user_data); typedef void (*MPI_T_event_cb_function) (MPI_T_event_instance event, @@ -3007,7 +3000,7 @@ OMPI_DECLSPEC int PMPI_T_event_get_num (int *num_events); OMPI_DECLSPEC int PMPI_T_event_get_info (int event_index, char *name, int *name_len, int *verbosity, MPI_Datatype *array_of_datatypes, MPI_Aint *array_of_displacements, int *num_elements, - MPI_T_enum *enumtype, MPI_Info *info, + MPI_Aint *extent, MPI_T_enum *enumtype, MPI_Info *info, char *desc, int *desc_len, int *bind); OMPI_DECLSPEC int PMPI_T_event_get_index (const char *name, int *event_index); OMPI_DECLSPEC int PMPI_T_event_handle_alloc (int event_index, void *obj_handle, @@ -3023,7 +3016,6 @@ OMPI_DECLSPEC int PMPI_T_event_callback_set_info (MPI_T_event_registration even OMPI_DECLSPEC int PMPI_T_event_callback_get_info (MPI_T_event_registration event_registration, MPI_T_cb_safety cb_safety, MPI_Info *info_used); OMPI_DECLSPEC int PMPI_T_event_handle_free (MPI_T_event_registration event_registration, - void *user_data, MPI_T_event_free_cb_function free_cb_function); OMPI_DECLSPEC int PMPI_T_event_set_dropped_handler (MPI_T_event_registration handle, MPI_T_event_dropped_cb_function dropped_cb_function); @@ -3033,7 +3025,7 @@ OMPI_DECLSPEC int PMPI_T_event_get_timestamp (MPI_T_event_instance event, MPI_C OMPI_DECLSPEC int PMPI_T_event_get_source (MPI_T_event_instance event, int *source_index); OMPI_DECLSPEC int PMPI_T_source_get_num (int *num_source); OMPI_DECLSPEC int PMPI_T_source_get_info (int source_id, char *name, int *name_len, - char *desc, int *desc_len, MPI_T_source_order *ordering, + char *desc, int *desc_len, MPI_T_order *ordering, MPI_Count *ticks_per_second, MPI_Count *max_timestamp, MPI_Info *info); OMPI_DECLSPEC int PMPI_T_source_get_timestamp (int source_id, MPI_Count *timestamp); @@ -3121,7 +3113,7 @@ OMPI_DECLSPEC int MPI_T_event_get_num (int *num_events); OMPI_DECLSPEC int MPI_T_event_get_info (int event_index, char *name, int *name_len, int *verbosity, MPI_Datatype *array_of_datatypes, MPI_Aint *array_of_displacements, int *num_elements, - MPI_T_enum *enumtype, MPI_Info *info, + MPI_Aint *extent, MPI_T_enum *enumtype, MPI_Info *info, char *desc, int *desc_len, int *bind); OMPI_DECLSPEC int MPI_T_event_get_index (const char *name, int *event_index); OMPI_DECLSPEC int MPI_T_event_handle_alloc (int event_index, void *obj_handle, @@ -3130,7 +3122,6 @@ OMPI_DECLSPEC int MPI_T_event_handle_set_info (MPI_T_event_registration event_r OMPI_DECLSPEC int MPI_T_event_handle_get_info (MPI_T_event_registration event_registration, MPI_Info *info_used); OMPI_DECLSPEC int MPI_T_event_handle_free (MPI_T_event_registration event_registration, - void *user_data, MPI_T_event_free_cb_function free_cb_function); OMPI_DECLSPEC int MPI_T_event_register_callback (MPI_T_event_registration event_registration, MPI_T_cb_safety cb_safety, MPI_Info info, void *user_data, @@ -3148,7 +3139,7 @@ OMPI_DECLSPEC int MPI_T_event_get_source (MPI_T_event_instance event, int *sour OMPI_DECLSPEC int MPI_T_source_get_num (int *num_source); OMPI_DECLSPEC int MPI_T_source_get_info (int source_id, char *name, int *name_len, - char *desc, int *desc_len, MPI_T_source_order *ordering, + char *desc, int *desc_len, MPI_T_order *ordering, MPI_Count *ticks_per_second, MPI_Count *max_timestamp, MPI_Info *info); OMPI_DECLSPEC int MPI_T_source_get_timestamp (int source_id, MPI_Count *timestamp); diff --git a/ompi/mca/osc/rdma/osc_rdma.h b/ompi/mca/osc/rdma/osc_rdma.h index b18d2d7c4d0..d9070083262 100644 --- a/ompi/mca/osc/rdma/osc_rdma.h +++ b/ompi/mca/osc/rdma/osc_rdma.h @@ -57,6 +57,34 @@ #include "osc_rdma_peer.h" #include "opal_stdint.h" +#include "opal/mca/base/mca_base_event.h" + +enum { + OMPI_OSC_RDMA_EVENT_LOCK_ACQUIRED, + OMPI_OSC_RDMA_EVENT_LOCK_RELEASED, + OMPI_OSC_RDMA_EVENT_PUT_STARTED, + OMPI_OSC_RDMA_EVENT_PUT_COMPLETE, + OMPI_OSC_RDMA_EVENT_GET_STARTED, + OMPI_OSC_RDMA_EVENT_GET_COMPLETE, + OMPI_OSC_RDMA_EVENT_FLUSH_STARTED, + OMPI_OSC_RDMA_EVENT_FLUSH_COMPLETE, + OMPI_OSC_RDMA_EVENT_PSCW_EXPOSE_START, + OMPI_OSC_RDMA_EVENT_PSCW_EXPOSE_COMPLETE, + OMPI_OSC_RDMA_EVENT_PSCW_ACCESS_START, + OMPI_OSC_RDMA_EVENT_PSCW_ACCESS_COMPLETE, + OMPI_OSC_RDMA_EVENT_FENCE, + OMPI_OSC_RDMA_EVENT_MAX, +}; + +struct mca_osc_rdma_rdma_event_t { + int target; + uint64_t address; + uint64_t size; +}; + +typedef struct mca_osc_rdma_rdma_event_t mca_osc_rdma_rdma_event_t; + +extern mca_base_event_list_item_t mca_osc_rdma_events[]; #define RANK_ARRAY_COUNT(module) ((ompi_comm_size ((module)->comm) + (module)->node_count - 1) / (module)->node_count) diff --git a/ompi/mca/osc/rdma/osc_rdma_active_target.c b/ompi/mca/osc/rdma/osc_rdma_active_target.c index 9858151fa67..10026b6abaf 100644 --- a/ompi/mca/osc/rdma/osc_rdma_active_target.c +++ b/ompi/mca/osc/rdma/osc_rdma_active_target.c @@ -182,6 +182,8 @@ static void ompi_osc_rdma_handle_post (ompi_osc_rdma_module_t *module, int rank, rank, (int) (npeers - state->num_post_msgs - 1)); /* an atomic is not really necessary as this function is currently used but it doesn't hurt */ ompi_osc_rdma_counter_add (&state->num_post_msgs, 1); + mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_PSCW_ACCESS_START].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, + module->win, NULL, &rank); return; } } @@ -307,6 +309,9 @@ int ompi_osc_rdma_post_atomic (ompi_group_t *group, int mpi_assert, ompi_win_t * return OMPI_SUCCESS; } + mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_PSCW_EXPOSE_START].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, + module->win, NULL, NULL); + /* translate group ranks into the communicator */ peers = ompi_osc_rdma_get_peers (module, module->pw_group); if (OPAL_UNLIKELY(NULL == peers)) { @@ -394,6 +399,8 @@ int ompi_osc_rdma_start_atomic (ompi_group_t *group, int mpi_assert, ompi_win_t "from %d processes", peer->rank, (int) (group_size - state->num_post_msgs - 1)); opal_list_remove_item (&module->pending_posts, &pending_post->super); OBJ_RELEASE(pending_post); + mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_PSCW_ACCESS_START].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, + module->win, NULL, &peer->rank); ompi_osc_rdma_counter_add (&state->num_post_msgs, 1); break; } @@ -464,6 +471,9 @@ int ompi_osc_rdma_complete_atomic (ompi_win_t *win) ompi_osc_rdma_peer_t *peer = peers[i]; intptr_t target = (intptr_t) peer->state + offsetof (ompi_osc_rdma_state_t, num_complete_msgs); + mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_PSCW_ACCESS_COMPLETE].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, + module->win, NULL, &peer->rank); + if (!ompi_osc_rdma_peer_local_state (peer)) { ret = ompi_osc_rdma_lock_btl_op (module, peer, target, MCA_BTL_ATOMIC_ADD, 1, true); assert (OMPI_SUCCESS == ret); @@ -507,6 +517,9 @@ int ompi_osc_rdma_wait_atomic (ompi_win_t *win) opal_atomic_mb (); } + mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_PSCW_EXPOSE_COMPLETE].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, + module->win, NULL, NULL); + OPAL_THREAD_LOCK(&module->lock); group = module->pw_group; module->pw_group = NULL; @@ -556,6 +569,9 @@ int ompi_osc_rdma_test_atomic (ompi_win_t *win, int *flag) module->pw_group = NULL; OPAL_THREAD_UNLOCK(&(module->lock)); + mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_PSCW_EXPOSE_COMPLETE].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, + module->win, NULL, NULL); + OBJ_RELEASE(group); OSC_RDMA_VERBOSE(MCA_BASE_VERBOSE_TRACE, "test complete. returning flag: true"); diff --git a/ompi/mca/osc/rdma/osc_rdma_comm.c b/ompi/mca/osc/rdma/osc_rdma_comm.c index 9b519e36eaf..c553ca86cb1 100644 --- a/ompi/mca/osc/rdma/osc_rdma_comm.c +++ b/ompi/mca/osc/rdma/osc_rdma_comm.c @@ -15,8 +15,7 @@ * $HEADER$ */ -#include "ompi_config.h" - +#include "osc_rdma.h" #include "osc_rdma_comm.h" #include "osc_rdma_frag.h" #include "osc_rdma_sync.h" @@ -461,6 +460,9 @@ static int ompi_osc_rdma_put_real (ompi_osc_rdma_sync_t *sync, ompi_osc_rdma_pee OSC_RDMA_VERBOSE(MCA_BASE_VERBOSE_TRACE, "initiating btl put of %lu bytes to remote address %" PRIx64 ", sync " "object %p...", (unsigned long) size, target_address, (void *) sync); + mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_PUT_STARTED].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, + module->win, NULL, &((mca_osc_rdma_rdma_event_t){.target = peer->rank, .address = target_address, .size = size})); + /* flag outstanding rma requests */ ompi_osc_rdma_sync_rdma_inc (sync); @@ -725,6 +727,9 @@ static int ompi_osc_rdma_get_contig (ompi_osc_rdma_sync_t *sync, ompi_osc_rdma_p ompi_osc_rdma_sync_rdma_inc (sync); } + mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_GET_STARTED].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, + module->win, NULL, &((mca_osc_rdma_rdma_event_t){.target = peer->rank, .address = source_address, .size = size})); + do { ret = ompi_osc_rdma_btl_get(module, peer->data_btl_index, peer->data_endpoint, ptr, aligned_source_base, local_handle, source_handle, diff --git a/ompi/mca/osc/rdma/osc_rdma_component.c b/ompi/mca/osc/rdma/osc_rdma_component.c index a7a005a8afe..04259d1ca8b 100644 --- a/ompi/mca/osc/rdma/osc_rdma_component.c +++ b/ompi/mca/osc/rdma/osc_rdma_component.c @@ -85,6 +85,87 @@ static const char* ompi_osc_rdma_set_no_lock_info(opal_infosubscriber_t *obj, co static char *ompi_osc_rdma_full_connectivity_btls; +static char *mca_osc_rdma_target_element[] = { + "target", NULL, +}; + +static opal_datatype_t *mca_osc_rdma_rdma_event_types[] = { + &ompi_mpi_int.dt.super, &ompi_mpi_int64_t.dt.super, &ompi_mpi_int64_t.dt.super, +}; + +static char *mca_osc_rdma_rdma_event_elements[] = { + "target", "address", "size_bytes", NULL, +}; + +static unsigned long mca_osc_rdma_rdma_event_offsets[] = { + offsetof (mca_osc_rdma_rdma_event_t, target), offsetof (mca_osc_rdma_rdma_event_t, address), + offsetof (mca_osc_rdma_rdma_event_t, size), +}; + +mca_base_event_list_item_t mca_osc_rdma_events[] = { + [OMPI_OSC_RDMA_EVENT_LOCK_ACQUIRED] = {.name = "lock_acquired", .desc = "Passive-target lock aquired", + .verbosity = OPAL_INFO_LVL_5, .datatypes = &(opal_datatype_t *) {&ompi_mpi_int.dt.super}, + .offsets = &(unsigned long) {0}, .num_datatypes = 1, .elements = mca_osc_rdma_target_element, + .extent = sizeof (int), .bind = MCA_BASE_VAR_BIND_MPI_WIN}, + + [OMPI_OSC_RDMA_EVENT_LOCK_RELEASED] = {.name = "lock_released", .desc = "Passive-target lock required", + .verbosity = OPAL_INFO_LVL_5, .datatypes = &(opal_datatype_t *) {&ompi_mpi_int.dt.super}, + .offsets = &(unsigned long) {0}, .num_datatypes = 1, .elements = mca_osc_rdma_target_element, + .extent = sizeof (int), .bind = MCA_BASE_VAR_BIND_MPI_WIN}, + + [OMPI_OSC_RDMA_EVENT_PUT_STARTED] = {.name = "put_started", .desc = "Put started to target. Complete event may not exist.", + .verbosity = OPAL_INFO_LVL_5, .datatypes = mca_osc_rdma_rdma_event_types, + .offsets = mca_osc_rdma_rdma_event_offsets, .num_datatypes = 3, + .elements = mca_osc_rdma_rdma_event_elements, .extent = 24, .bind = MCA_BASE_VAR_BIND_MPI_WIN}, + + [OMPI_OSC_RDMA_EVENT_PUT_COMPLETE] = {.name = "put_complete", .desc = "Put completed on target", + .verbosity = OPAL_INFO_LVL_5, .datatypes = mca_osc_rdma_rdma_event_types, + .offsets = mca_osc_rdma_rdma_event_offsets, .num_datatypes = 3, + .elements = mca_osc_rdma_rdma_event_elements, .extent = 24, .bind = MCA_BASE_VAR_BIND_MPI_WIN}, + + [OMPI_OSC_RDMA_EVENT_GET_STARTED] = {.name = "get_started", .desc = "Put started to target. Complete event may not exist.", + .verbosity = OPAL_INFO_LVL_5, .datatypes = mca_osc_rdma_rdma_event_types, + .offsets = mca_osc_rdma_rdma_event_offsets, .num_datatypes = 3, + .elements = mca_osc_rdma_rdma_event_elements, .extent = 24, .bind = MCA_BASE_VAR_BIND_MPI_WIN}, + + [OMPI_OSC_RDMA_EVENT_GET_COMPLETE] = {.name = "get_complete", .desc = "Put completed on target", + .verbosity = OPAL_INFO_LVL_5, .datatypes = mca_osc_rdma_rdma_event_types, + .offsets = mca_osc_rdma_rdma_event_offsets, .num_datatypes = 3, + .elements = mca_osc_rdma_rdma_event_elements, .extent = 24, .bind = MCA_BASE_VAR_BIND_MPI_WIN}, + + [OMPI_OSC_RDMA_EVENT_FLUSH_STARTED] = {.name = "flush_started", .desc = "Flush started on target", + .verbosity = OPAL_INFO_LVL_5, .datatypes = &(opal_datatype_t *) {&ompi_mpi_int.dt.super}, + .offsets = &(unsigned long) {0}, .num_datatypes = 1, .elements = mca_osc_rdma_target_element, + .extent = sizeof (int), .bind = MCA_BASE_VAR_BIND_MPI_WIN}, + + [OMPI_OSC_RDMA_EVENT_FLUSH_COMPLETE] = {.name = "flush_complete", .desc = "Flush complete on target", + .verbosity = OPAL_INFO_LVL_5, .datatypes = &(opal_datatype_t *) {&ompi_mpi_int.dt.super}, + .offsets = &(unsigned long) {0}, .num_datatypes = 1, .elements = mca_osc_rdma_target_element, + .extent = sizeof (int), .bind = MCA_BASE_VAR_BIND_MPI_WIN}, + + [OMPI_OSC_RDMA_EVENT_PSCW_EXPOSE_START] = {.name = "pscw_expose_start", .desc = "PSWW exposure started", + .verbosity = OPAL_INFO_LVL_5, .datatypes = &(opal_datatype_t *) {&ompi_mpi_int.dt.super}, + .offsets = &(unsigned long) {0}, .num_datatypes = 0, .elements = mca_osc_rdma_target_element, + .extent = sizeof (int), .bind = MCA_BASE_VAR_BIND_MPI_WIN}, + + [OMPI_OSC_RDMA_EVENT_PSCW_EXPOSE_COMPLETE] = {.name = "pscw_expose_complete", .desc = "PSWW exposure complete", + .verbosity = OPAL_INFO_LVL_5, .datatypes = &(opal_datatype_t *) {&ompi_mpi_int.dt.super}, + .offsets = &(unsigned long) {0}, .num_datatypes = 0, .elements = mca_osc_rdma_target_element, + .extent = sizeof (int), .bind = MCA_BASE_VAR_BIND_MPI_WIN}, + + [OMPI_OSC_RDMA_EVENT_PSCW_ACCESS_START] = {.name = "pscw_access_start", .desc = "PSWW access epoch started", + .verbosity = OPAL_INFO_LVL_5, .datatypes = &(opal_datatype_t *) {&ompi_mpi_int.dt.super}, + .offsets = &(unsigned long) {0}, .num_datatypes = 1, .elements = mca_osc_rdma_target_element, + .extent = sizeof (int), .bind = MCA_BASE_VAR_BIND_MPI_WIN}, + + [OMPI_OSC_RDMA_EVENT_PSCW_ACCESS_COMPLETE] = {.name = "pscw_access_complete", .desc = "PSWW access epoch complete", + .verbosity = OPAL_INFO_LVL_5, .datatypes = &(opal_datatype_t *) {&ompi_mpi_int.dt.super}, + .offsets = &(unsigned long) {0}, .num_datatypes = 1, .elements = mca_osc_rdma_target_element, + .extent = sizeof (int), .bind = MCA_BASE_VAR_BIND_MPI_WIN}, + + [OMPI_OSC_RDMA_EVENT_FENCE] = {.name = "fence", .desc = "Fence called", .verbosity = OPAL_INFO_LVL_5, .bind = MCA_BASE_VAR_BIND_MPI_WIN}, +}; + static const mca_base_var_enum_value_t ompi_osc_rdma_locking_modes[] = { {.value = OMPI_OSC_RDMA_LOCKING_TWO_LEVEL, .string = "two_level"}, {.value = OMPI_OSC_RDMA_LOCKING_ON_DEMAND, .string = "on_demand"}, @@ -305,6 +386,8 @@ static int ompi_osc_rdma_component_register (void) ompi_osc_rdma_pvar_read, NULL, NULL, (void *) (intptr_t) offsetof (ompi_osc_rdma_module_t, get_retry_count)); + mca_base_component_event_register_list (&mca_osc_rdma_component.super.osc_version, mca_osc_rdma_events, OMPI_OSC_RDMA_EVENT_MAX); + return OMPI_SUCCESS; } diff --git a/ompi/mca/osc/rdma/osc_rdma_passive_target.c b/ompi/mca/osc/rdma/osc_rdma_passive_target.c index 8154c8da176..d88882a5fee 100644 --- a/ompi/mca/osc/rdma/osc_rdma_passive_target.c +++ b/ompi/mca/osc/rdma/osc_rdma_passive_target.c @@ -56,9 +56,15 @@ int ompi_osc_rdma_flush (int target, struct ompi_win_t *win) } OPAL_THREAD_UNLOCK(&module->lock); + mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_FLUSH_STARTED].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, + module->win, NULL, &target); + /* finish all outstanding fragments */ ompi_osc_rdma_sync_rdma_complete (lock); + mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_FLUSH_COMPLETE].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, + module->win, NULL, &target); + OSC_RDMA_VERBOSE(MCA_BASE_VERBOSE_TRACE, "flush on target %d complete", target); return OMPI_SUCCESS; @@ -85,6 +91,9 @@ int ompi_osc_rdma_flush_all (struct ompi_win_t *win) ompi_osc_rdma_sync_rdma_complete (&module->all_sync); } + mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_FLUSH_STARTED].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, + module->win, NULL, &(int) {-1}); + /* flush all locks */ ret = opal_hash_table_get_first_key_uint32 (&module->outstanding_locks, &key, (void **) &lock, &node); while (OPAL_SUCCESS == ret) { @@ -94,6 +103,9 @@ int ompi_osc_rdma_flush_all (struct ompi_win_t *win) node, &node); } + mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_FLUSH_COMPLETE].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, + module->win, NULL, &(int) {-1}); + OSC_RDMA_VERBOSE(MCA_BASE_VERBOSE_TRACE, "flush_all complete"); return OPAL_SUCCESS; @@ -159,6 +171,9 @@ static inline int ompi_osc_rdma_lock_atomic_internal (ompi_osc_rdma_module_t *mo } while (1); } + mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_LOCK_ACQUIRED].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, + module->win, NULL, &peer->rank); + return OMPI_SUCCESS; } @@ -183,6 +198,10 @@ static inline int ompi_osc_rdma_unlock_atomic_internal (ompi_osc_rdma_module_t * peer->flags &= ~OMPI_OSC_RDMA_PEER_DEMAND_LOCKED; } + mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_LOCK_RELEASED].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, + module->win, NULL, &peer->rank); + + return OMPI_SUCCESS; } @@ -355,6 +374,9 @@ int ompi_osc_rdma_lock_all_atomic (int mpi_assert, struct ompi_win_t *win) ret = ompi_osc_rdma_lock_acquire_shared (module, module->leader, 0x0000000100000000UL, offsetof(ompi_osc_rdma_state_t, global_lock), 0x00000000ffffffffUL); + + mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_LOCK_ACQUIRED].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, + module->win, NULL, &(int) {-1}); } else { /* always lock myself */ ret = ompi_osc_rdma_demand_lock_peer (module, module->my_peer); @@ -410,6 +432,9 @@ int ompi_osc_rdma_unlock_all_atomic (struct ompi_win_t *win) /* decrement the master lock shared count */ (void) ompi_osc_rdma_lock_release_shared (module, module->leader, -0x0000000100000000UL, offsetof (ompi_osc_rdma_state_t, global_lock)); + + mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_LOCK_RELEASED].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, + module->win, NULL, &(int) {-1}); } } diff --git a/ompi/mca/pml/ob1/pml_ob1.c b/ompi/mca/pml/ob1/pml_ob1.c index e0516d16fe0..5f02f2aa6ce 100644 --- a/ompi/mca/pml/ob1/pml_ob1.c +++ b/ompi/mca/pml/ob1/pml_ob1.c @@ -14,7 +14,7 @@ * Copyright (c) 2006-2008 University of Houston. All rights reserved. * Copyright (c) 2009-2010 Oracle and/or its affiliates. All rights reserved * Copyright (c) 2011 Sandia National Laboratories. All rights reserved. - * Copyright (c) 2011-2015 Los Alamos National Security, LLC. All rights + * Copyright (c) 2011-2018 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2012 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2015 FUJITSU LIMITED. All rights reserved. @@ -305,8 +305,8 @@ int mca_pml_ob1_add_comm(ompi_communicator_t* comm) * figure out if the messages are not received in the correct * order (if multiple network interfaces). */ - PERUSE_TRACE_MSG_EVENT(PERUSE_COMM_MSG_ARRIVED, comm, - hdr->hdr_src, hdr->hdr_tag, PERUSE_RECV); + mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_MESSAGE_ARRIVED].event, + MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, comm, NULL, hdr); /* There is no matching to be done, and no lock to be held on the communicator as * we know at this point that the communicator has not yet been returned to the user. @@ -322,8 +322,8 @@ int mca_pml_ob1_add_comm(ompi_communicator_t* comm) #else custom_match_umq_append(pml_comm->umq, hdr->hdr_tag, hdr->hdr_src, frag); #endif - PERUSE_TRACE_MSG_EVENT(PERUSE_COMM_MSG_INSERT_IN_UNEX_Q, comm, - hdr->hdr_src, hdr->hdr_tag, PERUSE_RECV); + mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_UNEX_INSERT].event, + MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, comm, NULL, hdr); continue; } @@ -337,8 +337,9 @@ int mca_pml_ob1_add_comm(ompi_communicator_t* comm) #else custom_match_umq_append(pml_comm->umq, hdr->hdr_tag, hdr->hdr_src, frag); #endif - PERUSE_TRACE_MSG_EVENT(PERUSE_COMM_MSG_INSERT_IN_UNEX_Q, comm, - hdr->hdr_src, hdr->hdr_tag, PERUSE_RECV); + mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_UNEX_INSERT].event, + MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, comm, NULL, hdr); + /* And now the ugly part. As some fragments can be inserted in the cant_match list, * every time we successfully add a fragment in the unexpected list we have to make * sure the next one is not in the cant_match. Otherwise, we will endup in a deadlock diff --git a/ompi/mca/pml/ob1/pml_ob1.h b/ompi/mca/pml/ob1/pml_ob1.h index a0091793ab4..00e113babca 100644 --- a/ompi/mca/pml/ob1/pml_ob1.h +++ b/ompi/mca/pml/ob1/pml_ob1.h @@ -44,6 +44,7 @@ #include "ompi/proc/proc.h" #include "opal/mca/allocator/base/base.h" #include "ompi/runtime/mpiruntime.h" +#include "opal/mca/base/mca_base_event.h" BEGIN_C_DECLS @@ -91,6 +92,34 @@ struct mca_pml_ob1_t { }; typedef struct mca_pml_ob1_t mca_pml_ob1_t; +enum { + MCA_PML_OB1_EVENT_MESSAGE_ARRIVED, + MCA_PML_OB1_EVENT_SEARCH_POSTED_BEGIN, + MCA_PML_OB1_EVENT_SEARCH_POSTED_END, + MCA_PML_OB1_EVENT_SEARCH_UNEX_BEGIN, + MCA_PML_OB1_EVENT_SEARCH_UNEX_END, + MCA_PML_OB1_EVENT_POSTED_INSERT, + MCA_PML_OB1_EVENT_POSTED_REMOVE, + MCA_PML_OB1_EVENT_UNEX_INSERT, + MCA_PML_OB1_EVENT_UNEX_REMOVE, + MCA_PML_OB1_EVENT_TRANSFER_BEGIN, + MCA_PML_OB1_EVENT_TRANSFER, + MCA_PML_OB1_EVENT_TRANSFER_END, + MCA_PML_OB1_EVENT_RECEIVE_CANCELED, + MCA_PML_OB1_EVENT_REQUEST_FREE, + MCA_PML_OB1_EVENT_REQUEST_ACTIVATE, + MCA_PML_OB1_EVENT_REQUEST_COMPLETE, + MCA_PML_OB1_EVENT_MAX, +}; + +extern mca_base_event_list_item_t mca_pml_ob1_events[]; + +struct mca_pml_ob1_transfer_event_t { + void *request; + int64_t length; +}; +typedef struct mca_pml_ob1_transfer_event_t mca_pml_ob1_transfer_event_t; + extern mca_pml_ob1_t mca_pml_ob1; extern int mca_pml_ob1_output; extern bool mca_pml_ob1_matching_protection; diff --git a/ompi/mca/pml/ob1/pml_ob1_component.c b/ompi/mca/pml/ob1/pml_ob1_component.c index 74786121e4f..c7644338b2f 100644 --- a/ompi/mca/pml/ob1/pml_ob1_component.c +++ b/ompi/mca/pml/ob1/pml_ob1_component.c @@ -12,7 +12,7 @@ * All rights reserved. * Copyright (c) 2007-2010 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved - * Copyright (c) 2013-2017 Los Alamos National Security, LLC. All rights + * Copyright (c) 2013-2018 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2018 Sandia National Laboratories * All rights reserved. @@ -64,6 +64,111 @@ static int mca_pml_ob1_verbose = 0; bool mca_pml_ob1_matching_protection = false; int mca_pml_ob1_accelerator_events_max = 400; +static opal_datatype_t *mca_pml_ob1_match_hdr_types[] = { + &ompi_mpi_int16_t.dt.super, &ompi_mpi_int32_t.dt.super, + &ompi_mpi_int32_t.dt.super, &ompi_mpi_int16_t.dt.super, +}; + +static opal_datatype_t *mca_pml_ob1_request_size_types[] = { + &ompi_mpi_aint.dt.super, &ompi_mpi_int64_t.dt.super, +}; + +static unsigned long mca_pml_ob1_match_hdr_offsets[] = { + offsetof (mca_pml_ob1_match_hdr_t, hdr_ctx), offsetof (mca_pml_ob1_match_hdr_t, hdr_src), + offsetof (mca_pml_ob1_match_hdr_t, hdr_tag), offsetof (mca_pml_ob1_match_hdr_t, hdr_seq), +}; + +static unsigned long mca_pml_ob1_request_size_offsets[] = { + offsetof (mca_pml_ob1_transfer_event_t, request), offsetof (mca_pml_ob1_transfer_event_t, length), +}; + +static char *mca_pml_ob1_match_hdr_names[] = { + "context id", "source", "tag", "sequence number", NULL, +}; + +static char *mca_pml_ob1_request_element[] = { + "request", NULL, +}; + +static char *mca_pml_ob1_request_size_elements[] = { + "request", "length", NULL, +}; + + +mca_base_event_list_item_t mca_pml_ob1_events[] = { + [MCA_PML_OB1_EVENT_MESSAGE_ARRIVED] = {.name = "message_arrived", .desc = "Message arrived for match", + .verbosity = OPAL_INFO_LVL_5, .datatypes = mca_pml_ob1_match_hdr_types, + .offsets = mca_pml_ob1_match_hdr_offsets, .num_datatypes = 4, + .elements = mca_pml_ob1_match_hdr_names, .extent = 12, .bind = MCA_BASE_VAR_BIND_MPI_COMM}, + + [MCA_PML_OB1_EVENT_SEARCH_POSTED_BEGIN] = {.name = "search_posted_begin", .desc = "Begin searching posted message queue", + .verbosity = OPAL_INFO_LVL_5, .datatypes = &mca_pml_ob1_match_hdr_types[1], + .offsets = &mca_pml_ob1_match_hdr_offsets[1], .num_datatypes = 2, + .elements = &mca_pml_ob1_match_hdr_names[1], .extent = 8, .bind = MCA_BASE_VAR_BIND_MPI_COMM}, + + [MCA_PML_OB1_EVENT_SEARCH_POSTED_END] = {.name = "search_posted_end", .desc = "Finished searching posted message queue", + .verbosity = OPAL_INFO_LVL_5, .datatypes = &mca_pml_ob1_match_hdr_types[1], + .offsets = &mca_pml_ob1_match_hdr_offsets[1], .num_datatypes = 2, + .elements = &mca_pml_ob1_match_hdr_names[1], .extent = 8, .bind = MCA_BASE_VAR_BIND_MPI_COMM}, + + [MCA_PML_OB1_EVENT_SEARCH_UNEX_BEGIN] = {.name = "search_unexpected_begin", .desc = "Begin searching unexpected message queue", + .verbosity = OPAL_INFO_LVL_5, .datatypes = &(opal_datatype_t *) {&ompi_mpi_aint.dt.super}, + .offsets = &(unsigned long) {0}, .num_datatypes = 1, .elements = mca_pml_ob1_request_element, + .extent = sizeof (MPI_Aint), .bind = MCA_BASE_VAR_BIND_MPI_COMM}, + + [MCA_PML_OB1_EVENT_SEARCH_UNEX_END] = {.name = "search_unexpected_end", .desc = "Finished searching unexpected message queue", + .verbosity = OPAL_INFO_LVL_5, .datatypes = &(opal_datatype_t *) {&ompi_mpi_aint.dt.super}, + .offsets = &(unsigned long) {0}, .num_datatypes = 1, .elements = mca_pml_ob1_request_element, + .extent = sizeof (MPI_Aint), .bind = MCA_BASE_VAR_BIND_MPI_COMM}, + + [MCA_PML_OB1_EVENT_POSTED_INSERT] = {.name = "posted_insert", .desc = "Added request to the posted message queue", + .verbosity = OPAL_INFO_LVL_5, .datatypes = &(opal_datatype_t *) {&ompi_mpi_aint.dt.super}, + .offsets = &(unsigned long) {0}, .num_datatypes = 1, .elements = mca_pml_ob1_request_element, + .extent = sizeof (MPI_Aint), .bind = MCA_BASE_VAR_BIND_MPI_COMM}, + + [MCA_PML_OB1_EVENT_POSTED_REMOVE] = {.name = "posted_remove", .desc = "Remove request from the posted message queue", + .verbosity = OPAL_INFO_LVL_5, .datatypes = &(opal_datatype_t *) {&ompi_mpi_aint.dt.super}, + .offsets = &(unsigned long) {0}, .num_datatypes = 1, .elements = mca_pml_ob1_request_element, + .extent = sizeof (MPI_Aint), .bind = MCA_BASE_VAR_BIND_MPI_COMM}, + + [MCA_PML_OB1_EVENT_UNEX_INSERT] = {.name = "unex_insert", .desc = "Unexpected message inserted in queue", .verbosity = OPAL_INFO_LVL_5, + .datatypes = &mca_pml_ob1_match_hdr_types[1], .offsets = &mca_pml_ob1_match_hdr_offsets[1], + .num_datatypes = 2, .elements = &mca_pml_ob1_match_hdr_names[1], .extent = 8, .bind = MCA_BASE_VAR_BIND_MPI_COMM}, + + [MCA_PML_OB1_EVENT_UNEX_REMOVE] = {.name = "unex_remove", .desc = "Unexpected message removed from queue", .verbosity = OPAL_INFO_LVL_5, + .datatypes = &mca_pml_ob1_match_hdr_types[1], .offsets = &mca_pml_ob1_match_hdr_offsets[1], + .num_datatypes = 2, .elements = &mca_pml_ob1_match_hdr_names[1], .extent = 8, .bind = MCA_BASE_VAR_BIND_MPI_COMM}, + + [MCA_PML_OB1_EVENT_TRANSFER_BEGIN] = {.name = "transfer_begin", .desc = "Transfer has begun", .verbosity = OPAL_INFO_LVL_5, + .datatypes = &(opal_datatype_t *) {&ompi_mpi_aint.dt.super}, .offsets = &(unsigned long) {0}, .num_datatypes = 1, + .elements = mca_pml_ob1_request_element, .extent = sizeof (MPI_Aint), .bind = MCA_BASE_VAR_BIND_MPI_COMM}, + + [MCA_PML_OB1_EVENT_TRANSFER] = {.name = "transfer", .desc = "Transfer event", .verbosity = OPAL_INFO_LVL_5, + .datatypes = mca_pml_ob1_request_size_types, .offsets = mca_pml_ob1_request_size_offsets, .num_datatypes = 2, + .elements = mca_pml_ob1_request_size_elements, .extent = sizeof (mca_pml_ob1_transfer_event_t), + .bind = MCA_BASE_VAR_BIND_MPI_COMM}, + + [MCA_PML_OB1_EVENT_TRANSFER_END] = {.name = "transfer_end", .desc = "Transfer has completed", .verbosity = OPAL_INFO_LVL_5, + .datatypes = &(opal_datatype_t *) {&ompi_mpi_aint.dt.super}, .offsets = &(unsigned long) {0}, .num_datatypes = 1, + .elements = mca_pml_ob1_request_element, .extent = sizeof (MPI_Aint), .bind = MCA_BASE_VAR_BIND_MPI_COMM}, + + [MCA_PML_OB1_EVENT_RECEIVE_CANCELED] = {.name = "cancel", .desc = "Receive request canceled", .verbosity = OPAL_INFO_LVL_5, + .datatypes = &(opal_datatype_t *) {&ompi_mpi_aint.dt.super}, .offsets = &(unsigned long) {0}, .num_datatypes = 1, + .elements = mca_pml_ob1_request_element, .extent = sizeof (MPI_Aint), .bind = MCA_BASE_VAR_BIND_MPI_COMM}, + + [MCA_PML_OB1_EVENT_REQUEST_FREE] = {.name = "free", .desc = "Request object freed", .verbosity = OPAL_INFO_LVL_5, + .datatypes = &(opal_datatype_t *) {&ompi_mpi_aint.dt.super}, .offsets = &(unsigned long) {0}, .num_datatypes = 1, + .elements = mca_pml_ob1_request_element, .extent = sizeof (MPI_Aint), .bind = MCA_BASE_VAR_BIND_MPI_COMM}, + + [MCA_PML_OB1_EVENT_REQUEST_ACTIVATE] = {.name = "request_activate", .desc = "Request activated", .verbosity = OPAL_INFO_LVL_5, + .datatypes = &(opal_datatype_t *) {&ompi_mpi_aint.dt.super}, .offsets = &(unsigned long) {0}, .num_datatypes = 1, + .elements = mca_pml_ob1_request_element, .extent = sizeof (MPI_Aint), .bind = MCA_BASE_VAR_BIND_MPI_COMM}, + + [MCA_PML_OB1_EVENT_REQUEST_COMPLETE] = {.name = "request_complete", .desc = "Request completed", .verbosity = OPAL_INFO_LVL_5, + .datatypes = &(opal_datatype_t *) {&ompi_mpi_aint.dt.super}, .offsets = &(unsigned long) {0}, .num_datatypes = 1, + .elements = mca_pml_ob1_request_element, .extent = sizeof (MPI_Aint), .bind = MCA_BASE_VAR_BIND_MPI_COMM}, +}; + mca_pml_base_component_2_1_0_t mca_pml_ob1_component = { /* First, the mca_base_component_t struct containing meta information about the component itself */ @@ -243,11 +348,7 @@ static int mca_pml_ob1_component_register(void) MCA_BASE_PVAR_FLAG_READONLY | MCA_BASE_PVAR_FLAG_CONTINUOUS, mca_pml_ob1_get_posted_recvq_size, NULL, mca_pml_ob1_comm_size_notify, NULL); - mca_pml_ob1_accelerator_events_max = 400; - (void) mca_base_component_var_register(&mca_pml_ob1_component.pmlm_version, "accelerator_events_max", - "Number of events created by the ob1 component internally", - MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, OPAL_INFO_LVL_5, - MCA_BASE_VAR_SCOPE_READONLY, &mca_pml_ob1_accelerator_events_max); + mca_base_component_event_register_list (&mca_pml_ob1_component.pmlm_version, mca_pml_ob1_events, MCA_PML_OB1_EVENT_MAX); return OMPI_SUCCESS; } diff --git a/ompi/mca/pml/ob1/pml_ob1_irecv.c b/ompi/mca/pml/ob1/pml_ob1_irecv.c index 4ccb8ea00f2..4f54c6a5f85 100644 --- a/ompi/mca/pml/ob1/pml_ob1_irecv.c +++ b/ompi/mca/pml/ob1/pml_ob1_irecv.c @@ -10,7 +10,7 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. - * Copyright (c) 2007-2016 Los Alamos National Security, LLC. All rights + * Copyright (c) 2007-2018 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2010-2012 Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011 Sandia National Laboratories. All rights reserved. @@ -60,9 +60,8 @@ int mca_pml_ob1_irecv_init(void *addr, addr, count, datatype, src, tag, comm, true); - PERUSE_TRACE_COMM_EVENT (PERUSE_COMM_REQ_ACTIVATE, - &((recvreq)->req_recv.req_base), - PERUSE_RECV); + mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_REQUEST_ACTIVATE].event, + MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, comm, NULL, &recvreq); /* Work around a leak in start by marking this request as complete. The * problem occurred because we do not have a way to differentiate an @@ -92,9 +91,8 @@ int mca_pml_ob1_irecv(void *addr, addr, count, datatype, src, tag, comm, false); - PERUSE_TRACE_COMM_EVENT (PERUSE_COMM_REQ_ACTIVATE, - &((recvreq)->req_recv.req_base), - PERUSE_RECV); + mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_REQUEST_ACTIVATE].event, + MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, comm, NULL, &recvreq); MCA_PML_OB1_RECV_REQUEST_START(recvreq); *request = (ompi_request_t *) recvreq; @@ -128,9 +126,8 @@ int mca_pml_ob1_recv(void *addr, MCA_PML_OB1_RECV_REQUEST_INIT(recvreq, addr, count, datatype, src, tag, comm, false); - PERUSE_TRACE_COMM_EVENT (PERUSE_COMM_REQ_ACTIVATE, - &(recvreq->req_recv.req_base), - PERUSE_RECV); + mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_REQUEST_ACTIVATE].event, + MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, comm, NULL, &recvreq); MCA_PML_OB1_RECV_REQUEST_START(recvreq); ompi_request_wait_completion(&recvreq->req_recv.req_base.req_ompi); @@ -221,9 +218,8 @@ mca_pml_ob1_imrecv( void *buf, src, tag, comm, false); OBJ_RELEASE(comm); - PERUSE_TRACE_COMM_EVENT (PERUSE_COMM_REQ_ACTIVATE, - &((recvreq)->req_recv.req_base), - PERUSE_RECV); + mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_REQUEST_ACTIVATE].event, + MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, comm, NULL, &recvreq); /* init/re-init the request */ recvreq->req_lock = 0; @@ -314,9 +310,8 @@ mca_pml_ob1_mrecv( void *buf, src, tag, comm, false); OBJ_RELEASE(comm); - PERUSE_TRACE_COMM_EVENT (PERUSE_COMM_REQ_ACTIVATE, - &((recvreq)->req_recv.req_base), - PERUSE_RECV); + mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_REQUEST_ACTIVATE].event, + MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, comm, NULL, &recvreq); /* init/re-init the request */ recvreq->req_lock = 0; diff --git a/ompi/mca/pml/ob1/pml_ob1_isend.c b/ompi/mca/pml/ob1/pml_ob1_isend.c index b3e1741a239..a3e8c65404d 100644 --- a/ompi/mca/pml/ob1/pml_ob1_isend.c +++ b/ompi/mca/pml/ob1/pml_ob1_isend.c @@ -10,7 +10,7 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. - * Copyright (c) 2007-2016 Los Alamos National Security, LLC. All rights + * Copyright (c) 2007-2018 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2014-2021 Cisco Systems, Inc. All rights reserved * Copyright (c) 2015 Research Organization for Information Science @@ -61,9 +61,8 @@ int mca_pml_ob1_isend_init(const void *buf, MCA_PML_OB1_SEND_REQUEST_INIT(sendreq, buf, count, datatype, dst, tag, comm, sendmode, true, ob1_proc); - PERUSE_TRACE_COMM_EVENT (PERUSE_COMM_REQ_ACTIVATE, - &(sendreq)->req_send.req_base, - PERUSE_SEND); + mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_REQUEST_ACTIVATE].event, + MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, comm, NULL, &sendreq); /* Work around a leak in start by marking this request as complete. The * problem occurred because we do not have a way to differentiate an @@ -207,9 +206,8 @@ int mca_pml_ob1_isend(const void *buf, dst, tag, comm, sendmode, false, ob1_proc); - PERUSE_TRACE_COMM_EVENT (PERUSE_COMM_REQ_ACTIVATE, - &(sendreq)->req_send.req_base, - PERUSE_SEND); + mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_REQUEST_ACTIVATE].event, + MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, comm, NULL, &sendreq); MCA_PML_OB1_SEND_REQUEST_START_W_SEQ(sendreq, endpoint, seqn, rc); *request = (ompi_request_t *) sendreq; @@ -318,9 +316,8 @@ int mca_pml_ob1_send(const void *buf, MCA_PML_OB1_SEND_REQUEST_INIT(sendreq, buf, count, datatype, dst, tag, comm, sendmode, false, ob1_proc); - PERUSE_TRACE_COMM_EVENT (PERUSE_COMM_REQ_ACTIVATE, - &sendreq->req_send.req_base, - PERUSE_SEND); + mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_REQUEST_ACTIVATE].event, + MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, comm, NULL, &sendreq); MCA_PML_OB1_SEND_REQUEST_START_W_SEQ(sendreq, endpoint, seqn, rc); if (OPAL_LIKELY(rc == OMPI_SUCCESS)) { diff --git a/ompi/mca/pml/ob1/pml_ob1_recvfrag.c b/ompi/mca/pml/ob1/pml_ob1_recvfrag.c index a3db1458938..f8763f32f77 100644 --- a/ompi/mca/pml/ob1/pml_ob1_recvfrag.c +++ b/ompi/mca/pml/ob1/pml_ob1_recvfrag.c @@ -13,7 +13,7 @@ * Copyright (c) 2008 UT-Battelle, LLC. All rights reserved. * Copyright (c) 2006-2008 University of Houston. All rights reserved. * Copyright (c) 2009-2010 Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012-2015 Los Alamos National Security, LLC. All rights + * Copyright (c) 2012-2018 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. @@ -494,8 +494,8 @@ void mca_pml_ob1_recv_frag_callback_match (mca_btl_base_module_t *btl, * figure out if the messages are not received in the correct * order (if multiple network interfaces). */ - PERUSE_TRACE_MSG_EVENT(PERUSE_COMM_MSG_ARRIVED, comm_ptr, - hdr->hdr_src, hdr->hdr_tag, PERUSE_RECV); + mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_MESSAGE_ARRIVED].event, + MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, comm_ptr, NULL, hdr); /* get next expected message sequence number - if threaded * run, lock to make sure that if another thread is processing @@ -541,8 +541,8 @@ void mca_pml_ob1_recv_frag_callback_match (mca_btl_base_module_t *btl, * received in the correct sequence. Otherwise, we delay the event * generation until we reach the correct sequence number. */ - PERUSE_TRACE_MSG_EVENT(PERUSE_COMM_SEARCH_POSTED_Q_BEGIN, comm_ptr, - hdr->hdr_src, hdr->hdr_tag, PERUSE_RECV); + mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_SEARCH_POSTED_BEGIN].event, + MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, comm_ptr, NULL, hdr); match = match_one(btl, hdr, segments, num_segments, comm_ptr, proc, NULL); @@ -550,8 +550,8 @@ void mca_pml_ob1_recv_frag_callback_match (mca_btl_base_module_t *btl, * before going into check_cantmatch_for_match so we can make * a difference for the searching time for all messages. */ - PERUSE_TRACE_MSG_EVENT(PERUSE_COMM_SEARCH_POSTED_Q_END, comm_ptr, - hdr->hdr_src, hdr->hdr_tag, PERUSE_RECV); + mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_SEARCH_POSTED_END].event, + MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, comm_ptr, NULL, hdr); /* release matching lock before processing fragment */ OB1_MATCHING_UNLOCK(&comm->matching_lock); @@ -897,8 +897,9 @@ static mca_pml_ob1_recv_request_t *match_incomming(const mca_pml_ob1_match_hdr_t req_tag = (*match)->req_recv.req_base.req_tag; if(req_tag == tag || (req_tag == OMPI_ANY_TAG && tag >= 0)) { opal_list_remove_item(queue, (opal_list_item_t*)(*match)); - PERUSE_TRACE_COMM_EVENT(PERUSE_COMM_REQ_REMOVE_FROM_POSTED_Q, - &((*match)->req_recv.req_base), PERUSE_RECV); + mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_POSTED_REMOVE].event, + MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, + (*match)->req_recv.req_base.req_comm, NULL, match); return *match; } @@ -925,8 +926,9 @@ static mca_pml_ob1_recv_request_t *match_incomming_no_any_source (const mca_pml_ if (req_tag == tag || (req_tag == OMPI_ANY_TAG && tag >= 0)) { opal_list_remove_item (&proc->specific_receives, (opal_list_item_t *) recv_req); - PERUSE_TRACE_COMM_EVENT(PERUSE_COMM_REQ_REMOVE_FROM_POSTED_Q, - &(recv_req->req_recv.req_base), PERUSE_RECV); + mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_POSTED_REMOVE].event, + MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, + recv_req->req_recv.req_base.req_comm, NULL, &recv_req); return recv_req; } } @@ -992,8 +994,9 @@ static mca_pml_ob1_recv_request_t *match_one (mca_btl_base_module_t *btl, return NULL; } - PERUSE_TRACE_COMM_EVENT(PERUSE_COMM_MSG_MATCH_POSTED_REQ, - &(match->req_recv.req_base), PERUSE_RECV); + mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_POSTED_REMOVE].event, + MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, + match->req_recv.req_base.req_comm, NULL, &match); SPC_TIMER_STOP(OMPI_SPC_MATCH_TIME, &timer); return match; } @@ -1009,9 +1012,10 @@ static mca_pml_ob1_recv_request_t *match_one (mca_btl_base_module_t *btl, SPC_RECORD(OMPI_SPC_UNEXPECTED, 1); SPC_RECORD(OMPI_SPC_UNEXPECTED_IN_QUEUE, 1); SPC_UPDATE_WATERMARK(OMPI_SPC_MAX_UNEXPECTED_IN_QUEUE, OMPI_SPC_UNEXPECTED_IN_QUEUE); - PERUSE_TRACE_MSG_EVENT(PERUSE_COMM_MSG_INSERT_IN_UNEX_Q, comm_ptr, - hdr->hdr_src, hdr->hdr_tag, PERUSE_RECV); - SPC_TIMER_STOP(OMPI_SPC_MATCH_TIME, &timer); + + mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_UNEX_INSERT].event, + MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, comm, NULL, hdr); + SPC_TIMER_STOP(OMPI_SPC_MATCH_TIME, &timer); return NULL; } while(true); } @@ -1084,8 +1088,8 @@ static int mca_pml_ob1_recv_frag_match (mca_btl_base_module_t *btl, * figure out if the messages are not received in the correct * order (if multiple network interfaces). */ - PERUSE_TRACE_MSG_EVENT(PERUSE_COMM_MSG_ARRIVED, comm_ptr, - hdr->hdr_src, hdr->hdr_tag, PERUSE_RECV); + mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_MESSAGE_ARRIVED].event, + MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, comm_ptr, NULL, hdr); /* get next expected message sequence number - if threaded * run, lock to make sure that if another thread is processing @@ -1180,8 +1184,8 @@ mca_pml_ob1_recv_frag_match_proc (mca_btl_base_module_t *btl, * received in the correct sequence. Otherwise, we delay the event * generation until we reach the correct sequence number. */ - PERUSE_TRACE_MSG_EVENT(PERUSE_COMM_SEARCH_POSTED_Q_BEGIN, comm_ptr, - hdr->hdr_src, hdr->hdr_tag, PERUSE_RECV); + mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_SEARCH_POSTED_BEGIN].event, + MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, comm_ptr, NULL, hdr); match = match_one(btl, hdr, segments, num_segments, comm_ptr, proc, frag); @@ -1189,8 +1193,8 @@ mca_pml_ob1_recv_frag_match_proc (mca_btl_base_module_t *btl, * before going into check_cantmatch_for_match we can make a * difference for the searching time for all messages. */ - PERUSE_TRACE_MSG_EVENT(PERUSE_COMM_SEARCH_POSTED_Q_END, comm_ptr, - hdr->hdr_src, hdr->hdr_tag, PERUSE_RECV); + mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_SEARCH_POSTED_END].event, + MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, comm_ptr, NULL, hdr); /* release matching lock before processing fragment */ OB1_MATCHING_UNLOCK(&comm->matching_lock); diff --git a/ompi/mca/pml/ob1/pml_ob1_recvreq.c b/ompi/mca/pml/ob1/pml_ob1_recvreq.c index 57aba677a8a..a71045cebfb 100644 --- a/ompi/mca/pml/ob1/pml_ob1_recvreq.c +++ b/ompi/mca/pml/ob1/pml_ob1_recvreq.c @@ -13,7 +13,7 @@ * Copyright (c) 2008 UT-Battelle, LLC. All rights reserved. * Copyright (c) 2011 Sandia National Laboratories. All rights reserved. * Copyright (c) 2012-2015 NVIDIA Corporation. All rights reserved. - * Copyright (c) 2011-2017 Los Alamos National Security, LLC. All rights + * Copyright (c) 2011-2018 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2012 FUJITSU LIMITED. All rights reserved. * Copyright (c) 2014-2016 Research Organization for Information Science @@ -74,8 +74,9 @@ static int mca_pml_ob1_recv_request_free(struct ompi_request_t** request) assert (false == recvreq->req_recv.req_base.req_free_called); recvreq->req_recv.req_base.req_free_called = true; - PERUSE_TRACE_COMM_EVENT( PERUSE_COMM_REQ_NOTIFY, - &(recvreq->req_recv.req_base), PERUSE_RECV ); + mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_REQUEST_FREE].event, + MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, + recvreq->req_recv.req_base.req_comm, NULL, &recvreq); if (recvreq->req_recv.req_base.req_pml_complete) { /* make buffer defined when the request is completed, @@ -148,6 +149,10 @@ static int mca_pml_ob1_recv_request_cancel(struct ompi_request_t* ompi_request, return OMPI_SUCCESS; #endif /*OPAL_ENABLE_FT_MPI*/ } + + void *req = &(request->req_recv.req_base); + mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_RECEIVE_CANCELED].event, + MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, comm, NULL, &req); /** * As now the PML is done with this request we have to force the pml_complete * to true. Otherwise, the request will never be freed. @@ -449,6 +454,7 @@ static void mca_pml_ob1_rget_completion (mca_btl_base_module_t* btl, struct mca_ static int mca_pml_ob1_recv_request_put_frag (mca_pml_ob1_rdma_frag_t *frag) { mca_pml_ob1_recv_request_t *recvreq = (mca_pml_ob1_recv_request_t *) frag->rdma_req; + ompi_communicator_t *comm = recvreq->req_recv.req_base.req_comm; #if OPAL_ENABLE_HETEROGENEOUS_SUPPORT ompi_proc_t* proc = (ompi_proc_t*)recvreq->req_recv.req_base.req_proc; #endif @@ -488,9 +494,10 @@ static int mca_pml_ob1_recv_request_put_frag (mca_pml_ob1_rdma_frag_t *frag) recvreq->req_ack_sent = true; - PERUSE_TRACE_COMM_OMPI_EVENT( PERUSE_COMM_REQ_XFER_CONTINUE, - &(recvreq->req_recv.req_base), frag->rdma_length, - PERUSE_RECV); + mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_TRANSFER].event, + MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, comm, NULL, + &((mca_pml_ob1_transfer_event_t) {.request = recvreq, .length = frag->rdma_length})); + /* send rdma request to peer */ rc = mca_bml_base_send (bml_btl, ctl, MCA_PML_OB1_HDR_TYPE_PUT); @@ -529,9 +536,9 @@ int mca_pml_ob1_recv_request_get_frag (mca_pml_ob1_rdma_frag_t *frag) local_handle = recvreq->local_handle; } - PERUSE_TRACE_COMM_OMPI_EVENT(PERUSE_COMM_REQ_XFER_CONTINUE, - &(((mca_pml_ob1_recv_request_t *) frag->rdma_req)->req_recv.req_base), - frag->rdma_length, PERUSE_RECV); + mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_TRANSFER].event, + MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, recvreq->req_recv.req_base.req_comm, NULL, + &((mca_pml_ob1_transfer_event_t){.request = frag->rdma_req, .length = frag->rdma_length})); /* queue up get request */ rc = mca_bml_base_get (bml_btl, frag->local_address, frag->remote_address, local_handle, @@ -546,9 +553,6 @@ int mca_pml_ob1_recv_request_get_frag (mca_pml_ob1_rdma_frag_t *frag) return OMPI_SUCCESS; } - - - /* * Update the recv request status to reflect the number of bytes * received and actually delivered to the application. @@ -1116,16 +1120,15 @@ static inline void append_recv_req_to_queue(opal_list_t *queue, { opal_list_append(queue, (opal_list_item_t*)req); -#if OMPI_WANT_PERUSE /** * We don't want to generate this kind of event for MPI_Probe. */ if (req->req_recv.req_base.req_type != MCA_PML_REQUEST_PROBE && req->req_recv.req_base.req_type != MCA_PML_REQUEST_MPROBE) { - PERUSE_TRACE_COMM_EVENT(PERUSE_COMM_REQ_INSERT_IN_POSTED_Q, - &(req->req_recv.req_base), PERUSE_RECV); + ompi_communicator_t *comm = req->req_recv.req_base.req_comm; + mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_POSTED_INSERT].event, + MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, comm, NULL, &req); } -#endif } /* @@ -1288,8 +1291,8 @@ void mca_pml_ob1_recv_req_start(mca_pml_ob1_recv_request_t *req) * The laps of time between the ACTIVATE event and the SEARCH_UNEX one include * the cost of the request lock. */ - PERUSE_TRACE_COMM_EVENT(PERUSE_COMM_SEARCH_UNEX_Q_BEGIN, - &(req->req_recv.req_base), PERUSE_RECV); + mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_SEARCH_UNEX_BEGIN].event, + MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, comm, NULL, &req); /* assign sequence number */ req->req_recv.req_base.req_sequence = ob1_comm->recv_sequence++; @@ -1348,8 +1351,8 @@ void mca_pml_ob1_recv_req_start(mca_pml_ob1_recv_request_t *req) } if(OPAL_UNLIKELY(NULL == frag)) { - PERUSE_TRACE_COMM_EVENT(PERUSE_COMM_SEARCH_UNEX_Q_END, - &(req->req_recv.req_base), PERUSE_RECV); + mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_SEARCH_UNEX_END].event, + MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, comm, NULL, &req); /* We didn't find any matches. Record this irecv so we can match it when the message comes in. */ if(OPAL_LIKELY(req->req_recv.req_base.req_type != MCA_PML_REQUEST_IPROBE && @@ -1365,18 +1368,13 @@ void mca_pml_ob1_recv_req_start(mca_pml_ob1_recv_request_t *req) OB1_MATCHING_UNLOCK(&ob1_comm->matching_lock); } else { if(OPAL_LIKELY(!IS_PROB_REQ(req))) { - PERUSE_TRACE_COMM_EVENT(PERUSE_COMM_REQ_MATCH_UNEX, - &(req->req_recv.req_base), PERUSE_RECV); - hdr = (mca_pml_ob1_hdr_t*)frag->segments->seg_addr.pval; - PERUSE_TRACE_MSG_EVENT(PERUSE_COMM_MSG_REMOVE_FROM_UNEX_Q, - req->req_recv.req_base.req_comm, - hdr->hdr_match.hdr_src, - hdr->hdr_match.hdr_tag, - PERUSE_RECV); - PERUSE_TRACE_COMM_EVENT(PERUSE_COMM_SEARCH_UNEX_Q_END, - &(req->req_recv.req_base), PERUSE_RECV); + mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_UNEX_REMOVE].event, + MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, comm, NULL, &hdr->hdr_match); + + mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_SEARCH_UNEX_END].event, + MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, comm, NULL, &req); #if MCA_PML_OB1_CUSTOM_MATCH custom_match_umq_remove_hold(req->req_recv.req_base.req_comm->c_pml_comm->umq, hold_prev, hold_elem, hold_index); diff --git a/ompi/mca/pml/ob1/pml_ob1_recvreq.h b/ompi/mca/pml/ob1/pml_ob1_recvreq.h index 402d3f4dcec..18362bc44f8 100644 --- a/ompi/mca/pml/ob1/pml_ob1_recvreq.h +++ b/ompi/mca/pml/ob1/pml_ob1_recvreq.h @@ -124,8 +124,9 @@ do { \ */ #define MCA_PML_OB1_RECV_REQUEST_MPI_COMPLETE( recvreq ) \ do { \ - PERUSE_TRACE_COMM_EVENT( PERUSE_COMM_REQ_COMPLETE, \ - &(recvreq->req_recv.req_base), PERUSE_RECV ); \ + mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_REQUEST_COMPLETE].event, \ + MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, \ + (recvreq)->req_recv.req_base.req_comm, NULL, &(recvreq)); \ ompi_request_complete( &(recvreq->req_recv.req_base.req_ompi), true ); \ } while (0) @@ -162,8 +163,9 @@ recv_request_pml_complete(mca_pml_ob1_recv_request_t *recvreq) if(false == recvreq->req_recv.req_base.req_pml_complete){ if(recvreq->req_recv.req_bytes_packed > 0) { - PERUSE_TRACE_COMM_EVENT( PERUSE_COMM_REQ_XFER_END, - &recvreq->req_recv.req_base, PERUSE_RECV ); + mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_TRANSFER_END].event, + MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, + recvreq->req_recv.req_base.req_comm, NULL, &recvreq); } for(i = 0; i < recvreq->req_rdma_cnt; i++) { @@ -258,8 +260,9 @@ static inline void recv_req_matched(mca_pml_ob1_recv_request_t *req, prepare_recv_req_converter(req); } #endif /* OPAL_ENABLE_HETEROGENEOUS_SUPPORT */ - PERUSE_TRACE_COMM_EVENT(PERUSE_COMM_REQ_XFER_BEGIN, - &req->req_recv.req_base, PERUSE_RECV); + mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_TRANSFER_BEGIN].event, + MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, + req->req_recv.req_base.req_comm, NULL, &req); } } @@ -268,7 +271,7 @@ static inline void recv_req_matched(mca_pml_ob1_recv_request_t *req, * */ -#define MCA_PML_OB1_RECV_REQUEST_UNPACK( request, \ +#define MCA_PML_OB1_RECV_REQUEST_UNPACK( req, \ segments, \ num_segments, \ seg_offset, \ @@ -277,7 +280,7 @@ static inline void recv_req_matched(mca_pml_ob1_recv_request_t *req, bytes_delivered) \ do { \ bytes_delivered = 0; \ - if(request->req_recv.req_bytes_packed > 0) { \ + if((req)->req_recv.req_bytes_packed > 0) { \ struct iovec iov[MCA_BTL_DES_MAX_SEGMENTS]; \ uint32_t iov_count = 0; \ size_t max_data = bytes_received; \ @@ -295,18 +298,21 @@ do { offset = 0; \ } \ } \ - OPAL_THREAD_LOCK(&request->lock); \ - PERUSE_TRACE_COMM_OMPI_EVENT (PERUSE_COMM_REQ_XFER_CONTINUE, \ - &(request->req_recv.req_base), max_data, \ - PERUSE_RECV); \ - opal_convertor_set_position( &(request->req_recv.req_base.req_convertor), \ + OPAL_THREAD_LOCK(&(req)->lock); \ + \ + mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_TRANSFER].event, \ + MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, \ + (req)->req_recv.req_base.req_comm, NULL, \ + &((mca_pml_ob1_transfer_event_t){.request = req, .length = max_data})); \ + \ + opal_convertor_set_position( &((req)->req_recv.req_base.req_convertor), \ &data_offset ); \ - opal_convertor_unpack( &(request)->req_recv.req_base.req_convertor, \ + opal_convertor_unpack( &(req)->req_recv.req_base.req_convertor, \ iov, \ &iov_count, \ &max_data ); \ bytes_delivered = max_data; \ - OPAL_THREAD_UNLOCK(&request->lock); \ + OPAL_THREAD_UNLOCK(&(req)->lock); \ } \ } while (0) diff --git a/ompi/mca/pml/ob1/pml_ob1_sendreq.c b/ompi/mca/pml/ob1/pml_ob1_sendreq.c index 0dd246917c0..c3598925683 100644 --- a/ompi/mca/pml/ob1/pml_ob1_sendreq.c +++ b/ompi/mca/pml/ob1/pml_ob1_sendreq.c @@ -13,7 +13,7 @@ * Copyright (c) 2008 UT-Battelle, LLC. All rights reserved. * Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012 NVIDIA Corporation. All rights reserved. - * Copyright (c) 2012-2016 Los Alamos National Security, LLC. All rights + * Copyright (c) 2012-2018 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2015 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2016 Research Organization for Information Science @@ -107,8 +107,9 @@ static int mca_pml_ob1_send_request_free(struct ompi_request_t** request) if(false == sendreq->req_send.req_base.req_free_called) { sendreq->req_send.req_base.req_free_called = true; - PERUSE_TRACE_COMM_EVENT( PERUSE_COMM_REQ_NOTIFY, - &(sendreq->req_send.req_base), PERUSE_SEND ); + mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_REQUEST_FREE].event, + MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, + sendreq->req_send.req_base.req_comm, NULL, &sendreq); if (sendreq->req_send.req_base.req_pml_complete) { /* make buffer defined when the request is completed, @@ -208,8 +209,10 @@ mca_pml_ob1_match_completion_free_request( mca_bml_base_btl_t* bml_btl, mca_pml_ob1_send_request_t* sendreq ) { if( sendreq->req_send.req_bytes_packed > 0 ) { - PERUSE_TRACE_COMM_EVENT( PERUSE_COMM_REQ_XFER_BEGIN, - &(sendreq->req_send.req_base), PERUSE_SEND ); + void *req = &(sendreq->req_send.req_base); + mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_TRANSFER_BEGIN].event, + MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, + sendreq->req_send.req_base.req_comm, NULL, &req); } /* signal request completion */ @@ -253,8 +256,10 @@ mca_pml_ob1_rndv_completion_request( mca_bml_base_btl_t* bml_btl, size_t req_bytes_delivered ) { if( sendreq->req_send.req_bytes_packed > 0 ) { - PERUSE_TRACE_COMM_EVENT( PERUSE_COMM_REQ_XFER_BEGIN, - &(sendreq->req_send.req_base), PERUSE_SEND ); + void *req = &(sendreq->req_send.req_base); + mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_TRANSFER_BEGIN].event, + MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, + sendreq->req_send.req_base.req_comm, NULL, &req); } OPAL_THREAD_ADD_FETCH_SIZE_T(&sendreq->req_bytes_delivered, req_bytes_delivered); @@ -908,8 +913,10 @@ int mca_pml_ob1_send_request_start_rdma( mca_pml_ob1_send_request_t* sendreq, * sent the GET message ... */ if( sendreq->req_send.req_bytes_packed > 0 ) { - PERUSE_TRACE_COMM_EVENT( PERUSE_COMM_REQ_XFER_BEGIN, - &(sendreq->req_send.req_base), PERUSE_SEND ); + void *req = &(sendreq->req_send.req_base); + mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_TRANSFER_BEGIN].event, + MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, + sendreq->req_send.req_base.req_comm, NULL, &req); } /* send */ @@ -1216,10 +1223,10 @@ mca_pml_ob1_send_request_schedule_once(mca_pml_ob1_send_request_t* sendreq) ob1_hdr_hton(hdr, MCA_PML_OB1_HDR_TYPE_FRAG, sendreq->req_send.req_base.req_proc); -#if OMPI_WANT_PERUSE - PERUSE_TRACE_COMM_OMPI_EVENT(PERUSE_COMM_REQ_XFER_CONTINUE, - &(sendreq->req_send.req_base), size, PERUSE_SEND); -#endif /* OMPI_WANT_PERUSE */ + void *req = &(sendreq->req_send.req_base); + mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_TRANSFER].event, + MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, + sendreq->req_send.req_base.req_comm, NULL, &req); /* At this point, check to see if the BTL is doing an asynchronous * copy. This would have been initiated in the mca_bml_base_prepare_src @@ -1376,8 +1383,10 @@ int mca_pml_ob1_send_request_put_frag( mca_pml_ob1_rdma_frag_t *frag ) } } - PERUSE_TRACE_COMM_OMPI_EVENT( PERUSE_COMM_REQ_XFER_CONTINUE, - &(((mca_pml_ob1_send_request_t*)frag->rdma_req)->req_send.req_base), frag->rdma_length, PERUSE_SEND ); + void *req = &(((mca_pml_ob1_send_request_t*)frag->rdma_req)->req_send.req_base); + mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_TRANSFER].event, + MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, + sendreq->req_send.req_base.req_comm, NULL, &req); rc = mca_bml_base_put (bml_btl, frag->local_address, frag->remote_address, local_handle, (mca_btl_base_registration_handle_t *) frag->remote_handle, frag->rdma_length, diff --git a/ompi/mca/pml/ob1/pml_ob1_sendreq.h b/ompi/mca/pml/ob1/pml_ob1_sendreq.h index 1d50ecc033d..df6bb23ad57 100644 --- a/ompi/mca/pml/ob1/pml_ob1_sendreq.h +++ b/ompi/mca/pml/ob1/pml_ob1_sendreq.h @@ -211,8 +211,9 @@ do { (sendreq)->req_send.req_base.req_tag; \ (sendreq)->req_send.req_base.req_ompi.req_status._ucount = \ (sendreq)->req_send.req_bytes_packed; \ - PERUSE_TRACE_COMM_EVENT( PERUSE_COMM_REQ_COMPLETE, \ - &(sendreq->req_send.req_base), PERUSE_SEND); \ + mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_REQUEST_COMPLETE].event, \ + MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, \ + (sendreq)->req_send.req_base.req_comm, NULL, &(sendreq)); \ \ ompi_request_complete( &((sendreq)->req_send.req_base.req_ompi), (with_signal) ); \ } while(0) @@ -260,8 +261,9 @@ send_request_pml_complete(mca_pml_ob1_send_request_t *sendreq) { if(false == sendreq->req_send.req_base.req_pml_complete) { if(sendreq->req_send.req_bytes_packed > 0) { - PERUSE_TRACE_COMM_EVENT( PERUSE_COMM_REQ_XFER_END, - &(sendreq->req_send.req_base), PERUSE_SEND); + mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_TRANSFER_END].event, + MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, + sendreq->req_send.req_base.req_comm, NULL, &sendreq); } /* return mpool resources */ diff --git a/ompi/mpi/tool/event_callback_get_info.c b/ompi/mpi/tool/event_callback_get_info.c index 92519a13aac..220f6543044 100644 --- a/ompi/mpi/tool/event_callback_get_info.c +++ b/ompi/mpi/tool/event_callback_get_info.c @@ -14,25 +14,39 @@ * $HEADER$ */ - -#include "ompi_config.h" #include "ompi/mpi/tool/mpit-internal.h" -#if OMPI_BUILD_MPI_PROFILING -#if OPAL_HAVE_WEAK_SYMBOLS +#if OPAL_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES #pragma weak MPI_T_event_callback_get_info = PMPI_T_event_callback_get_info #endif -#define MPI_T_event_callback_get_info PMPI_T_event_callback_get_info + +#if OMPI_PROFILING_DEFINES +#include "ompi/mpi/tool/profile/defines.h" #endif int MPI_T_event_callback_get_info (MPI_T_event_registration event_registration, MPI_T_cb_safety cb_safety, MPI_Info *info_used) { + ompi_info_t *info; + int ret; + if (!mpit_is_initialized ()) { return MPI_T_ERR_NOT_INITIALIZED; } - return MPI_T_ERR_INVALID_HANDLE; -} + info = OBJ_NEW(ompi_info_t); + if (NULL == info) { + return ompit_opal_to_mpit_error(OMPI_ERR_OUT_OF_RESOURCE); + } + + /* mca_base_cb_safety_t and MPI_T_cb_safety must be kept in sync for this to work */ + ret = mca_base_event_callback_get_info (event_registration, (mca_base_cb_safety_t) cb_safety, &info->super); + if (OPAL_SUCCESS != ret) { + OBJ_RELEASE(info); + } else { + *info_used = info; + } + return ompit_opal_to_mpit_error(ret); +} diff --git a/ompi/mpi/tool/event_callback_set_info.c b/ompi/mpi/tool/event_callback_set_info.c index 5f78d2c92de..daf356cf656 100644 --- a/ompi/mpi/tool/event_callback_set_info.c +++ b/ompi/mpi/tool/event_callback_set_info.c @@ -14,23 +14,28 @@ * $HEADER$ */ -#include "ompi_config.h" - #include "ompi/mpi/tool/mpit-internal.h" -#if OMPI_BUILD_MPI_PROFILING -#if OPAL_HAVE_WEAK_SYMBOLS +#if OPAL_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES #pragma weak MPI_T_event_callback_set_info = PMPI_T_event_callback_set_info #endif -#define MPI_T_event_callback_set_info PMPI_T_event_callback_set_info + +#if OMPI_PROFILING_DEFINES +#include "ompi/mpi/tool/profile/defines.h" #endif + int MPI_T_event_callback_set_info (MPI_T_event_registration event_registration, MPI_T_cb_safety cb_safety, MPI_Info info) { + int ret; + if (!mpit_is_initialized ()) { return MPI_T_ERR_NOT_INITIALIZED; } - return MPI_T_ERR_INVALID_HANDLE; + /* mca_base_cb_safety_t and MPI_T_cb_safety must be kept in sync for this to work */ + ret = mca_base_event_callback_set_info (event_registration, (mca_base_cb_safety_t) cb_safety, &info->super); + + return ompit_opal_to_mpit_error(ret); } diff --git a/ompi/mpi/tool/event_copy.c b/ompi/mpi/tool/event_copy.c index f0c64bad822..f68711629f8 100644 --- a/ompi/mpi/tool/event_copy.c +++ b/ompi/mpi/tool/event_copy.c @@ -13,15 +13,14 @@ * $HEADER$ */ -#include "ompi_config.h" - #include "ompi/mpi/tool/mpit-internal.h" -#if OMPI_BUILD_MPI_PROFILING -#if OPAL_HAVE_WEAK_SYMBOLS +#if OPAL_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES #pragma weak MPI_T_event_copy = PMPI_T_event_copy #endif -#define MPI_T_event_copy PMPI_T_event_copy + +#if OMPI_PROFILING_DEFINES +#include "ompi/mpi/tool/profile/defines.h" #endif @@ -31,5 +30,6 @@ int MPI_T_event_copy (MPI_T_event_instance event, void *buffer) return MPI_T_ERR_NOT_INITIALIZED; } - return MPI_T_ERR_INVALID_HANDLE; + mca_base_event_copy (event, buffer); + return MPI_SUCCESS; } diff --git a/ompi/mpi/tool/event_get_index.c b/ompi/mpi/tool/event_get_index.c index 0c0ec50cf39..08b0aaabfe0 100644 --- a/ompi/mpi/tool/event_get_index.c +++ b/ompi/mpi/tool/event_get_index.c @@ -12,19 +12,21 @@ * $HEADER$ */ -#include "ompi_config.h" - #include "ompi/mpi/tool/mpit-internal.h" -#if OMPI_BUILD_MPI_PROFILING -#if OPAL_HAVE_WEAK_SYMBOLS +#if OPAL_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES #pragma weak MPI_T_event_get_index = PMPI_T_event_get_index #endif -#define MPI_T_event_get_index PMPI_T_event_get_index + +#if OMPI_PROFILING_DEFINES +#include "ompi/mpi/tool/profile/defines.h" #endif + int MPI_T_event_get_index (const char *name, int *event_index) { + mca_base_event_t *event = NULL; + if (!mpit_is_initialized ()) { return MPI_T_ERR_NOT_INITIALIZED; } @@ -33,5 +35,14 @@ int MPI_T_event_get_index (const char *name, int *event_index) return MPI_ERR_ARG; } - return MPI_T_ERR_INVALID_NAME; + ompi_mpit_lock (); + (void) mca_base_event_get_by_fullname (name, &event); + ompi_mpit_unlock (); + + if (NULL == event) { + return MPI_T_ERR_INVALID_NAME; + } + + *event_index = event->event_index; + return MPI_SUCCESS; } diff --git a/ompi/mpi/tool/event_get_info.c b/ompi/mpi/tool/event_get_info.c index f7fd9134379..d1839d5799a 100644 --- a/ompi/mpi/tool/event_get_info.c +++ b/ompi/mpi/tool/event_get_info.c @@ -13,26 +13,105 @@ * $HEADER$ */ -#include "ompi_config.h" - #include "ompi/mpi/tool/mpit-internal.h" -#if OMPI_BUILD_MPI_PROFILING +/* needed to convert between opal and ompi datatypes until a function is provided */ +#include "ompi/datatype/ompi_datatype_internal.h" + +#if OMPI_PROFILING_DEFINES + #if OPAL_HAVE_WEAK_SYMBOLS #pragma weak MPI_T_event_get_info = PMPI_T_event_get_info #endif -#define MPI_T_event_get_info PMPI_T_event_get_info + +#include "ompi/mpi/tool/profile/defines.h" #endif int MPI_T_event_get_info (int event_index, char *name, int *name_len, int *verbosity, MPI_Datatype *array_of_datatypes, MPI_Aint *array_of_displacements, int *num_elements, - MPI_T_enum *enumtype, MPI_Info *info, + MPI_Aint *extent, MPI_T_enum *enumtype, MPI_Info *info, char *desc, int *desc_len, int *bind) { + mca_base_event_t * const event; + int ret, max_datatypes = 0; + if (!mpit_is_initialized ()) { return MPI_T_ERR_NOT_INITIALIZED; } - return MPI_T_ERR_INVALID_INDEX; + ompi_mpit_lock (); + + do { + /* Find the performance variable. mca_base_event_get() handles the + bounds checking. */ + ret = mca_base_event_get_by_index (event_index, (mca_base_event_t **) &event); + if (OMPI_SUCCESS != ret) { + break; + } + + /* Check the variable binding is something sane */ + if (event->event_bind > MPI_T_BIND_MPI_INFO || event->event_bind < MPI_T_BIND_NO_OBJECT) { + /* This variable specified an invalid binding (not an MPI object). */ + ret = MPI_T_ERR_INVALID_INDEX; + break; + } + + /* Copy name and description */ + mpit_copy_string (name, name_len, event->event_name); + mpit_copy_string (desc, desc_len, event->event_description); + + max_datatypes = num_elements ? (*num_elements < (int) (event->event_datatype_count + 1) ? *num_elements - 1 : event->event_datatype_count) : 0; + + if (max_datatypes) { + if (array_of_datatypes) { + for (int i = 0 ; i < max_datatypes ; i++) { + ompi_datatype_t *ompi_datatype = NULL; + + for (int j = 0 ; j < OMPI_DATATYPE_MPI_MAX_PREDEFINED ; ++j) { + if (ompi_datatype_basicDatatypes[j]->super.id == event->event_datatypes[i]->id) { + ompi_datatype = (ompi_datatype_t *) ompi_datatype_basicDatatypes[j]; + break; + } + } + + assert (NULL != ompi_datatype); + + array_of_datatypes[i] = ompi_datatype; + } + } + + if (array_of_displacements) { + for (int i = 0 ; i < max_datatypes ; i++) { + array_of_displacements[i] = (MPI_Aint) event->event_offsets[i]; + } + } + + *num_elements = max_datatypes; + } + + if (verbosity) { + *verbosity = event->event_verbosity; + } + + if (NULL != enumtype) { + *enumtype = event->event_enumerator ? (MPI_T_enum) event->event_enumerator : MPI_T_ENUM_NULL; + } + + if (NULL != bind) { + *bind = event->event_bind; + } + + if (NULL != extent) { + *extent = event->event_extent; + } + + if (NULL != info) { + *info = OBJ_NEW(ompi_info_t); + } + } while (0); + + ompi_mpit_unlock (); + + return ret; } diff --git a/ompi/mpi/tool/event_get_num.c b/ompi/mpi/tool/event_get_num.c index 0b27caa60fc..24058785861 100644 --- a/ompi/mpi/tool/event_get_num.c +++ b/ompi/mpi/tool/event_get_num.c @@ -12,17 +12,17 @@ * $HEADER$ */ -#include "ompi_config.h" - #include "ompi/mpi/tool/mpit-internal.h" -#if OMPI_BUILD_MPI_PROFILING -#if OPAL_HAVE_WEAK_SYMBOLS +#if OPAL_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES #pragma weak MPI_T_event_get_num = PMPI_T_event_get_num #endif -#define MPI_T_event_get_num PMPI_T_event_get_num + +#if OMPI_PROFILING_DEFINES +#include "ompi/mpi/tool/profile/defines.h" #endif + int MPI_T_event_get_num (int *num_event) { if (!mpit_is_initialized ()) { @@ -33,6 +33,5 @@ int MPI_T_event_get_num (int *num_event) return MPI_ERR_ARG; } - *num_event = 0; - return MPI_SUCCESS; + return mca_base_event_get_count (num_event); } diff --git a/ompi/mpi/tool/event_get_source.c b/ompi/mpi/tool/event_get_source.c index 7ec12af587e..936cce9efe1 100644 --- a/ompi/mpi/tool/event_get_source.c +++ b/ompi/mpi/tool/event_get_source.c @@ -13,22 +13,23 @@ * $HEADER$ */ -#include "ompi_config.h" - #include "ompi/mpi/tool/mpit-internal.h" -#if OMPI_BUILD_MPI_PROFILING -#if OPAL_HAVE_WEAK_SYMBOLS +#if OPAL_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES #pragma weak MPI_T_event_get_source = PMPI_T_event_get_source #endif -#define MPI_T_event_get_source PMPI_T_event_get_source + +#if OMPI_PROFILING_DEFINES +#include "ompi/mpi/tool/profile/defines.h" #endif + int MPI_T_event_get_source (MPI_T_event_instance event, int *source_index) { if (!mpit_is_initialized ()) { return MPI_T_ERR_NOT_INITIALIZED; } - return MPI_T_ERR_INVALID_HANDLE; + mca_base_event_get_source (event, source_index); + return MPI_SUCCESS; } diff --git a/ompi/mpi/tool/event_get_timestamp.c b/ompi/mpi/tool/event_get_timestamp.c index 34fd49d5075..88edbaf0d65 100644 --- a/ompi/mpi/tool/event_get_timestamp.c +++ b/ompi/mpi/tool/event_get_timestamp.c @@ -13,22 +13,30 @@ * $HEADER$ */ -#include "ompi_config.h" - #include "ompi/mpi/tool/mpit-internal.h" -#if OMPI_BUILD_MPI_PROFILING +#if OMPI_PROFILING_DEFINES + #if OPAL_HAVE_WEAK_SYMBOLS #pragma weak MPI_T_event_get_timestamp = PMPI_T_event_get_timestamp #endif -#define MPI_T_event_get_timestamp PMPI_T_event_get_timestamp + +#include "ompi/mpi/tool/profile/defines.h" + #endif + int MPI_T_event_get_timestamp (MPI_T_event_instance event, MPI_Count *event_time) { + uint64_t mca_time; + int ret; + if (!mpit_is_initialized ()) { return MPI_T_ERR_NOT_INITIALIZED; } - return MPI_T_ERR_INVALID_HANDLE; + ret = mca_base_event_get_time (event, &mca_time); + *event_time = (MPI_Count) mca_time; + + return ompit_opal_to_mpit_error (ret); } diff --git a/ompi/mpi/tool/event_handle_alloc.c b/ompi/mpi/tool/event_handle_alloc.c index 0768cf2f879..e93a9f57163 100644 --- a/ompi/mpi/tool/event_handle_alloc.c +++ b/ompi/mpi/tool/event_handle_alloc.c @@ -13,23 +13,48 @@ * $HEADER$ */ -#include "ompi_config.h" - #include "ompi/mpi/tool/mpit-internal.h" -#if OMPI_BUILD_MPI_PROFILING -#if OPAL_HAVE_WEAK_SYMBOLS +#if OPAL_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES #pragma weak MPI_T_event_handle_alloc = PMPI_T_event_handle_alloc #endif -#define MPI_T_event_handle_alloc PMPI_T_event_handle_alloc + +#if OMPI_PROFILING_DEFINES +#include "ompi/mpi/tool/profile/defines.h" #endif + int MPI_T_event_handle_alloc (int event_index, void *obj_handle, MPI_Info info, MPI_T_event_registration *event_registration) { + mca_base_event_t * const event; + int ret; + if (!mpit_is_initialized ()) { return MPI_T_ERR_NOT_INITIALIZED; } - return MPI_T_ERR_INVALID_INDEX; + ompi_mpit_lock (); + + do { + /* Find the performance variable. mca_base_event_get() handles the + bounds checking. */ + ret = mca_base_event_get_by_index (event_index, (mca_base_event_t **) &event); + if (OMPI_SUCCESS != ret) { + break; + } + + /* Check the variable binding is something sane */ + if (event->event_bind > MPI_T_BIND_MPI_INFO || event->event_bind < MPI_T_BIND_NO_OBJECT) { + /* This variable specified an invalid binding (not an MPI object). */ + ret = MPI_T_ERR_INVALID_INDEX; + break; + } + + ret = mca_base_event_registration_alloc (event, obj_handle, &info->super, event_registration); + } while (0); + + ompi_mpit_unlock (); + + return ompit_opal_to_mpit_error(ret); } diff --git a/ompi/mpi/tool/event_handle_free.c b/ompi/mpi/tool/event_handle_free.c index 7fb756b3938..3453fdca43b 100644 --- a/ompi/mpi/tool/event_handle_free.c +++ b/ompi/mpi/tool/event_handle_free.c @@ -13,24 +13,40 @@ * $HEADER$ */ -#include "ompi_config.h" - #include "ompi/mpi/tool/mpit-internal.h" -#if OMPI_BUILD_MPI_PROFILING -#if OPAL_HAVE_WEAK_SYMBOLS +#if OPAL_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES #pragma weak MPI_T_event_handle_free = PMPI_T_event_handle_free #endif -#define MPI_T_event_handle_free PMPI_T_event_handle_free + +#if OMPI_PROFILING_DEFINES +#include "ompi/mpi/tool/profile/defines.h" #endif + int MPI_T_event_handle_free (MPI_T_event_registration event_registration, - void *user_data, MPI_T_event_free_cb_function free_cb_function) { + int ret = MPI_SUCCESS; + if (!mpit_is_initialized ()) { return MPI_T_ERR_NOT_INITIALIZED; } - return MPI_T_ERR_INVALID_HANDLE; + ompi_mpit_lock (); + + do { + /* Check that this is a valid handle */ + if (MPI_T_EVENT_REGISTRATION_NULL == event_registration) { + ret = MPI_T_ERR_INVALID_HANDLE; + break; + } + + mca_base_event_registration_free (event_registration, (mca_base_event_registration_free_cb_fn_t) free_cb_function); + /* *event_registration = MPI_T_EVENT_REGISTRATION_NULL; */ + } while (0); + + ompi_mpit_unlock (); + + return ret; } diff --git a/ompi/mpi/tool/event_handle_get_info.c b/ompi/mpi/tool/event_handle_get_info.c index 2009d67b1ef..e4636dc9306 100644 --- a/ompi/mpi/tool/event_handle_get_info.c +++ b/ompi/mpi/tool/event_handle_get_info.c @@ -14,23 +14,38 @@ * $HEADER$ */ -#include "ompi_config.h" - #include "ompi/mpi/tool/mpit-internal.h" -#if OMPI_BUILD_MPI_PROFILING -#if OPAL_HAVE_WEAK_SYMBOLS +#if OPAL_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES #pragma weak MPI_T_event_handle_get_info = PMPI_T_event_handle_get_info #endif -#define MPI_T_event_handle_get_info PMPI_T_event_handle_get_info + +#if OMPI_PROFILING_DEFINES +#include "ompi/mpi/tool/profile/defines.h" #endif + int MPI_T_event_handle_get_info (MPI_T_event_registration event_registration, MPI_Info *info_used) { + ompi_info_t *info; + int ret; + if (!mpit_is_initialized ()) { return MPI_T_ERR_NOT_INITIALIZED; } - return MPI_T_ERR_INVALID_HANDLE; + info = OBJ_NEW(ompi_info_t); + if (NULL == info) { + return ompit_opal_to_mpit_error(OMPI_ERR_OUT_OF_RESOURCE); + } + + ret = mca_base_event_handle_get_info (event_registration, &info->super); + if (OPAL_SUCCESS != ret) { + OBJ_RELEASE(info); + } else { + *info_used = info; + } + + return ompit_opal_to_mpit_error(ret); } diff --git a/ompi/mpi/tool/event_handle_set_info.c b/ompi/mpi/tool/event_handle_set_info.c index 0c35e27d2a1..5b5d1740c07 100644 --- a/ompi/mpi/tool/event_handle_set_info.c +++ b/ompi/mpi/tool/event_handle_set_info.c @@ -14,23 +14,27 @@ * $HEADER$ */ -#include "ompi_config.h" - #include "ompi/mpi/tool/mpit-internal.h" -#if OMPI_BUILD_MPI_PROFILING -#if OPAL_HAVE_WEAK_SYMBOLS +#if OPAL_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES #pragma weak MPI_T_event_handle_set_info = PMPI_T_event_handle_set_info #endif -#define MPI_T_event_handle_set_info PMPI_T_event_handle_set_info + +#if OMPI_PROFILING_DEFINES +#include "ompi/mpi/tool/profile/defines.h" #endif + int MPI_T_event_handle_set_info (MPI_T_event_registration event_registration, MPI_Info info) { + int ret; + if (!mpit_is_initialized ()) { return MPI_T_ERR_NOT_INITIALIZED; } - return MPI_T_ERR_INVALID_HANDLE; + ret = mca_base_event_handle_set_info (event_registration, &info->super); + + return ompit_opal_to_mpit_error(ret); } diff --git a/ompi/mpi/tool/event_read.c b/ompi/mpi/tool/event_read.c index e16d3e33f50..0a7a9540f3e 100644 --- a/ompi/mpi/tool/event_read.c +++ b/ompi/mpi/tool/event_read.c @@ -13,22 +13,26 @@ * $HEADER$ */ -#include "ompi_config.h" - #include "ompi/mpi/tool/mpit-internal.h" -#if OMPI_BUILD_MPI_PROFILING -#if OPAL_HAVE_WEAK_SYMBOLS +#if OPAL_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES #pragma weak MPI_T_event_read = PMPI_T_event_read #endif -#define MPI_T_event_read PMPI_T_event_read + +#if OMPI_PROFILING_DEFINES +#include "ompi/mpi/tool/profile/defines.h" #endif + int MPI_T_event_read (MPI_T_event_instance event, int element_index, void *buffer) { + int ret; + if (!mpit_is_initialized ()) { return MPI_T_ERR_NOT_INITIALIZED; } - return MPI_T_ERR_INVALID_HANDLE; + ret = mca_base_event_read (event, element_index, buffer); + + return ompit_opal_to_mpit_error (ret); } diff --git a/ompi/mpi/tool/event_register_callback.c b/ompi/mpi/tool/event_register_callback.c index 4550fabe520..45cc1073484 100644 --- a/ompi/mpi/tool/event_register_callback.c +++ b/ompi/mpi/tool/event_register_callback.c @@ -13,24 +13,34 @@ * $HEADER$ */ -#include "ompi_config.h" - #include "ompi/mpi/tool/mpit-internal.h" -#if OMPI_BUILD_MPI_PROFILING -#if OPAL_HAVE_WEAK_SYMBOLS +#if OPAL_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES #pragma weak MPI_T_event_register_callback = PMPI_T_event_register_callback #endif -#define MPI_T_event_register_callback PMPI_T_event_register_callback + +#if OMPI_PROFILING_DEFINES +#include "ompi/mpi/tool/profile/defines.h" #endif + int MPI_T_event_register_callback (MPI_T_event_registration event_registration, MPI_T_cb_safety cb_safety, MPI_Info info, void *user_data, MPI_T_event_cb_function event_cb_function) { + mca_base_event_t * const event; + int ret; + if (!mpit_is_initialized ()) { return MPI_T_ERR_NOT_INITIALIZED; } - return MPI_T_ERR_INVALID_HANDLE; + ompi_mpit_lock (); + + ret = mca_base_event_register_callback (event_registration, (mca_base_cb_safety_t) cb_safety, + &info->super, user_data, (mca_base_event_cb_fn_t) event_cb_function); + + ompi_mpit_unlock (); + + return ompit_opal_to_mpit_error(ret); } diff --git a/ompi/mpi/tool/event_set_dropped_handler.c b/ompi/mpi/tool/event_set_dropped_handler.c index fe15695abb8..5b5267edf33 100644 --- a/ompi/mpi/tool/event_set_dropped_handler.c +++ b/ompi/mpi/tool/event_set_dropped_handler.c @@ -13,15 +13,14 @@ * $HEADER$ */ -#include "ompi_config.h" - #include "ompi/mpi/tool/mpit-internal.h" -#if OMPI_BUILD_MPI_PROFILING -#if OPAL_HAVE_WEAK_SYMBOLS +#if OPAL_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES #pragma weak MPI_T_event_set_dropped_handler = PMPI_T_event_set_dropped_handler #endif -#define MPI_T_event_set_dropped_handler PMPI_T_event_set_dropped_handler + +#if OMPI_PROFILING_DEFINES +#include "ompi/mpi/tool/profile/defines.h" #endif int MPI_T_event_set_dropped_handler (MPI_T_event_registration handle, MPI_T_event_dropped_cb_function dropped_cb_function) @@ -31,5 +30,12 @@ int MPI_T_event_set_dropped_handler (MPI_T_event_registration handle, MPI_T_even return MPI_T_ERR_NOT_INITIALIZED; } - return MPI_T_ERR_INVALID_HANDLE; + /* Check that this is a valid handle */ + if (MPI_T_EVENT_REGISTRATION_NULL == handle) { + return MPI_T_ERR_INVALID_HANDLE; + } + + mca_base_event_registration_set_dropped_handler (handle, (mca_base_event_dropped_cb_fn_t) dropped_cb_function); + + return MPI_SUCCESS; } diff --git a/ompi/mpi/tool/mpit-internal.h b/ompi/mpi/tool/mpit-internal.h index 4ee3d9e92a3..7c0a7907989 100644 --- a/ompi/mpi/tool/mpit-internal.h +++ b/ompi/mpi/tool/mpit-internal.h @@ -1,6 +1,6 @@ /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* - * Copyright (c) 2011-2013 Los Alamos National Security, LLC. All rights + * Copyright (c) 2011-2018 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2011 UT-Battelle, LLC. All rights reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved. @@ -15,11 +15,10 @@ #ifndef MPIT_INTERNAL_H #define MPIT_INTERNAL_H +#include "ompi/include/ompi_config.h" #include "opal/util/string_copy.h" #include "opal/mca/base/mca_base_var.h" -#include "opal/mca/base/mca_base_pvar.h" - -#include "ompi/include/ompi_config.h" +#include "opal/mca/base/mca_base_event.h" #include "ompi/runtime/params.h" #include "ompi/communicator/communicator.h" #include "ompi/constants.h" diff --git a/ompi/mpi/tool/source_get_info.c b/ompi/mpi/tool/source_get_info.c index 94017246fa2..0b98e8a204e 100644 --- a/ompi/mpi/tool/source_get_info.c +++ b/ompi/mpi/tool/source_get_info.c @@ -12,23 +12,56 @@ * $HEADER$ */ -#include "ompi_config.h" - #include "ompi/mpi/tool/mpit-internal.h" -#if OMPI_BUILD_MPI_PROFILING -#if OPAL_HAVE_WEAK_SYMBOLS +#if OPAL_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES #pragma weak MPI_T_source_get_info = PMPI_T_source_get_info #endif -#define MPI_T_source_get_info PMPI_T_source_get_info + +#if OMPI_PROFILING_DEFINES +#include "ompi/mpi/tool/profile/defines.h" #endif -int MPI_T_source_get_info (int source_index, char *name, int *name_len, char *desc, int *desc_len, MPI_T_source_order *ordering, +int MPI_T_source_get_info (int source_id, char *name, int *name_len, char *desc, int *desc_len, MPI_T_order *ordering, MPI_Count *ticks_per_second, MPI_Count *max_timestamp, MPI_Info *info) { + mca_base_source_t *source; if (!mpit_is_initialized ()) { return MPI_T_ERR_NOT_INITIALIZED; } - return MPI_T_ERR_INVALID_INDEX; + ompi_mpit_lock (); + source = mca_base_source_get (source_id); + ompi_mpit_unlock (); + if (OPAL_UNLIKELY(NULL == source)) { + return MPI_T_ERR_INVALID_INDEX; + } + + if (name && name_len) { + strncpy (name, source->source_name, *name_len); + *name_len = strlen (name); + } + + if (desc && desc_len) { + strncpy (desc, source->source_description, *desc_len); + *desc_len = strlen (desc); + } + + if (ordering) { + *ordering = source->source_ordered; + } + + if (ticks_per_second) { + *ticks_per_second = source->source_ticks; + } + + if (max_timestamp) { + *max_timestamp = SIZE_T_MAX; + } + + if (*info) { + *info = OBJ_NEW(ompi_info_t); + } + + return MPI_SUCCESS; } diff --git a/ompi/mpi/tool/source_get_num.c b/ompi/mpi/tool/source_get_num.c index 6b31862ff27..0c2c879b96d 100644 --- a/ompi/mpi/tool/source_get_num.c +++ b/ompi/mpi/tool/source_get_num.c @@ -12,17 +12,17 @@ * $HEADER$ */ -#include "ompi_config.h" - #include "ompi/mpi/tool/mpit-internal.h" -#if OMPI_BUILD_MPI_PROFILING -#if OPAL_HAVE_WEAK_SYMBOLS +#if OPAL_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES #pragma weak MPI_T_source_get_num = PMPI_T_source_get_num #endif -#define MPI_T_source_get_num PMPI_T_source_get_num + +#if OMPI_PROFILING_DEFINES +#include "ompi/mpi/tool/profile/defines.h" #endif + int MPI_T_source_get_num (int *num_source) { if (!mpit_is_initialized ()) { @@ -33,6 +33,5 @@ int MPI_T_source_get_num (int *num_source) return MPI_ERR_ARG; } - *num_source = 0; - return MPI_SUCCESS; + return mca_base_source_get_count (num_source); } diff --git a/ompi/mpi/tool/source_get_timestamp.c b/ompi/mpi/tool/source_get_timestamp.c index 02a4303d286..d6b382e4a86 100644 --- a/ompi/mpi/tool/source_get_timestamp.c +++ b/ompi/mpi/tool/source_get_timestamp.c @@ -12,19 +12,19 @@ * $HEADER$ */ -#include "ompi_config.h" - #include "ompi/mpi/tool/mpit-internal.h" -#if OMPI_BUILD_MPI_PROFILING -#if OPAL_HAVE_WEAK_SYMBOLS +#if OPAL_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES #pragma weak MPI_T_source_get_timestamp = PMPI_T_source_get_timestamp #endif -#define MPI_T_source_get_timestamp PMPI_T_source_get_timestamp + +#if OMPI_PROFILING_DEFINES +#include "ompi/mpi/tool/profile/defines.h" #endif -int MPI_T_source_get_timestamp (int source_index, MPI_Count *timestamp) +int MPI_T_source_get_timestamp (int source_id, MPI_Count *timestamp) { + mca_base_source_t *source; if (!mpit_is_initialized ()) { return MPI_T_ERR_NOT_INITIALIZED; } @@ -33,5 +33,14 @@ int MPI_T_source_get_timestamp (int source_index, MPI_Count *timestamp) return MPI_ERR_ARG; } - return MPI_T_ERR_INVALID_INDEX; + ompi_mpit_lock (); + source = mca_base_source_get (source_id); + ompi_mpit_unlock (); + if (OPAL_UNLIKELY(NULL == source)) { + return MPI_T_ERR_INVALID_INDEX; + } + + *timestamp = source->source_time (); + + return MPI_SUCCESS; } diff --git a/opal/mca/base/Makefile.am b/opal/mca/base/Makefile.am index 2e4cd3f2f3f..5f177a27a8b 100644 --- a/opal/mca/base/Makefile.am +++ b/opal/mca/base/Makefile.am @@ -10,6 +10,8 @@ # Copyright (c) 2004-2005 The Regents of the University of California. # All rights reserved. # Copyright (c) 2010 Cisco Systems, Inc. All rights reserved. +# Copyright (c) 2013-2018 Los Alamos National Security, LLC. All rights +# reserved. # Copyright (c) 2020 Google LLC. All rights reserved. # $COPYRIGHT$ # @@ -39,7 +41,10 @@ headers = \ mca_base_var_enum.h \ mca_base_var_group.h \ mca_base_vari.h \ - mca_base_framework.h + mca_base_framework.h \ + mca_base_event.h \ + mca_base_source.h + # Library @@ -62,7 +67,9 @@ libmca_base_la_SOURCES = \ mca_base_var_group.c \ mca_base_parse_paramfile.c \ mca_base_components_register.c \ - mca_base_framework.c + mca_base_framework.c \ + mca_base_event.c \ + mca_base_source.c # Conditionally install the header files diff --git a/opal/mca/base/mca_base_event.c b/opal/mca/base/mca_base_event.c new file mode 100644 index 00000000000..124977f2ce8 --- /dev/null +++ b/opal/mca/base/mca_base_event.c @@ -0,0 +1,648 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2013-2018 Los Alamos National Security, LLC. All rights + * reserved. + * Copyright (c) 2015 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2015 Bull SAS. All rights reserved. + * Copyright (c) 2015 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + * Copyright (c) 2017 IBM Corporation. All rights reserved. + * Copyright (c) 2018-2019 Triad National Security, LLC. All rights + * reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "mca_base_event.h" +#include "mca_base_vari.h" + +#include +#include +#include + +#include "opal/class/opal_pointer_array.h" +#include "opal/class/opal_hash_table.h" +#include "opal/threads/thread_usage.h" + +static opal_hash_table_t mca_base_event_index_hash; +static opal_pointer_array_t registered_events; +static bool mca_base_event_initialized = false; +static int event_count = 0; + +#define min(a,b) ((a) < (b) ? (a) : (b)) +#define max(a,b) ((a) > (b) ? (a) : (b)) + +static int mca_base_event_get_by_index_internal (int index, mca_base_event_t **event, bool invalidok); +static int mca_base_event_get_by_fullname_internal (const char *full_name, mca_base_event_t **event, bool invalidok); +static int mca_base_event_get_by_name_internal (const char *project, const char *framework, const char *component, const char *name, + mca_base_event_t **event, bool invalidok); + +/***************************************************************************************************/ + +int mca_base_event_init (void) +{ + int ret = OPAL_SUCCESS; + + if (!mca_base_event_initialized) { + mca_base_event_initialized = true; + + OBJ_CONSTRUCT(®istered_events, opal_pointer_array_t); + opal_pointer_array_init(®istered_events, 128, 2048, 128); + + OBJ_CONSTRUCT(&mca_base_event_index_hash, opal_hash_table_t); + ret = opal_hash_table_init (&mca_base_event_index_hash, 1024); + if (OPAL_SUCCESS != ret) { + mca_base_event_initialized = false; + OBJ_DESTRUCT(®istered_events); + OBJ_DESTRUCT(&mca_base_event_index_hash); + } + } + + return ret; +} + +int mca_base_event_finalize (void) +{ + int i; + + if (mca_base_event_initialized) { + mca_base_event_initialized = false; + + for (i = 0 ; i < event_count ; ++i) { + mca_base_event_t *event = opal_pointer_array_get_item (®istered_events, i); + if (event) { + OBJ_RELEASE(event); + } + } + + event_count = 0; + + OBJ_DESTRUCT(®istered_events); + OBJ_DESTRUCT(&mca_base_event_index_hash); + } + + return OPAL_SUCCESS; +} + +/***************************************************************************************************/ + + +/** lookup functions */ + +static int mca_base_event_get_by_fullname_internal (const char *full_name, mca_base_event_t **event, bool invalidok) +{ + void *tmp; + int rc; + + rc = opal_hash_table_get_value_ptr (&mca_base_event_index_hash, full_name, strlen (full_name), + &tmp); + if (OPAL_SUCCESS != rc) { + return rc; + } + + return mca_base_event_get_by_index_internal ((int)(uintptr_t) tmp, event, invalidok); +} + +int mca_base_event_get_by_fullname (const char *full_name, mca_base_event_t **event) +{ + return mca_base_event_get_by_fullname_internal (full_name, event, false); +} + +static int mca_base_event_get_by_name_internal (const char *project, const char *framework, const char *component, const char *name, + mca_base_event_t **event, bool invalidok) +{ + char *full_name; + int ret; + + ret = mca_base_var_generate_full_name4 (project, framework, component, name, &full_name); + if (OPAL_SUCCESS != ret) { + return OPAL_ERROR; + } + + ret = mca_base_event_get_by_fullname_internal (full_name, event, invalidok); + free (full_name); + + return ret; +} + +int mca_base_event_get_by_name (const char *project, const char *framework, const char *component, const char *name, + mca_base_event_t **event) +{ + return mca_base_event_get_by_name_internal (project, framework, component, name, event, false); +} + +int mca_base_registration_get_event (mca_base_event_registration_t *registration, mca_base_event_t **event) +{ + if (OPAL_UNLIKELY(NULL == registration)) { + return OPAL_ERR_BAD_PARAM; + } + + *event = registration->event; + + return OPAL_SUCCESS; +} + +static int mca_base_event_get_by_index_internal (int index, mca_base_event_t **event, bool invalidok) +{ + if (index >= event_count) { + return OPAL_ERR_VALUE_OUT_OF_BOUNDS; + } + + *event = opal_pointer_array_get_item (®istered_events, index); + + /* variables should never be removed per MPI 3.0 § 14.3.7 */ + assert (*event); + + if (((*event)->event_flags & MCA_BASE_EVENT_FLAG_INVALID) && !invalidok) { + *event = NULL; + return OPAL_ERR_VALUE_OUT_OF_BOUNDS; + } + + return OPAL_SUCCESS; +} + +int mca_base_event_get_by_index (int index, mca_base_event_t **event) +{ + return mca_base_event_get_by_index_internal (index, (mca_base_event_t **) event, false); +} + +/***************************************************************************************************/ + +int mca_base_event_get_count (int *count) +{ + *count = event_count; + return OPAL_SUCCESS; +} + +int mca_base_event_register (const char *project, const char *framework, const char *component, const char *name, + const char *description, mca_base_var_info_lvl_t verbosity, opal_datatype_t **datatypes, + unsigned long *offsets, size_t num_datatypes, mca_base_var_enum_t *enumerator, int extent, int bind, + int source, uint32_t flags, mca_base_notify_fn_t notify, void *ctx, mca_base_event_t **event_out) +{ + int ret, group_index; + mca_base_event_t *event; + + /* ensure the caller did not set an invalid flag */ + assert (!(flags & 0x3f)); + + /* update this assert if more MPIT verbosity levels are added */ + assert (verbosity >= OPAL_INFO_LVL_1 && verbosity <= OPAL_INFO_LVL_9); + + + flags &= ~MCA_BASE_EVENT_FLAG_INVALID; + + /* check if this variable is already registered */ + ret = mca_base_event_get_by_name (project, framework, component, name, &event); + if (OPAL_SUCCESS > ret) { + /* find/register an MCA parameter group for this performance variable */ + group_index = mca_base_var_group_register (project, framework, component, NULL); + if (-1 > group_index) { + return group_index; + } + + /* create a new parameter entry */ + event = OBJ_NEW(mca_base_event_t); + if (NULL == event) { + return OPAL_ERR_OUT_OF_RESOURCE; + } + + do { + /* generate the variable's full name */ + ret = mca_base_var_generate_full_name4 (project, framework, component, name, &event->event_name); + if (OPAL_SUCCESS != ret) { + ret = OPAL_ERR_OUT_OF_RESOURCE; + break; + } + + if (NULL != description) { + event->event_description = strdup(description); + if (NULL == event->event_description) { + ret = OPAL_ERR_OUT_OF_RESOURCE; + break; + } + } + + event->event_index = opal_pointer_array_add (®istered_events, event); + if (0 > event->event_index) { + ret = OPAL_ERR_OUT_OF_RESOURCE; + break; + } + + /* add this performance variable to the MCA variable group */ + if (0 <= group_index) { + ret = mca_base_var_group_add_event (group_index, event->event_index); + if (0 > ret) { + break; + } + } + + opal_hash_table_set_value_ptr (&mca_base_event_index_hash, event->event_name, strlen (event->event_name), + (void *)(uintptr_t) event->event_index); + + event_count++; + ret = OPAL_SUCCESS; + } while (0); + + if (OPAL_SUCCESS != ret) { + OBJ_RELEASE(event); + return ret; + } + + event->event_group_index = group_index; + } + + event->event_verbosity = verbosity; + event->event_source = mca_base_source_get (source); + event->event_extent = extent; + + if (event->event_enumerator) { + OBJ_RELEASE(event->event_enumerator); + } + + event->event_enumerator = enumerator; + if (enumerator) { + OBJ_RETAIN(enumerator); + } + + event->event_bind = bind; + event->event_flags = flags; + event->event_ctx = ctx; + + event->event_datatypes = calloc (num_datatypes, sizeof (event->event_datatypes[0])); + event->event_offsets = calloc (num_datatypes, sizeof (event->event_offsets[0])); + if (NULL == event->event_datatypes || NULL == event->event_offsets) { + return OPAL_ERR_OUT_OF_RESOURCE; + } + + memcpy (event->event_datatypes, datatypes, num_datatypes * sizeof (event->event_datatypes[0])); + memcpy (event->event_offsets, offsets, num_datatypes * sizeof (event->event_offsets[0])); + + event->event_datatype_count = num_datatypes; + + if (event_out) { + *event_out = event; + } + + return OPAL_SUCCESS; +} + +int mca_base_component_event_register (const mca_base_component_t *component, const char *name, + const char *description, mca_base_var_info_lvl_t verbosity, opal_datatype_t **datatypes, + unsigned long *offsets, size_t num_datatypes, mca_base_var_enum_t *enumerator, int extent, int bind, + int source, uint32_t flags, mca_base_notify_fn_t notify, void *ctx, mca_base_event_t **event_out) +{ + /* invalidate this variable if the component's group is deregistered */ + return mca_base_event_register (component->mca_project_name, component->mca_type_name, component->mca_component_name, + name, description, verbosity, datatypes, offsets, num_datatypes, enumerator, extent, bind, + source, flags | MCA_BASE_EVENT_FLAG_IWG, notify, ctx, event_out); +} + +int mca_base_component_event_register_list (const mca_base_component_t *component, mca_base_event_list_item_t *list, int count) +{ + mca_base_var_enum_t *new_enum = NULL; + int ret; + + for (int i = 0 ; i < count ; ++i) { + mca_base_event_list_item_t *item = list + i; + if (NULL != item->elements && NULL != item->elements[0]) { + char *full_name; + ret = mca_base_var_generate_full_name4 (component->mca_project_name, component->mca_type_name, component->mca_component_name, + item->name, &full_name); + if (OPAL_SUCCESS != ret) { + return OPAL_ERROR; + } + + mca_base_var_enum_create_simple (full_name, item->elements, &new_enum); + } + + ret = mca_base_event_register (component->mca_project_name, component->mca_type_name, component->mca_component_name, + item->name, item->desc, item->verbosity, item->datatypes, item->offsets, item->num_datatypes, + new_enum, item->extent, item->bind, item->source, item->flags | MCA_BASE_EVENT_FLAG_IWG, + item->notify, item->ctx, &item->event); + + if (new_enum) { + OBJ_RELEASE(new_enum); + } + + if (OPAL_SUCCESS != ret) { + return ret; + } + + new_enum = NULL; + } + + return OPAL_SUCCESS; +} + + +int mca_base_event_mark_invalid (mca_base_event_t *event) +{ + event->event_flags |= MCA_BASE_PVAR_FLAG_INVALID; + + return OPAL_SUCCESS; +} + +int mca_base_event_registration_alloc (mca_base_event_t *event, void *obj_registration, opal_info_t *info, + mca_base_event_registration_t **registration) +{ + mca_base_event_registration_t *event_registration = NULL; + + if (0 == event->event_bind) { + /* ignore binding object */ + obj_registration = NULL; + } else if (0 != event->event_bind && NULL == obj_registration) { + /* this is an application error. what is the correct error code? */ + return OPAL_ERR_BAD_PARAM; + } + + /* allocate and initialize the registration */ + event_registration = OBJ_NEW(mca_base_event_registration_t); + if (NULL == event_registration) { + return OPAL_ERR_OUT_OF_RESOURCE; + } + + event_registration->obj_registration = (NULL == obj_registration ? NULL : *(void**)obj_registration); + event_registration->event = event; + event_registration->obj_registration = obj_registration; + + *registration = event_registration; + opal_list_append (&event->event_bound_registrations, &event_registration->super); + + return OPAL_SUCCESS; +} + +int mca_base_event_handle_set_info (mca_base_event_registration_t *registration, opal_info_t *info) +{ + /* nothing to do at this time */ + return OPAL_SUCCESS; +} + +int mca_base_event_handle_get_info (mca_base_event_registration_t *registration, opal_info_t *info_used) +{ + /* nothing to do at this time */ + return OPAL_SUCCESS; +} + +int mca_base_event_register_callback (mca_base_event_registration_t *registration, mca_base_cb_safety_t cb_safety, + opal_info_t *info, void *user_data, mca_base_event_cb_fn_t event_cbfn) +{ + if (cb_safety >= MCA_BASE_CB_SAFETY_MAX || cb_safety < 0) { + return OPAL_ERR_BAD_PARAM; + } + + registration->user_data[cb_safety] = user_data; + /* ensure the user data is commited before setting the callback function */ + opal_atomic_wmb(); + opal_atomic_swap_ptr ((opal_atomic_intptr_t *) (registration->event_cbs + cb_safety), (intptr_t) event_cbfn); + + return OPAL_SUCCESS; +} + +int mca_base_event_callback_set_info (mca_base_event_registration_t *registration, mca_base_cb_safety_t cb_safety, + opal_info_t *info) +{ + /* nothing to do */ + return OPAL_SUCCESS; +} + +int mca_base_event_callback_get_info (mca_base_event_registration_t *registration, mca_base_cb_safety_t cb_safety, + opal_info_t *info_used) +{ + /* nothing to do */ + return OPAL_SUCCESS; +} + +void mca_base_event_registration_free (mca_base_event_registration_t *registration, mca_base_event_registration_free_cb_fn_t cbfn) +{ + registration->free_cb = cbfn; + OBJ_RELEASE(registration); +} + +int mca_base_event_dump(int index, char ***out, mca_base_var_dump_type_t output_type) +{ + const char *framework, *component, *full_name; + mca_base_var_group_t *group; + int line = 0, line_count; + mca_base_event_t *event; + int ret, enum_count = 0; + char *tmp; + + ret = mca_base_event_get_by_index (index, &event); + if (OPAL_SUCCESS != ret) { + return ret; + } + + ret = mca_base_var_group_get_internal (event->event_group_index, &group, true); + if (OPAL_SUCCESS != ret) { + return ret; + } + + framework = group->group_framework; + component = group->group_component ? group->group_component : "base"; + full_name = event->event_name; + + if (NULL != event->event_enumerator) { + (void) event->event_enumerator->get_count(event->event_enumerator, &enum_count); + } + + if (MCA_BASE_VAR_DUMP_PARSABLE == output_type) { + line_count = 2 + !!(event->event_description) + enum_count + event->event_datatype_count; + + *out = (char **) calloc (line_count + 1, sizeof (char *)); + if (NULL == *out) { + return OPAL_ERR_OUT_OF_RESOURCE; + } + + /* build the message*/ + (void)asprintf(&tmp, "mca:%s:%s:event:%s:", framework, component, full_name); + + (void)asprintf(out[0] + line++, "%sextent:%lu", tmp, (unsigned long) event->event_extent); + (void)asprintf(out[0] + line++, "%snum_datatypes:%lu", tmp, (unsigned long) event->event_datatype_count); + for (size_t i = 0 ; i < event->event_datatype_count ; ++i) { + (void)asprintf(out[0] + line++, "%sdatatypes:%lu:%s", tmp, (unsigned long) i, event->event_datatypes[i]->name); + } + + /* if it has a help message, output the help message */ + if (event->event_description) { + (void)asprintf(out[0] + line++, "%shelp:%s", tmp, event->event_description); + } + + if (NULL != event->event_enumerator) { + for (int i = 0 ; i < enum_count ; ++i) { + const char *enum_string = NULL; + int enum_value; + + ret = event->event_enumerator->get_value (event->event_enumerator, i, &enum_value, + &enum_string); + if (OPAL_SUCCESS != ret) { + continue; + } + + (void)asprintf(out[0] + line++, "%senumerator:element:%d:%s", tmp, enum_value, enum_string); + } + } + + free(tmp); // release tmp storage + } else { + /* there will be at most three lines in the pretty print case */ + *out = (char **) calloc (4, sizeof (char *)); + if (NULL == *out) { + return OPAL_ERR_OUT_OF_RESOURCE; + } + + (void)asprintf (out[0] + line++, "event \"%s\" (extent: %lu, datatype count: %ld)", full_name, + (unsigned long) event->event_extent, (long) event->event_datatype_count); + + if (event->event_description) { + (void)asprintf(out[0] + line++, "%s", event->event_description); + } + + if (NULL != event->event_enumerator) { + char *values; + + ret = event->event_enumerator->dump(event->event_enumerator, &values); + if (OPAL_SUCCESS == ret) { + (void)asprintf (out[0] + line++, "Elements: %s", values); + free (values); + } + } + } + + return OPAL_SUCCESS; +} + +void mca_base_event_raise_internal (mca_base_event_t *event, mca_base_cb_safety_t cb_safety, void *obj, mca_base_source_t *source, void *data) +{ + mca_base_raised_event_t revent = {.re_timestamp = source ? source->source_time () : event->event_source->source_time (), + .re_source = source ? source->source_index : event->event_source->source_index, + .re_data = data, .re_event = event}; + mca_base_event_registration_t *registration; + + OPAL_LIST_FOREACH(registration, &event->event_bound_registrations, mca_base_event_registration_t) { + if (registration->obj_registration != obj) { + continue; + } + + for (mca_base_cb_safety_t i = cb_safety ; i < MCA_BASE_CB_SAFETY_MAX ; ++i) { + mca_base_event_cb_fn_t cb = registration->event_cbs[i]; + + if (NULL == cb) { + continue; + } + + /* call only the least restrictive callback allowed by the raise */ + cb (&revent, registration, cb_safety, registration->user_data[i]); + break; + } + } +} + +/* mca_base_event_t class */ +static void mca_base_event_contructor (mca_base_event_t *event) +{ + memset ((char *) event + sizeof (event->super), 0, sizeof (*event) - sizeof (event->super)); + OBJ_CONSTRUCT(&event->event_bound_registrations, opal_list_t); +} + +static void mca_base_event_destructor (mca_base_event_t *event) +{ + free (event->event_name); + free (event->event_description); + + if (NULL != event->event_enumerator) { + OBJ_RELEASE(event->event_enumerator); + } + + free (event->event_datatypes); + + OBJ_DESTRUCT(&event->event_bound_registrations); +} + +OBJ_CLASS_INSTANCE(mca_base_event_t, opal_object_t, mca_base_event_contructor, mca_base_event_destructor); + +/* mca_base_event_registration_t class */ +static void mca_base_event_registration_constructor (mca_base_event_registration_t *registration) +{ + memset ((char *) registration + sizeof (registration->super), 0, sizeof (*registration) - sizeof (registration->super)); +} + +static void mca_base_event_registration_destructor (mca_base_event_registration_t *registration) +{ + /* remove this registration from the event's list */ + if (registration->event) { + opal_list_remove_item (®istration->event->event_bound_registrations, ®istration->super); + } + + if (registration->free_cb) { + registration->free_cb (registration, MCA_BASE_CB_REQUIRE_NONE, registration->user_data); + } +} + +OBJ_CLASS_INSTANCE(mca_base_event_registration_t, opal_list_item_t, mca_base_event_registration_constructor, + mca_base_event_registration_destructor); + + +/* query functions */ +int mca_base_event_get_time (mca_base_raised_event_t *revent, uint64_t *event_time) +{ + *event_time = revent->re_timestamp; + return OPAL_SUCCESS; +} + +void mca_base_event_get_source (mca_base_raised_event_t *revent, int *source_index) +{ + *source_index = revent->re_source; +} + +int mca_base_event_read (mca_base_raised_event_t *revent, unsigned int element_index, void *buffer) +{ + mca_base_event_t *event = revent->re_event; + + if (element_index > event->event_datatype_count) { + return OPAL_ERR_VALUE_OUT_OF_BOUNDS; + } + + memcpy (buffer, revent->re_data + event->event_offsets[element_index], event->event_datatypes[element_index]->size); + + return OPAL_SUCCESS; +} + +void mca_base_event_copy (mca_base_raised_event_t *revent, void *buffer) +{ + mca_base_event_t *event = revent->re_event; + + memcpy (buffer, revent->re_data, event->event_extent); +} + +int mca_base_event_read_some (mca_base_raised_event_t *revent, void *array_of_buffers[]) +{ + mca_base_event_t *event = revent->re_event; + + for (size_t i = 0 ; i < event->event_datatype_count ; ++i) { + if (array_of_buffers[i]) { + memcpy (array_of_buffers[i], revent->re_data + event->event_offsets[i], event->event_datatypes[i]->size); + } + } + + return OPAL_SUCCESS; +} + +int mca_base_event_read_all (mca_base_raised_event_t *revent, void *array_of_buffers[]) +{ + mca_base_event_t *event = revent->re_event; + + for (size_t i = 0 ; i < event->event_datatype_count ; ++i) { + memcpy (array_of_buffers[i], revent->re_data + event->event_offsets[i], event->event_datatypes[i]->size); + } + + return OPAL_SUCCESS; +} + +void mca_base_event_registration_set_dropped_handler (mca_base_event_registration_t *registration, mca_base_event_dropped_cb_fn_t cbfn) +{ + registration->dropped_cb = cbfn; +} diff --git a/opal/mca/base/mca_base_event.h b/opal/mca/base/mca_base_event.h new file mode 100644 index 00000000000..ee740edf0fa --- /dev/null +++ b/opal/mca/base/mca_base_event.h @@ -0,0 +1,230 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2018 Los Alamos National Security, LLC. All rights + * reserved. + * Copyright (c) 2018-2019 Triad National Security, LLC. All rights + * reserved. + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#if !defined(MCA_BASE_EVENT_H) +#define MCA_BASE_EVENT_H + +#include "opal/datatype/opal_datatype.h" +#include "opal/util/info.h" +#include "mca_base_pvar.h" +#include "mca_base_source.h" + +struct mca_base_event_t; +struct mca_base_event_registration_t; +struct mca_base_raised_event_t; + +/* + * These flags are used when registering a new event. + */ +typedef enum { + /** This variable should be marked as invalid when the containing + group is deregistered (IWG = "invalidate with group"). This + flag is set automatically when you register a variable with + mca_base_component_pvvar_register(), but can also be set + manually when you register a variable with + mca_base_pvar_register(). Analogous to the + MCA_BASE_VAR_FLAG_DWG flag. */ + MCA_BASE_EVENT_FLAG_IWG = 0x040, + /** This variable has been marked as invalid. This flag is ignored + by mca_base_pvar_register(). */ + MCA_BASE_EVENT_FLAG_INVALID = 0x400, +} mca_base_event_flag_t; + +/** + * @basic Callback safety levels + * + * If these are modified then similar modifications will be needed in mpi.h.in. + */ +typedef enum { + MCA_BASE_CB_REQUIRE_NONE, + MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, + MCA_BASE_CB_REQUIRE_THREAD_SAFE, + MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, + MCA_BASE_CB_SAFETY_MAX, +} mca_base_cb_safety_t; + +typedef void (*mca_base_event_cb_fn_t) (struct mca_base_raised_event_t *event, struct mca_base_event_registration_t *registration, + mca_base_cb_safety_t cb_safety, void *user_data); + +typedef void (*mca_base_event_registration_free_cb_fn_t) (struct mca_base_event_registration_t *registration, + mca_base_cb_safety_t cb_safety, void *user_data); + +typedef void (*mca_base_event_dropped_cb_fn_t) (int count, struct mca_base_event_registration_t *registration, + mca_base_cb_safety_t cb_safety, void *user_data); + +typedef struct mca_base_raised_event_t { + struct mca_base_event_t *re_event; + int re_source; + uint64_t re_timestamp; + int8_t *re_data; +} mca_base_raised_event_t; + +typedef struct mca_base_event_t { + /** Make this an opal object */ + opal_object_t super; + + /** Variable index */ + int event_index; + + /** Full name of the variable: form is framework_component_name */ + char *event_name; + + /** Description of this performance variable */ + char *event_description; + + /** MCA variable group this variable is associated with */ + int event_group_index; + + /** Verbosity level of this variable */ + mca_base_var_info_lvl_t event_verbosity; + + /** Event datatypes */ + opal_datatype_t **event_datatypes; + + /** Event offsets */ + unsigned long *event_offsets; + + /** Size of the event_datatypes array */ + size_t event_datatype_count; + + /** size of the event data */ + size_t event_extent; + + + /** Enumerator for integer values */ + mca_base_var_enum_t *event_enumerator; + + /** Type of object to which this variable must be bound or MCA_BASE_VAR_BIND_NULL */ + int event_bind; + + /** event source (may be NULL) */ + mca_base_source_t *event_source; + + /** Flags for this variable */ + uint32_t event_flags; + + /** Notify the creator of this variable of a new/deleted handle. This callback can + * be used to turn on/off code that is needed for the event but may reduce performance + * in the case where there are no active event listeners. */ + mca_base_notify_fn_t event_notify; + + /** Context of this variable */ + void *event_ctx; + + /** List of bound event registrations. NOTE: The items in this list are + offsetof(mca_base_pvar_registration_t, list2) into a pvar registration. */ + opal_list_t event_bound_registrations; +} mca_base_event_t; + +OBJ_CLASS_DECLARATION(mca_base_event_t); + +typedef struct mca_base_event_list_item_t { + const char *name; + const char *desc; + mca_base_var_info_lvl_t verbosity; + opal_datatype_t **datatypes; + unsigned long *offsets; + size_t num_datatypes; + char **elements; + int extent; + int bind; + int source; + uint32_t flags; + mca_base_notify_fn_t notify; + void *ctx; + mca_base_event_t *event; +} mca_base_event_list_item_t; + +typedef struct mca_base_event_registration_t { + opal_list_item_t super; + + /** associated event */ + mca_base_event_t *event; + + /** user callback to trigger on event */ + mca_base_event_cb_fn_t event_cbs[MCA_BASE_CB_SAFETY_MAX]; + + /** user callback to trigger when an event was dropped */ + mca_base_event_dropped_cb_fn_t dropped_cb; + + /** free callback */ + mca_base_event_registration_free_cb_fn_t free_cb; + + /** user data specified when this registration was created */ + void *user_data[MCA_BASE_CB_SAFETY_MAX]; + + /** bound object registration */ + void *obj_registration; +} mca_base_event_registration_t; + +OBJ_CLASS_DECLARATION(mca_base_event_registration_t); + +OPAL_DECLSPEC int mca_base_event_init (void); +OPAL_DECLSPEC int mca_base_event_finalize (void); + +OPAL_DECLSPEC int mca_base_event_get_count (int *count); +OPAL_DECLSPEC int mca_base_event_mark_invalid (mca_base_event_t *event); +OPAL_DECLSPEC int mca_base_event_dump(int index, char ***out, mca_base_var_dump_type_t output_type); + +OPAL_DECLSPEC int mca_base_event_register (const char *project, const char *framework, const char *component, const char *name, + const char *description, mca_base_var_info_lvl_t verbosity, opal_datatype_t **datatypes, + unsigned long *offsets, size_t num_datatypes, mca_base_var_enum_t *enumerator, int extent, int bind, + int source, uint32_t flags, mca_base_notify_fn_t notify, void *ctx, mca_base_event_t **event_out); + +OPAL_DECLSPEC int mca_base_component_event_register (const mca_base_component_t *component, const char *name, + const char *description, mca_base_var_info_lvl_t verbosity, opal_datatype_t **datatypes, + unsigned long *offsets, size_t num_datatypes, mca_base_var_enum_t *enumerator, int extent, int bind, + int source, uint32_t flags, mca_base_notify_fn_t notify, void *ctx, mca_base_event_t **event_out); + +OPAL_DECLSPEC int mca_base_component_event_register_list (const mca_base_component_t *component, mca_base_event_list_item_t *list, int count); + +OPAL_DECLSPEC void mca_base_event_raise_internal (mca_base_event_t *event, mca_base_cb_safety_t cb_safety, void *obj, mca_base_source_t *source, + void *data); + +#define mca_base_event_raise(eventp, cb_safety, obj, source, data) \ + do { \ + if (OPAL_UNLIKELY(0 != opal_list_get_size (&(eventp)->event_bound_registrations))) { \ + /* at least one registration is bound to this event. raise the event with the user code */ \ + mca_base_event_raise_internal (eventp, cb_safety, obj, source, data); \ + } \ + } while (0); + +OPAL_DECLSPEC int mca_base_event_registration_alloc (mca_base_event_t *event, void *obj_registration, opal_info_t *info, + mca_base_event_registration_t **registration); +OPAL_DECLSPEC int mca_base_event_register_callback (mca_base_event_registration_t *registration, mca_base_cb_safety_t cb_safety, + opal_info_t *info, void *user_data, mca_base_event_cb_fn_t event_cbfn); + +OPAL_DECLSPEC void mca_base_event_registration_free (mca_base_event_registration_t *registration, mca_base_event_registration_free_cb_fn_t cbfn); + +OPAL_DECLSPEC void mca_base_event_registration_set_dropped_handler (mca_base_event_registration_t *registration, mca_base_event_dropped_cb_fn_t cbfn); + +OPAL_DECLSPEC int mca_base_event_get_by_index (int index, mca_base_event_t **event); +OPAL_DECLSPEC int mca_base_event_get_by_name (const char *project, const char *framework, const char *component, const char *name, + mca_base_event_t **event); +OPAL_DECLSPEC int mca_base_registration_get_event (mca_base_event_registration_t *registration, mca_base_event_t **event); +OPAL_DECLSPEC int mca_base_event_get_by_fullname (const char *full_name, mca_base_event_t **event); + +OPAL_DECLSPEC int mca_base_event_get_time (mca_base_raised_event_t *revent, uint64_t *event_time); +OPAL_DECLSPEC void mca_base_event_get_source (mca_base_raised_event_t *revent, int *source_index); +OPAL_DECLSPEC int mca_base_event_read (mca_base_raised_event_t *revent, unsigned int element_index, void *buffer); +OPAL_DECLSPEC void mca_base_event_copy (mca_base_raised_event_t *revent, void *buffer); +OPAL_DECLSPEC int mca_base_event_read_some (mca_base_raised_event_t *revent, void *array_of_buffers[]); +OPAL_DECLSPEC int mca_base_event_read_all (mca_base_raised_event_t *revent, void *array_of_buffers[]); + +OPAL_DECLSPEC int mca_base_event_handle_set_info (mca_base_event_registration_t *registration, opal_info_t *info); +OPAL_DECLSPEC int mca_base_event_handle_get_info (mca_base_event_registration_t *registration, opal_info_t *info_used); +OPAL_DECLSPEC int mca_base_event_callback_set_info (mca_base_event_registration_t *registration, mca_base_cb_safety_t cb_safety, + opal_info_t *info); +OPAL_DECLSPEC int mca_base_event_callback_get_info (mca_base_event_registration_t *registration, mca_base_cb_safety_t cb_safety, + opal_info_t *info_used); + +#endif /* !defined(MCA_BASE_EVENT_H) */ diff --git a/opal/mca/base/mca_base_source.c b/opal/mca/base/mca_base_source.c new file mode 100644 index 00000000000..ca5b2831403 --- /dev/null +++ b/opal/mca/base/mca_base_source.c @@ -0,0 +1,238 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2013-2018 Los Alamos National Security, LLC. All rights + * reserved. + * Copyright (c) 2015 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2015 Bull SAS. All rights reserved. + * Copyright (c) 2015 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + * Copyright (c) 2017 IBM Corporation. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "mca_base_source.h" +#include "mca_base_vari.h" + +#include +#include +#include + +#include "opal/class/opal_pointer_array.h" +#include "opal/class/opal_hash_table.h" + +static opal_pointer_array_t registered_sources; +static int mca_base_source_initialized; +static int source_count; + +int mca_base_source_default_source = -1; + +static uint64_t mca_base_source_default_time_source (void) +{ + uint64_t time_value; + +#if OPAL_HAVE_CLOCK_GETTIME + struct timespec current; + + clock_gettime (CLOCK_MONOTONIC, ¤t); + time_value = 1000000000ul * current.tv_sec + current.tv_nsec; +#else + struct timeval current; + + gettimeofday (¤t, NULL); + time_value = 1000000ul * current.tv_sec + current.tv_usec; +#endif + + return time_value; +} + +static uint64_t mca_base_source_default_time_source_ticks (void) +{ +#if OPAL_HAVE_CLOCK_GETTIME + return 1000000000; +#else + return 1000000; +#endif +} + +/***************************************************************************************************/ + +int mca_base_source_init (void) +{ + int ret = OPAL_SUCCESS; + + if (!mca_base_source_initialized++) { + mca_base_source_initialized = true; + + OBJ_CONSTRUCT(®istered_sources, opal_pointer_array_t); + opal_pointer_array_init(®istered_sources, 16, 512, 16); + + mca_base_source_default_source = mca_base_source_register ("opal", "mca", "base", "default_source", + "Default source for MCA events", true, + mca_base_source_default_time_source, + mca_base_source_default_time_source_ticks ()); + + } + + return ret; +} + +int mca_base_source_finalize (void) +{ + int i; + + if (0 == --mca_base_source_initialized) { + for (i = 0 ; i < source_count ; ++i) { + mca_base_source_t *source = opal_pointer_array_get_item (®istered_sources, i); + if (source) { + OBJ_RELEASE(source); + } + } + + source_count = 0; + + OBJ_DESTRUCT(®istered_sources); + } + + return OPAL_SUCCESS; +} + +/***************************************************************************************************/ + +mca_base_source_t *mca_base_source_get (int source_index) +{ + return opal_pointer_array_get_item (®istered_sources, source_index); +} + +int mca_base_source_set_time_source (int source_index, mca_base_source_time_fn_t time_source, uint64_t time_ticks) +{ + mca_base_source_t *source = mca_base_source_get (source_index); + + if (NULL == source) { + return OPAL_ERR_NOT_FOUND; + } + + if (!time_source) { + time_source = mca_base_source_default_time_source; + time_ticks = mca_base_source_default_time_source_ticks (); + } + + source->source_time = time_source; + source->source_ticks = time_ticks; + + return OPAL_SUCCESS; +} + +/***************************************************************************************************/ + +int mca_base_source_get_count (int *count) +{ + *count = source_count; + return OPAL_SUCCESS; +} + +static inline int mca_base_source_get_by_name (const char *name, mca_base_source_t **source_out) +{ + /* there are expected to be a relatively small number of sources so a linear search should be fine */ + for (int i = 0 ; i < source_count ; ++i) { + mca_base_source_t *source = opal_pointer_array_get_item (®istered_sources, i); + if (NULL != source && 0 == strcmp (name, source->source_name)) { + if (source) { + *source_out = source; + } + + return OPAL_SUCCESS; + } + } + + return OPAL_ERR_NOT_FOUND; +} + +int mca_base_source_register (const char *project, const char *framework, const char *component, const char *name, + const char *description, bool ordered, mca_base_source_time_fn_t source_time, uint64_t source_ticks) +{ + mca_base_source_t *source; + char *source_name; + int ret; + + /* generate the variable's full name */ + ret = mca_base_var_generate_full_name4 (NULL, framework, component, name, &source_name); + if (OPAL_SUCCESS != ret) { + return ret; + } + + + /* check if this variable is already registered */ + ret = mca_base_source_get_by_name (source_name, &source); + if (OPAL_SUCCESS > ret) { + /* create a new parameter entry */ + source = OBJ_NEW(mca_base_source_t); + if (NULL == source) { + return OPAL_ERR_OUT_OF_RESOURCE; + } + + do { + source->source_name = source_name; + + if (NULL != description) { + source->source_description = strdup(description); + if (NULL == source->source_description) { + ret = OPAL_ERR_OUT_OF_RESOURCE; + break; + } + } + + source->source_index = opal_pointer_array_add (®istered_sources, source); + if (0 > source->source_index) { + ret = OPAL_ERR_OUT_OF_RESOURCE; + break; + } + + source_count++; + ret = OPAL_SUCCESS; + } while (0); + + if (OPAL_SUCCESS != ret) { + OBJ_RELEASE(source); + return ret; + } + } else { + free (source_name); + } + + source->source_ordered = ordered; + if (NULL == source_time) { + source_time = mca_base_source_default_time_source; + source_ticks = mca_base_source_default_time_source_ticks (); + } + + source->source_time = source_time; + source->source_ticks = source_ticks; + + return OPAL_SUCCESS; +} +int mca_base_component_source_register (const mca_base_component_t *component, const char *name, const char *description, bool ordered, + mca_base_source_time_fn_t source_time, uint64_t source_ticks) +{ + /* invalidate this variable if the component's group is deregistered */ + return mca_base_source_register (component->mca_project_name, component->mca_type_name, component->mca_component_name, + name, description, ordered, source_time, source_ticks); +} + +/* mca_base_source_t class */ +static void mca_base_source_contructor (mca_base_source_t *source) +{ + memset ((char *) source + sizeof (source->super), 0, sizeof (*source) - sizeof (source->super)); +} + +static void mca_base_source_destructor (mca_base_source_t *source) +{ + free (source->source_name); + free (source->source_description); +} + +OBJ_CLASS_INSTANCE(mca_base_source_t, opal_object_t, mca_base_source_contructor, mca_base_source_destructor); diff --git a/opal/mca/base/mca_base_source.h b/opal/mca/base/mca_base_source.h new file mode 100644 index 00000000000..62a156746f7 --- /dev/null +++ b/opal/mca/base/mca_base_source.h @@ -0,0 +1,68 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2018 Los Alamos National Security, LLC. All rights + * reserved. + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#if !defined(MCA_BASE_SOURCE_H) +#define MCA_BASE_SOURCE_H + +#include "opal/datatype/opal_datatype.h" +#include "mca_base_pvar.h" + +enum { + /* default source */ + MCA_BASE_SOURCE_DEFAULT_SOURCE, +}; + +typedef uint64_t (*mca_base_source_time_fn_t) (void); + +typedef struct mca_base_source_t { + /** Make this an opal object */ + opal_object_t super; + + /** Source index */ + int source_index; + + /** Source ordering */ + bool source_ordered; + + /** Full name of the variable: form is framework_component_name */ + char *source_name; + + /** Description of this performance variable */ + char *source_description; + + /** Time source (never NULL) */ + mca_base_source_time_fn_t source_time; + + /** Time source ticks per second */ + uint64_t source_ticks; +} mca_base_source_t; + +OBJ_CLASS_DECLARATION(mca_base_source_t); + +extern int mca_base_source_default_source; + +OPAL_DECLSPEC int mca_base_source_init (void); +OPAL_DECLSPEC int mca_base_source_finalize (void); + +OPAL_DECLSPEC int mca_base_source_get_count (int *count); + +OPAL_DECLSPEC int mca_base_source_dump(int index, char ***out, mca_base_var_dump_type_t output_type); + +OPAL_DECLSPEC int mca_base_source_register (const char *project, const char *framework, const char *component, const char *name, + const char *description, bool ordered, mca_base_source_time_fn_t source_time, uint64_t source_ticks); + +OPAL_DECLSPEC int mca_base_component_source_register (const mca_base_component_t *component, const char *name, const char *description, + bool ordered, mca_base_source_time_fn_t source_time, uint64_t source_ticks); + +OPAL_DECLSPEC int mca_base_source_set_time_source (int source_index, mca_base_source_time_fn_t time_source, uint64_t time_ticks); + +OPAL_DECLSPEC mca_base_source_t *mca_base_source_get (int source_index); + +#endif /* !defined(MCA_BASE_SOURCE_H) */ diff --git a/opal/mca/base/mca_base_var.c b/opal/mca/base/mca_base_var.c index b9860c6ed1e..7e5747ad94a 100644 --- a/opal/mca/base/mca_base_var.c +++ b/opal/mca/base/mca_base_var.c @@ -277,6 +277,15 @@ int mca_base_var_init(void) if (NULL == (cwd = getcwd(NULL, 0))) { opal_output(0, "Error: Unable to get the current working directory\n"); cwd = strdup("."); + + ret = mca_base_source_init (); + if (OPAL_SUCCESS != ret) { + return ret; + } + + ret = mca_base_event_init (); + if (OPAL_SUCCESS != ret) { + return ret; } /* Set this before we register the parameter, below */ diff --git a/opal/mca/base/mca_base_var_enum.c b/opal/mca/base/mca_base_var_enum.c index a6d89da5f20..8868d8c8aec 100644 --- a/opal/mca/base/mca_base_var_enum.c +++ b/opal/mca/base/mca_base_var_enum.c @@ -429,6 +429,43 @@ int mca_base_var_enum_create(const char *name, const mca_base_var_enum_value_t * return OPAL_SUCCESS; } +int mca_base_var_enum_create_simple (const char *name, char * const strings[], mca_base_var_enum_t **enumerator) +{ + mca_base_var_enum_t *new_enum; + int i; + + *enumerator = NULL; + + new_enum = OBJ_NEW(mca_base_var_enum_t); + if (NULL == new_enum) { + return OPAL_ERR_OUT_OF_RESOURCE; + } + + new_enum->enum_name = strdup (name); + if (NULL == new_enum->enum_name) { + return OPAL_ERR_OUT_OF_RESOURCE; + } + + for (i = 0 ; strings[i] ; ++i); + new_enum->enum_value_count = i; + + /* make a copy of the values */ + new_enum->enum_values = calloc (new_enum->enum_value_count + 1, sizeof (*new_enum->enum_values)); + if (NULL == new_enum->enum_values) { + OBJ_RELEASE(new_enum); + return OPAL_ERR_OUT_OF_RESOURCE; + } + + for (i = 0 ; i < new_enum->enum_value_count ; ++i) { + new_enum->enum_values[i].value = i; + new_enum->enum_values[i].string = strdup (strings[i]); + } + + *enumerator = new_enum; + + return OPAL_SUCCESS; +} + int mca_base_var_enum_create_flag(const char *name, const mca_base_var_enum_value_flag_t *flags, mca_base_var_enum_flag_t **enumerator) { diff --git a/opal/mca/base/mca_base_var_enum.h b/opal/mca/base/mca_base_var_enum.h index 7fdfa8e64f0..89aa7b9e7bf 100644 --- a/opal/mca/base/mca_base_var_enum.h +++ b/opal/mca/base/mca_base_var_enum.h @@ -221,6 +221,9 @@ OPAL_DECLSPEC int mca_base_var_enum_create(const char *name, const mca_base_var_enum_value_t values[], mca_base_var_enum_t **enumerator); +OPAL_DECLSPEC int mca_base_var_enum_create_simple (const char *name, char * const strings[], + mca_base_var_enum_t **enumerator); + /** * Create a new default flag enumerator * diff --git a/opal/mca/base/mca_base_var_group.c b/opal/mca/base/mca_base_var_group.c index 732df663e98..6d2aaed9eb1 100644 --- a/opal/mca/base/mca_base_var_group.c +++ b/opal/mca/base/mca_base_var_group.c @@ -11,7 +11,7 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2008-2013 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2012-2015 Los Alamos National Security, LLC. All rights + * Copyright (c) 2012-2018 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2017 Research Organization for Information Science * and Technology (RIST). All rights reserved. @@ -42,6 +42,10 @@ #include "opal/mca/base/mca_base_pvar.h" #include "opal/mca/base/mca_base_vari.h" #include "opal/mca/mca.h" +#include "opal/mca/base/mca_base_event.h" +#include "opal/constants.h" +#include "opal/util/output.h" +#include "opal/util/opal_environ.h" #include "opal/runtime/opal.h" #include "opal/util/opal_environ.h" #include "opal/util/output.h" @@ -379,6 +383,21 @@ int mca_base_var_group_deregister(int group_index) opal_value_array_set_size(&group->group_enums, 0); + /* deregister all events */ + size = opal_value_array_get_size(&group->group_events); + params = OPAL_VALUE_ARRAY_GET_BASE(&group->group_events, int); + + for (int i = 0 ; i < size ; ++i) { + mca_base_event_t *event; + + ret = mca_base_event_get_by_index (params[i], &event); + if (OPAL_SUCCESS != ret || !(event->event_flags & MCA_BASE_EVENT_FLAG_IWG)) { + continue; + } + + (void) mca_base_event_mark_invalid (event); + } + size = opal_value_array_get_size(&group->group_subgroups); subgroups = OPAL_VALUE_ARRAY_GET_BASE(&group->group_subgroups, int); for (int i = 0; i < size; ++i) { @@ -488,7 +507,37 @@ int mca_base_var_group_add_enum(const int group_index, const void *storage) return (int) opal_value_array_get_size(&group->group_enums) - 1; } -int mca_base_var_group_get(const int group_index, const mca_base_var_group_t **group) +int mca_base_var_group_add_event (const int group_index, const int event_index) +{ + mca_base_var_group_t *group; + int size, i, ret; + int *params; + + ret = mca_base_var_group_get_internal (group_index, &group, false); + if (OPAL_SUCCESS != ret) { + return ret; + } + + size = opal_value_array_get_size(&group->group_events); + params = OPAL_VALUE_ARRAY_GET_BASE(&group->group_events, int); + for (i = 0 ; i < size ; ++i) { + if (params[i] == event_index) { + return i; + } + } + + if (OPAL_SUCCESS != + (ret = opal_value_array_append_item (&group->group_events, &event_index))) { + return ret; + } + + mca_base_var_groups_timestamp++; + + /* return the group index */ + return (int) opal_value_array_get_size (&group->group_events) - 1; +} + +int mca_base_var_group_get (const int group_index, const mca_base_var_group_t **group) { return mca_base_var_group_get_internal(group_index, (mca_base_var_group_t **) group, false); } @@ -531,7 +580,10 @@ static void mca_base_var_group_constructor(mca_base_var_group_t *group) opal_value_array_init(&group->group_pvars, sizeof(int)); OBJ_CONSTRUCT(&group->group_enums, opal_value_array_t); - opal_value_array_init(&group->group_enums, sizeof(void *)); + opal_value_array_init (&group->group_enums, sizeof(void *)); + + OBJ_CONSTRUCT(&group->group_events, opal_value_array_t); + opal_value_array_init (&group->group_events, sizeof(int)); } static void mca_base_var_group_destructor(mca_base_var_group_t *group) @@ -555,6 +607,7 @@ static void mca_base_var_group_destructor(mca_base_var_group_t *group) OBJ_DESTRUCT(&group->group_vars); OBJ_DESTRUCT(&group->group_pvars); OBJ_DESTRUCT(&group->group_enums); + OBJ_DESTRUCT(&group->group_events); } int mca_base_var_group_get_count(void) diff --git a/opal/mca/base/mca_base_var_group.h b/opal/mca/base/mca_base_var_group.h index 71261b16940..bbba7a685e3 100644 --- a/opal/mca/base/mca_base_var_group.h +++ b/opal/mca/base/mca_base_var_group.h @@ -57,6 +57,9 @@ struct mca_base_var_group_t { /** Pointer array of group enums */ opal_value_array_t group_enums; + + /** Pointer array of group events */ + opal_value_array_t group_events; }; typedef struct mca_base_var_group_t mca_base_var_group_t; diff --git a/opal/mca/base/mca_base_vari.h b/opal/mca/base/mca_base_vari.h index cc89842fdd8..b5a2acad4a5 100644 --- a/opal/mca/base/mca_base_vari.h +++ b/opal/mca/base/mca_base_vari.h @@ -11,7 +11,7 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2008 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights + * Copyright (c) 2012-2018 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2017 Research Organization for Information Science * and Technology (RIST). All rights reserved. @@ -48,6 +48,8 @@ #include "opal/class/opal_value_array.h" #include "opal/mca/base/mca_base_pvar.h" #include "opal/mca/base/mca_base_var.h" +#include "opal/mca/base/mca_base_source.h" +#include "opal/mca/base/mca_base_event.h" BEGIN_C_DECLS @@ -147,6 +149,13 @@ OPAL_DECLSPEC int mca_base_var_group_add_pvar(const int group_index, const int p */ OPAL_DECLSPEC int mca_base_var_group_add_enum(const int group_index, const void *storage); +/** + * \internal + * + * Add an event to a group + */ +OPAL_DECLSPEC int mca_base_var_group_add_event (const int group_index, const int event_index); + /** * \internal * diff --git a/opal/runtime/opal_info_support.c b/opal/runtime/opal_info_support.c index e167451d67f..10d151a6547 100644 --- a/opal/runtime/opal_info_support.c +++ b/opal/runtime/opal_info_support.c @@ -11,7 +11,7 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2006-2015 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2010-2016 Los Alamos National Security, LLC. All rights + * Copyright (c) 2010-2018 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2011-2012 University of Houston. All rights reserved. * Copyright (c) 2016-2017 Intel, Inc. All rights reserved. @@ -50,6 +50,10 @@ #include "opal/util/output.h" #include "opal/util/printf.h" #include "opal/util/show_help.h" +#include "opal/runtime/opal.h" +#include "opal/dss/dss.h" +#include "opal/mca/base/mca_base_pvar.h" +#include "opal/mca/base/mca_base_event.h" #include "opal/include/opal/frameworks.h" @@ -667,6 +671,7 @@ static void opal_info_show_mca_group_params(const mca_base_var_group_t *group, { const int *variables, *groups; const mca_base_pvar_t *pvar; + mca_base_event_t *event; const char *group_component; const mca_base_var_t *var; char **strings, *message; @@ -804,6 +809,52 @@ static void opal_info_show_mca_group_params(const mca_base_var_group_t *group, free(strings); } + variables = OPAL_VALUE_ARRAY_GET_BASE(&group->group_events, const int); + count = opal_value_array_get_size((opal_value_array_t *)&group->group_events); + + for (i = 0 ; i < count ; ++i) { + ret = mca_base_event_get_by_index (variables[i], &event); + if (OPAL_SUCCESS != ret || max_level < event->event_verbosity) { + continue; + } + + if (opal_info_pretty && curr_group != group) { + asprintf(&message, "MCA%s %s%s", requested ? "" : " (-)", + group->group_framework, + component_msg ? component_msg : ""); + opal_info_out(message, message, "---------------------------------------------------"); + free(message); + curr_group = group; + } + + ret = mca_base_event_dump (variables[i], &strings, !opal_info_pretty ? MCA_BASE_VAR_DUMP_PARSABLE : MCA_BASE_VAR_DUMP_READABLE); + if (OPAL_SUCCESS != ret) { + continue; + } + + for (j = 0 ; strings[j] ; ++j) { + if (0 == j && opal_info_pretty) { + asprintf (&message, "MCA%s %s%s", requested ? "" : " (-)", + group->group_framework, + component_msg ? component_msg : ""); + opal_info_out(message, message, strings[j]); + free(message); + } else { + opal_info_out("", "", strings[j]); + } + free(strings[j]); + } + if (!opal_info_pretty) { + /* generate an entry indicating whether this variable is disabled or not. if the + * format in mca_base_var/pvar/event.c changes this needs to be changed as well */ + asprintf (&message, "mca:%s:%s:event:%s:disabled:%s", group->group_framework, + group_component, event->event_name, requested ? "false" : "true"); + opal_info_out("", "", message); + free (message); + } + free(strings); + } + groups = OPAL_VALUE_ARRAY_GET_BASE(&group->group_subgroups, const int); count = opal_value_array_get_size((opal_value_array_t *) &group->group_subgroups); From a91b0b8eb37c7b94882d107d5f5fb5bfd6f586a1 Mon Sep 17 00:00:00 2001 From: Chris Chambreau Date: Mon, 23 Mar 2020 08:37:57 -0700 Subject: [PATCH 02/23] Modifications for changes to proposed MPI_T Events API as well as minor fixes. Signed-off-by: Chris Chambreau --- ompi/include/mpi.h.in | 8 ++++---- ompi/mca/pml/ob1/pml_ob1_component.c | 4 ++-- ompi/mpi/tool/event_get_info.c | 25 ++++++++++++++++++++++++- ompi/mpi/tool/source_get_info.c | 12 +++++++++--- opal/mca/base/mca_base_event.c | 2 +- opal/mca/base/mca_base_var.c | 1 + 6 files changed, 41 insertions(+), 11 deletions(-) diff --git a/ompi/include/mpi.h.in b/ompi/include/mpi.h.in index e0b910306d9..a5b48a392d3 100644 --- a/ompi/include/mpi.h.in +++ b/ompi/include/mpi.h.in @@ -928,12 +928,12 @@ typedef enum { /* * MPIT source ordering */ -enum ompi_mpi_t_order_t { +enum ompi_mpi_t_source_order_t { MPI_T_ORDERED, MPI_T_UNORDERED, }; -typedef enum ompi_mpi_t_order_t MPI_T_order; +typedef enum ompi_mpi_t_source_order_t MPI_T_source_order; /* * MPI Tool event functions @@ -3025,7 +3025,7 @@ OMPI_DECLSPEC int PMPI_T_event_get_timestamp (MPI_T_event_instance event, MPI_C OMPI_DECLSPEC int PMPI_T_event_get_source (MPI_T_event_instance event, int *source_index); OMPI_DECLSPEC int PMPI_T_source_get_num (int *num_source); OMPI_DECLSPEC int PMPI_T_source_get_info (int source_id, char *name, int *name_len, - char *desc, int *desc_len, MPI_T_order *ordering, + char *desc, int *desc_len, MPI_T_source_order *ordering, MPI_Count *ticks_per_second, MPI_Count *max_timestamp, MPI_Info *info); OMPI_DECLSPEC int PMPI_T_source_get_timestamp (int source_id, MPI_Count *timestamp); @@ -3139,7 +3139,7 @@ OMPI_DECLSPEC int MPI_T_event_get_source (MPI_T_event_instance event, int *sour OMPI_DECLSPEC int MPI_T_source_get_num (int *num_source); OMPI_DECLSPEC int MPI_T_source_get_info (int source_id, char *name, int *name_len, - char *desc, int *desc_len, MPI_T_order *ordering, + char *desc, int *desc_len, MPI_T_source_order *ordering, MPI_Count *ticks_per_second, MPI_Count *max_timestamp, MPI_Info *info); OMPI_DECLSPEC int MPI_T_source_get_timestamp (int source_id, MPI_Count *timestamp); diff --git a/ompi/mca/pml/ob1/pml_ob1_component.c b/ompi/mca/pml/ob1/pml_ob1_component.c index c7644338b2f..bc17b87454c 100644 --- a/ompi/mca/pml/ob1/pml_ob1_component.c +++ b/ompi/mca/pml/ob1/pml_ob1_component.c @@ -103,12 +103,12 @@ mca_base_event_list_item_t mca_pml_ob1_events[] = { [MCA_PML_OB1_EVENT_SEARCH_POSTED_BEGIN] = {.name = "search_posted_begin", .desc = "Begin searching posted message queue", .verbosity = OPAL_INFO_LVL_5, .datatypes = &mca_pml_ob1_match_hdr_types[1], - .offsets = &mca_pml_ob1_match_hdr_offsets[1], .num_datatypes = 2, + .offsets = &mca_pml_ob1_match_hdr_offsets[1], .num_datatypes = 3, .elements = &mca_pml_ob1_match_hdr_names[1], .extent = 8, .bind = MCA_BASE_VAR_BIND_MPI_COMM}, [MCA_PML_OB1_EVENT_SEARCH_POSTED_END] = {.name = "search_posted_end", .desc = "Finished searching posted message queue", .verbosity = OPAL_INFO_LVL_5, .datatypes = &mca_pml_ob1_match_hdr_types[1], - .offsets = &mca_pml_ob1_match_hdr_offsets[1], .num_datatypes = 2, + .offsets = &mca_pml_ob1_match_hdr_offsets[1], .num_datatypes = 3, .elements = &mca_pml_ob1_match_hdr_names[1], .extent = 8, .bind = MCA_BASE_VAR_BIND_MPI_COMM}, [MCA_PML_OB1_EVENT_SEARCH_UNEX_BEGIN] = {.name = "search_unexpected_begin", .desc = "Begin searching unexpected message queue", diff --git a/ompi/mpi/tool/event_get_info.c b/ompi/mpi/tool/event_get_info.c index d1839d5799a..a5d2987df06 100644 --- a/ompi/mpi/tool/event_get_info.c +++ b/ompi/mpi/tool/event_get_info.c @@ -61,7 +61,30 @@ int MPI_T_event_get_info (int event_index, char *name, int *name_len, mpit_copy_string (name, name_len, event->event_name); mpit_copy_string (desc, desc_len, event->event_description); - max_datatypes = num_elements ? (*num_elements < (int) (event->event_datatype_count + 1) ? *num_elements - 1 : event->event_datatype_count) : 0; + // num_elements is INOUT + // + // Can query number of datatypes, returned in num_elements + // if array_of_datatypes or displacements are NULL, just return data_type_count. + // Otherwise, if array_of_datatypes or displacements are not NULL, use num_elements + // as maximum datatypes or displacements returned. + // + // Unless the user passes the NULL pointer for num_elements, + // the function returns the number of elements required for this event type. + // + // If the number of elements used by the event type is larger than the value of num_elements + // provided by the user, the number of datatype handles and displacements returned in the + // corresponding arrays is truncated to the value of num_elements passed in by the user. + + max_datatypes = 0; + if (num_elements) { + if (NULL != array_of_datatypes || NULL != array_of_displacements) { + if (*num_elements < (int) (event->event_datatype_count)) + max_datatypes = *num_elements; + else + max_datatypes = event->event_datatype_count; + } + *num_elements = event->event_datatype_count; + } if (max_datatypes) { if (array_of_datatypes) { diff --git a/ompi/mpi/tool/source_get_info.c b/ompi/mpi/tool/source_get_info.c index 0b98e8a204e..b545c166e55 100644 --- a/ompi/mpi/tool/source_get_info.c +++ b/ompi/mpi/tool/source_get_info.c @@ -22,7 +22,7 @@ #include "ompi/mpi/tool/profile/defines.h" #endif -int MPI_T_source_get_info (int source_id, char *name, int *name_len, char *desc, int *desc_len, MPI_T_order *ordering, +int MPI_T_source_get_info (int source_id, char *name, int *name_len, char *desc, int *desc_len, MPI_T_source_order *ordering, MPI_Count *ticks_per_second, MPI_Count *max_timestamp, MPI_Info *info) { mca_base_source_t *source; @@ -37,11 +37,17 @@ int MPI_T_source_get_info (int source_id, char *name, int *name_len, char *desc, return MPI_T_ERR_INVALID_INDEX; } + if (NULL == name && name_len) + *name_len = strlen(source->source_name); + if (name && name_len) { strncpy (name, source->source_name, *name_len); *name_len = strlen (name); } + if (NULL == desc && desc_len) + *desc_len = strlen(source->source_description); + if (desc && desc_len) { strncpy (desc, source->source_description, *desc_len); *desc_len = strlen (desc); @@ -56,10 +62,10 @@ int MPI_T_source_get_info (int source_id, char *name, int *name_len, char *desc, } if (max_timestamp) { - *max_timestamp = SIZE_T_MAX; + *max_timestamp = SIZE_MAX; } - if (*info) { + if (NULL != info && *info) { *info = OBJ_NEW(ompi_info_t); } diff --git a/opal/mca/base/mca_base_event.c b/opal/mca/base/mca_base_event.c index 124977f2ce8..4d1eb5177fa 100644 --- a/opal/mca/base/mca_base_event.c +++ b/opal/mca/base/mca_base_event.c @@ -26,7 +26,7 @@ #include "opal/class/opal_pointer_array.h" #include "opal/class/opal_hash_table.h" -#include "opal/threads/thread_usage.h" +#include "opal/mca/threads/thread_usage.h" static opal_hash_table_t mca_base_event_index_hash; static opal_pointer_array_t registered_events; diff --git a/opal/mca/base/mca_base_var.c b/opal/mca/base/mca_base_var.c index 7e5747ad94a..f604ab0cb3b 100644 --- a/opal/mca/base/mca_base_var.c +++ b/opal/mca/base/mca_base_var.c @@ -277,6 +277,7 @@ int mca_base_var_init(void) if (NULL == (cwd = getcwd(NULL, 0))) { opal_output(0, "Error: Unable to get the current working directory\n"); cwd = strdup("."); + } ret = mca_base_source_init (); if (OPAL_SUCCESS != ret) { From bbd690ec35c16d2282aa49a8c3b17bf1f753c5c6 Mon Sep 17 00:00:00 2001 From: Howard Pritchard Date: Wed, 24 Nov 2021 14:35:29 -0700 Subject: [PATCH 03/23] remove include of dss.h dss.h has been removed since this PR was originally opened Signed-off-by: Howard Pritchard --- opal/runtime/opal_info_support.c | 1 - 1 file changed, 1 deletion(-) diff --git a/opal/runtime/opal_info_support.c b/opal/runtime/opal_info_support.c index 10d151a6547..7f6a455b29b 100644 --- a/opal/runtime/opal_info_support.c +++ b/opal/runtime/opal_info_support.c @@ -51,7 +51,6 @@ #include "opal/util/printf.h" #include "opal/util/show_help.h" #include "opal/runtime/opal.h" -#include "opal/dss/dss.h" #include "opal/mca/base/mca_base_pvar.h" #include "opal/mca/base/mca_base_event.h" From 47850056411ebe5d8629825420e854a9228d46e2 Mon Sep 17 00:00:00 2001 From: Chris Chambreau Date: Thu, 23 Dec 2021 15:22:47 -0800 Subject: [PATCH 04/23] Remove non-conformant event_get_info extent argument and internal tracking. Signed-off-by: Chris Chambreau --- ompi/include/mpi.h.in | 4 ++-- ompi/mca/osc/rdma/osc_rdma_component.c | 24 +++++++++---------- ompi/mca/pml/ob1/pml_ob1_component.c | 33 +++++++++++++------------- ompi/mpi/tool/event_get_info.c | 6 +---- opal/mca/base/mca_base_event.c | 14 +++++------ opal/mca/base/mca_base_event.h | 9 ++----- 6 files changed, 39 insertions(+), 51 deletions(-) diff --git a/ompi/include/mpi.h.in b/ompi/include/mpi.h.in index a5b48a392d3..da21d8fde8d 100644 --- a/ompi/include/mpi.h.in +++ b/ompi/include/mpi.h.in @@ -3000,7 +3000,7 @@ OMPI_DECLSPEC int PMPI_T_event_get_num (int *num_events); OMPI_DECLSPEC int PMPI_T_event_get_info (int event_index, char *name, int *name_len, int *verbosity, MPI_Datatype *array_of_datatypes, MPI_Aint *array_of_displacements, int *num_elements, - MPI_Aint *extent, MPI_T_enum *enumtype, MPI_Info *info, + MPI_T_enum *enumtype, MPI_Info *info, char *desc, int *desc_len, int *bind); OMPI_DECLSPEC int PMPI_T_event_get_index (const char *name, int *event_index); OMPI_DECLSPEC int PMPI_T_event_handle_alloc (int event_index, void *obj_handle, @@ -3113,7 +3113,7 @@ OMPI_DECLSPEC int MPI_T_event_get_num (int *num_events); OMPI_DECLSPEC int MPI_T_event_get_info (int event_index, char *name, int *name_len, int *verbosity, MPI_Datatype *array_of_datatypes, MPI_Aint *array_of_displacements, int *num_elements, - MPI_Aint *extent, MPI_T_enum *enumtype, MPI_Info *info, + MPI_T_enum *enumtype, MPI_Info *info, char *desc, int *desc_len, int *bind); OMPI_DECLSPEC int MPI_T_event_get_index (const char *name, int *event_index); OMPI_DECLSPEC int MPI_T_event_handle_alloc (int event_index, void *obj_handle, diff --git a/ompi/mca/osc/rdma/osc_rdma_component.c b/ompi/mca/osc/rdma/osc_rdma_component.c index 04259d1ca8b..b2674cb6373 100644 --- a/ompi/mca/osc/rdma/osc_rdma_component.c +++ b/ompi/mca/osc/rdma/osc_rdma_component.c @@ -106,62 +106,62 @@ mca_base_event_list_item_t mca_osc_rdma_events[] = { [OMPI_OSC_RDMA_EVENT_LOCK_ACQUIRED] = {.name = "lock_acquired", .desc = "Passive-target lock aquired", .verbosity = OPAL_INFO_LVL_5, .datatypes = &(opal_datatype_t *) {&ompi_mpi_int.dt.super}, .offsets = &(unsigned long) {0}, .num_datatypes = 1, .elements = mca_osc_rdma_target_element, - .extent = sizeof (int), .bind = MCA_BASE_VAR_BIND_MPI_WIN}, + .bind = MCA_BASE_VAR_BIND_MPI_WIN}, [OMPI_OSC_RDMA_EVENT_LOCK_RELEASED] = {.name = "lock_released", .desc = "Passive-target lock required", .verbosity = OPAL_INFO_LVL_5, .datatypes = &(opal_datatype_t *) {&ompi_mpi_int.dt.super}, .offsets = &(unsigned long) {0}, .num_datatypes = 1, .elements = mca_osc_rdma_target_element, - .extent = sizeof (int), .bind = MCA_BASE_VAR_BIND_MPI_WIN}, + .bind = MCA_BASE_VAR_BIND_MPI_WIN}, [OMPI_OSC_RDMA_EVENT_PUT_STARTED] = {.name = "put_started", .desc = "Put started to target. Complete event may not exist.", .verbosity = OPAL_INFO_LVL_5, .datatypes = mca_osc_rdma_rdma_event_types, .offsets = mca_osc_rdma_rdma_event_offsets, .num_datatypes = 3, - .elements = mca_osc_rdma_rdma_event_elements, .extent = 24, .bind = MCA_BASE_VAR_BIND_MPI_WIN}, + .elements = mca_osc_rdma_rdma_event_elements, .bind = MCA_BASE_VAR_BIND_MPI_WIN}, [OMPI_OSC_RDMA_EVENT_PUT_COMPLETE] = {.name = "put_complete", .desc = "Put completed on target", .verbosity = OPAL_INFO_LVL_5, .datatypes = mca_osc_rdma_rdma_event_types, .offsets = mca_osc_rdma_rdma_event_offsets, .num_datatypes = 3, - .elements = mca_osc_rdma_rdma_event_elements, .extent = 24, .bind = MCA_BASE_VAR_BIND_MPI_WIN}, + .elements = mca_osc_rdma_rdma_event_elements, .bind = MCA_BASE_VAR_BIND_MPI_WIN}, [OMPI_OSC_RDMA_EVENT_GET_STARTED] = {.name = "get_started", .desc = "Put started to target. Complete event may not exist.", .verbosity = OPAL_INFO_LVL_5, .datatypes = mca_osc_rdma_rdma_event_types, .offsets = mca_osc_rdma_rdma_event_offsets, .num_datatypes = 3, - .elements = mca_osc_rdma_rdma_event_elements, .extent = 24, .bind = MCA_BASE_VAR_BIND_MPI_WIN}, + .elements = mca_osc_rdma_rdma_event_elements, .bind = MCA_BASE_VAR_BIND_MPI_WIN}, [OMPI_OSC_RDMA_EVENT_GET_COMPLETE] = {.name = "get_complete", .desc = "Put completed on target", .verbosity = OPAL_INFO_LVL_5, .datatypes = mca_osc_rdma_rdma_event_types, .offsets = mca_osc_rdma_rdma_event_offsets, .num_datatypes = 3, - .elements = mca_osc_rdma_rdma_event_elements, .extent = 24, .bind = MCA_BASE_VAR_BIND_MPI_WIN}, + .elements = mca_osc_rdma_rdma_event_elements, .bind = MCA_BASE_VAR_BIND_MPI_WIN}, [OMPI_OSC_RDMA_EVENT_FLUSH_STARTED] = {.name = "flush_started", .desc = "Flush started on target", .verbosity = OPAL_INFO_LVL_5, .datatypes = &(opal_datatype_t *) {&ompi_mpi_int.dt.super}, .offsets = &(unsigned long) {0}, .num_datatypes = 1, .elements = mca_osc_rdma_target_element, - .extent = sizeof (int), .bind = MCA_BASE_VAR_BIND_MPI_WIN}, + .bind = MCA_BASE_VAR_BIND_MPI_WIN}, [OMPI_OSC_RDMA_EVENT_FLUSH_COMPLETE] = {.name = "flush_complete", .desc = "Flush complete on target", .verbosity = OPAL_INFO_LVL_5, .datatypes = &(opal_datatype_t *) {&ompi_mpi_int.dt.super}, .offsets = &(unsigned long) {0}, .num_datatypes = 1, .elements = mca_osc_rdma_target_element, - .extent = sizeof (int), .bind = MCA_BASE_VAR_BIND_MPI_WIN}, + .bind = MCA_BASE_VAR_BIND_MPI_WIN}, [OMPI_OSC_RDMA_EVENT_PSCW_EXPOSE_START] = {.name = "pscw_expose_start", .desc = "PSWW exposure started", .verbosity = OPAL_INFO_LVL_5, .datatypes = &(opal_datatype_t *) {&ompi_mpi_int.dt.super}, .offsets = &(unsigned long) {0}, .num_datatypes = 0, .elements = mca_osc_rdma_target_element, - .extent = sizeof (int), .bind = MCA_BASE_VAR_BIND_MPI_WIN}, + .bind = MCA_BASE_VAR_BIND_MPI_WIN}, [OMPI_OSC_RDMA_EVENT_PSCW_EXPOSE_COMPLETE] = {.name = "pscw_expose_complete", .desc = "PSWW exposure complete", .verbosity = OPAL_INFO_LVL_5, .datatypes = &(opal_datatype_t *) {&ompi_mpi_int.dt.super}, .offsets = &(unsigned long) {0}, .num_datatypes = 0, .elements = mca_osc_rdma_target_element, - .extent = sizeof (int), .bind = MCA_BASE_VAR_BIND_MPI_WIN}, + .bind = MCA_BASE_VAR_BIND_MPI_WIN}, [OMPI_OSC_RDMA_EVENT_PSCW_ACCESS_START] = {.name = "pscw_access_start", .desc = "PSWW access epoch started", .verbosity = OPAL_INFO_LVL_5, .datatypes = &(opal_datatype_t *) {&ompi_mpi_int.dt.super}, .offsets = &(unsigned long) {0}, .num_datatypes = 1, .elements = mca_osc_rdma_target_element, - .extent = sizeof (int), .bind = MCA_BASE_VAR_BIND_MPI_WIN}, + .bind = MCA_BASE_VAR_BIND_MPI_WIN}, [OMPI_OSC_RDMA_EVENT_PSCW_ACCESS_COMPLETE] = {.name = "pscw_access_complete", .desc = "PSWW access epoch complete", .verbosity = OPAL_INFO_LVL_5, .datatypes = &(opal_datatype_t *) {&ompi_mpi_int.dt.super}, .offsets = &(unsigned long) {0}, .num_datatypes = 1, .elements = mca_osc_rdma_target_element, - .extent = sizeof (int), .bind = MCA_BASE_VAR_BIND_MPI_WIN}, + .bind = MCA_BASE_VAR_BIND_MPI_WIN}, [OMPI_OSC_RDMA_EVENT_FENCE] = {.name = "fence", .desc = "Fence called", .verbosity = OPAL_INFO_LVL_5, .bind = MCA_BASE_VAR_BIND_MPI_WIN}, }; diff --git a/ompi/mca/pml/ob1/pml_ob1_component.c b/ompi/mca/pml/ob1/pml_ob1_component.c index bc17b87454c..6a9b5d1f01f 100644 --- a/ompi/mca/pml/ob1/pml_ob1_component.c +++ b/ompi/mca/pml/ob1/pml_ob1_component.c @@ -99,74 +99,73 @@ mca_base_event_list_item_t mca_pml_ob1_events[] = { [MCA_PML_OB1_EVENT_MESSAGE_ARRIVED] = {.name = "message_arrived", .desc = "Message arrived for match", .verbosity = OPAL_INFO_LVL_5, .datatypes = mca_pml_ob1_match_hdr_types, .offsets = mca_pml_ob1_match_hdr_offsets, .num_datatypes = 4, - .elements = mca_pml_ob1_match_hdr_names, .extent = 12, .bind = MCA_BASE_VAR_BIND_MPI_COMM}, + .elements = mca_pml_ob1_match_hdr_names, .bind = MCA_BASE_VAR_BIND_MPI_COMM}, [MCA_PML_OB1_EVENT_SEARCH_POSTED_BEGIN] = {.name = "search_posted_begin", .desc = "Begin searching posted message queue", .verbosity = OPAL_INFO_LVL_5, .datatypes = &mca_pml_ob1_match_hdr_types[1], .offsets = &mca_pml_ob1_match_hdr_offsets[1], .num_datatypes = 3, - .elements = &mca_pml_ob1_match_hdr_names[1], .extent = 8, .bind = MCA_BASE_VAR_BIND_MPI_COMM}, + .elements = &mca_pml_ob1_match_hdr_names[1], .bind = MCA_BASE_VAR_BIND_MPI_COMM}, [MCA_PML_OB1_EVENT_SEARCH_POSTED_END] = {.name = "search_posted_end", .desc = "Finished searching posted message queue", .verbosity = OPAL_INFO_LVL_5, .datatypes = &mca_pml_ob1_match_hdr_types[1], .offsets = &mca_pml_ob1_match_hdr_offsets[1], .num_datatypes = 3, - .elements = &mca_pml_ob1_match_hdr_names[1], .extent = 8, .bind = MCA_BASE_VAR_BIND_MPI_COMM}, + .elements = &mca_pml_ob1_match_hdr_names[1], .bind = MCA_BASE_VAR_BIND_MPI_COMM}, [MCA_PML_OB1_EVENT_SEARCH_UNEX_BEGIN] = {.name = "search_unexpected_begin", .desc = "Begin searching unexpected message queue", .verbosity = OPAL_INFO_LVL_5, .datatypes = &(opal_datatype_t *) {&ompi_mpi_aint.dt.super}, .offsets = &(unsigned long) {0}, .num_datatypes = 1, .elements = mca_pml_ob1_request_element, - .extent = sizeof (MPI_Aint), .bind = MCA_BASE_VAR_BIND_MPI_COMM}, + .bind = MCA_BASE_VAR_BIND_MPI_COMM}, [MCA_PML_OB1_EVENT_SEARCH_UNEX_END] = {.name = "search_unexpected_end", .desc = "Finished searching unexpected message queue", .verbosity = OPAL_INFO_LVL_5, .datatypes = &(opal_datatype_t *) {&ompi_mpi_aint.dt.super}, .offsets = &(unsigned long) {0}, .num_datatypes = 1, .elements = mca_pml_ob1_request_element, - .extent = sizeof (MPI_Aint), .bind = MCA_BASE_VAR_BIND_MPI_COMM}, + .bind = MCA_BASE_VAR_BIND_MPI_COMM}, [MCA_PML_OB1_EVENT_POSTED_INSERT] = {.name = "posted_insert", .desc = "Added request to the posted message queue", .verbosity = OPAL_INFO_LVL_5, .datatypes = &(opal_datatype_t *) {&ompi_mpi_aint.dt.super}, .offsets = &(unsigned long) {0}, .num_datatypes = 1, .elements = mca_pml_ob1_request_element, - .extent = sizeof (MPI_Aint), .bind = MCA_BASE_VAR_BIND_MPI_COMM}, + .bind = MCA_BASE_VAR_BIND_MPI_COMM}, [MCA_PML_OB1_EVENT_POSTED_REMOVE] = {.name = "posted_remove", .desc = "Remove request from the posted message queue", .verbosity = OPAL_INFO_LVL_5, .datatypes = &(opal_datatype_t *) {&ompi_mpi_aint.dt.super}, .offsets = &(unsigned long) {0}, .num_datatypes = 1, .elements = mca_pml_ob1_request_element, - .extent = sizeof (MPI_Aint), .bind = MCA_BASE_VAR_BIND_MPI_COMM}, + .bind = MCA_BASE_VAR_BIND_MPI_COMM}, [MCA_PML_OB1_EVENT_UNEX_INSERT] = {.name = "unex_insert", .desc = "Unexpected message inserted in queue", .verbosity = OPAL_INFO_LVL_5, .datatypes = &mca_pml_ob1_match_hdr_types[1], .offsets = &mca_pml_ob1_match_hdr_offsets[1], - .num_datatypes = 2, .elements = &mca_pml_ob1_match_hdr_names[1], .extent = 8, .bind = MCA_BASE_VAR_BIND_MPI_COMM}, + .num_datatypes = 2, .elements = &mca_pml_ob1_match_hdr_names[1], .bind = MCA_BASE_VAR_BIND_MPI_COMM}, [MCA_PML_OB1_EVENT_UNEX_REMOVE] = {.name = "unex_remove", .desc = "Unexpected message removed from queue", .verbosity = OPAL_INFO_LVL_5, .datatypes = &mca_pml_ob1_match_hdr_types[1], .offsets = &mca_pml_ob1_match_hdr_offsets[1], - .num_datatypes = 2, .elements = &mca_pml_ob1_match_hdr_names[1], .extent = 8, .bind = MCA_BASE_VAR_BIND_MPI_COMM}, + .num_datatypes = 2, .elements = &mca_pml_ob1_match_hdr_names[1], .bind = MCA_BASE_VAR_BIND_MPI_COMM}, [MCA_PML_OB1_EVENT_TRANSFER_BEGIN] = {.name = "transfer_begin", .desc = "Transfer has begun", .verbosity = OPAL_INFO_LVL_5, .datatypes = &(opal_datatype_t *) {&ompi_mpi_aint.dt.super}, .offsets = &(unsigned long) {0}, .num_datatypes = 1, - .elements = mca_pml_ob1_request_element, .extent = sizeof (MPI_Aint), .bind = MCA_BASE_VAR_BIND_MPI_COMM}, + .elements = mca_pml_ob1_request_element, .bind = MCA_BASE_VAR_BIND_MPI_COMM}, [MCA_PML_OB1_EVENT_TRANSFER] = {.name = "transfer", .desc = "Transfer event", .verbosity = OPAL_INFO_LVL_5, .datatypes = mca_pml_ob1_request_size_types, .offsets = mca_pml_ob1_request_size_offsets, .num_datatypes = 2, - .elements = mca_pml_ob1_request_size_elements, .extent = sizeof (mca_pml_ob1_transfer_event_t), - .bind = MCA_BASE_VAR_BIND_MPI_COMM}, + .elements = mca_pml_ob1_request_size_elements, .bind = MCA_BASE_VAR_BIND_MPI_COMM}, [MCA_PML_OB1_EVENT_TRANSFER_END] = {.name = "transfer_end", .desc = "Transfer has completed", .verbosity = OPAL_INFO_LVL_5, .datatypes = &(opal_datatype_t *) {&ompi_mpi_aint.dt.super}, .offsets = &(unsigned long) {0}, .num_datatypes = 1, - .elements = mca_pml_ob1_request_element, .extent = sizeof (MPI_Aint), .bind = MCA_BASE_VAR_BIND_MPI_COMM}, + .elements = mca_pml_ob1_request_element, .bind = MCA_BASE_VAR_BIND_MPI_COMM}, [MCA_PML_OB1_EVENT_RECEIVE_CANCELED] = {.name = "cancel", .desc = "Receive request canceled", .verbosity = OPAL_INFO_LVL_5, .datatypes = &(opal_datatype_t *) {&ompi_mpi_aint.dt.super}, .offsets = &(unsigned long) {0}, .num_datatypes = 1, - .elements = mca_pml_ob1_request_element, .extent = sizeof (MPI_Aint), .bind = MCA_BASE_VAR_BIND_MPI_COMM}, + .elements = mca_pml_ob1_request_element, .bind = MCA_BASE_VAR_BIND_MPI_COMM}, [MCA_PML_OB1_EVENT_REQUEST_FREE] = {.name = "free", .desc = "Request object freed", .verbosity = OPAL_INFO_LVL_5, .datatypes = &(opal_datatype_t *) {&ompi_mpi_aint.dt.super}, .offsets = &(unsigned long) {0}, .num_datatypes = 1, - .elements = mca_pml_ob1_request_element, .extent = sizeof (MPI_Aint), .bind = MCA_BASE_VAR_BIND_MPI_COMM}, + .elements = mca_pml_ob1_request_element, .bind = MCA_BASE_VAR_BIND_MPI_COMM}, [MCA_PML_OB1_EVENT_REQUEST_ACTIVATE] = {.name = "request_activate", .desc = "Request activated", .verbosity = OPAL_INFO_LVL_5, .datatypes = &(opal_datatype_t *) {&ompi_mpi_aint.dt.super}, .offsets = &(unsigned long) {0}, .num_datatypes = 1, - .elements = mca_pml_ob1_request_element, .extent = sizeof (MPI_Aint), .bind = MCA_BASE_VAR_BIND_MPI_COMM}, + .elements = mca_pml_ob1_request_element, .bind = MCA_BASE_VAR_BIND_MPI_COMM}, [MCA_PML_OB1_EVENT_REQUEST_COMPLETE] = {.name = "request_complete", .desc = "Request completed", .verbosity = OPAL_INFO_LVL_5, .datatypes = &(opal_datatype_t *) {&ompi_mpi_aint.dt.super}, .offsets = &(unsigned long) {0}, .num_datatypes = 1, - .elements = mca_pml_ob1_request_element, .extent = sizeof (MPI_Aint), .bind = MCA_BASE_VAR_BIND_MPI_COMM}, + .elements = mca_pml_ob1_request_element, .bind = MCA_BASE_VAR_BIND_MPI_COMM}, }; mca_pml_base_component_2_1_0_t mca_pml_ob1_component = { diff --git a/ompi/mpi/tool/event_get_info.c b/ompi/mpi/tool/event_get_info.c index a5d2987df06..16e01aeb5ae 100644 --- a/ompi/mpi/tool/event_get_info.c +++ b/ompi/mpi/tool/event_get_info.c @@ -30,7 +30,7 @@ int MPI_T_event_get_info (int event_index, char *name, int *name_len, int *verbosity, MPI_Datatype *array_of_datatypes, MPI_Aint *array_of_displacements, int *num_elements, - MPI_Aint *extent, MPI_T_enum *enumtype, MPI_Info *info, + MPI_T_enum *enumtype, MPI_Info *info, char *desc, int *desc_len, int *bind) { mca_base_event_t * const event; @@ -125,10 +125,6 @@ int MPI_T_event_get_info (int event_index, char *name, int *name_len, *bind = event->event_bind; } - if (NULL != extent) { - *extent = event->event_extent; - } - if (NULL != info) { *info = OBJ_NEW(ompi_info_t); } diff --git a/opal/mca/base/mca_base_event.c b/opal/mca/base/mca_base_event.c index 4d1eb5177fa..5ca60474ca0 100644 --- a/opal/mca/base/mca_base_event.c +++ b/opal/mca/base/mca_base_event.c @@ -180,7 +180,7 @@ int mca_base_event_get_count (int *count) int mca_base_event_register (const char *project, const char *framework, const char *component, const char *name, const char *description, mca_base_var_info_lvl_t verbosity, opal_datatype_t **datatypes, - unsigned long *offsets, size_t num_datatypes, mca_base_var_enum_t *enumerator, int extent, int bind, + unsigned long *offsets, size_t num_datatypes, mca_base_var_enum_t *enumerator, int bind, int source, uint32_t flags, mca_base_notify_fn_t notify, void *ctx, mca_base_event_t **event_out) { int ret, group_index; @@ -257,7 +257,6 @@ int mca_base_event_register (const char *project, const char *framework, const c event->event_verbosity = verbosity; event->event_source = mca_base_source_get (source); - event->event_extent = extent; if (event->event_enumerator) { OBJ_RELEASE(event->event_enumerator); @@ -292,12 +291,12 @@ int mca_base_event_register (const char *project, const char *framework, const c int mca_base_component_event_register (const mca_base_component_t *component, const char *name, const char *description, mca_base_var_info_lvl_t verbosity, opal_datatype_t **datatypes, - unsigned long *offsets, size_t num_datatypes, mca_base_var_enum_t *enumerator, int extent, int bind, + unsigned long *offsets, size_t num_datatypes, mca_base_var_enum_t *enumerator, int bind, int source, uint32_t flags, mca_base_notify_fn_t notify, void *ctx, mca_base_event_t **event_out) { /* invalidate this variable if the component's group is deregistered */ return mca_base_event_register (component->mca_project_name, component->mca_type_name, component->mca_component_name, - name, description, verbosity, datatypes, offsets, num_datatypes, enumerator, extent, bind, + name, description, verbosity, datatypes, offsets, num_datatypes, enumerator, bind, source, flags | MCA_BASE_EVENT_FLAG_IWG, notify, ctx, event_out); } @@ -321,7 +320,7 @@ int mca_base_component_event_register_list (const mca_base_component_t *componen ret = mca_base_event_register (component->mca_project_name, component->mca_type_name, component->mca_component_name, item->name, item->desc, item->verbosity, item->datatypes, item->offsets, item->num_datatypes, - new_enum, item->extent, item->bind, item->source, item->flags | MCA_BASE_EVENT_FLAG_IWG, + new_enum, item->bind, item->source, item->flags | MCA_BASE_EVENT_FLAG_IWG, item->notify, item->ctx, &item->event); if (new_enum) { @@ -460,7 +459,6 @@ int mca_base_event_dump(int index, char ***out, mca_base_var_dump_type_t output_ /* build the message*/ (void)asprintf(&tmp, "mca:%s:%s:event:%s:", framework, component, full_name); - (void)asprintf(out[0] + line++, "%sextent:%lu", tmp, (unsigned long) event->event_extent); (void)asprintf(out[0] + line++, "%snum_datatypes:%lu", tmp, (unsigned long) event->event_datatype_count); for (size_t i = 0 ; i < event->event_datatype_count ; ++i) { (void)asprintf(out[0] + line++, "%sdatatypes:%lu:%s", tmp, (unsigned long) i, event->event_datatypes[i]->name); @@ -494,8 +492,8 @@ int mca_base_event_dump(int index, char ***out, mca_base_var_dump_type_t output_ return OPAL_ERR_OUT_OF_RESOURCE; } - (void)asprintf (out[0] + line++, "event \"%s\" (extent: %lu, datatype count: %ld)", full_name, - (unsigned long) event->event_extent, (long) event->event_datatype_count); + (void)asprintf (out[0] + line++, "event \"%s\" (datatype count: %ld)", full_name, + (long) event->event_datatype_count); if (event->event_description) { (void)asprintf(out[0] + line++, "%s", event->event_description); diff --git a/opal/mca/base/mca_base_event.h b/opal/mca/base/mca_base_event.h index ee740edf0fa..8003c8a1f71 100644 --- a/opal/mca/base/mca_base_event.h +++ b/opal/mca/base/mca_base_event.h @@ -96,10 +96,6 @@ typedef struct mca_base_event_t { /** Size of the event_datatypes array */ size_t event_datatype_count; - /** size of the event data */ - size_t event_extent; - - /** Enumerator for integer values */ mca_base_var_enum_t *event_enumerator; @@ -135,7 +131,6 @@ typedef struct mca_base_event_list_item_t { unsigned long *offsets; size_t num_datatypes; char **elements; - int extent; int bind; int source; uint32_t flags; @@ -177,12 +172,12 @@ OPAL_DECLSPEC int mca_base_event_dump(int index, char ***out, mca_base_var_dump_ OPAL_DECLSPEC int mca_base_event_register (const char *project, const char *framework, const char *component, const char *name, const char *description, mca_base_var_info_lvl_t verbosity, opal_datatype_t **datatypes, - unsigned long *offsets, size_t num_datatypes, mca_base_var_enum_t *enumerator, int extent, int bind, + unsigned long *offsets, size_t num_datatypes, mca_base_var_enum_t *enumerator, int bind, int source, uint32_t flags, mca_base_notify_fn_t notify, void *ctx, mca_base_event_t **event_out); OPAL_DECLSPEC int mca_base_component_event_register (const mca_base_component_t *component, const char *name, const char *description, mca_base_var_info_lvl_t verbosity, opal_datatype_t **datatypes, - unsigned long *offsets, size_t num_datatypes, mca_base_var_enum_t *enumerator, int extent, int bind, + unsigned long *offsets, size_t num_datatypes, mca_base_var_enum_t *enumerator, int bind, int source, uint32_t flags, mca_base_notify_fn_t notify, void *ctx, mca_base_event_t **event_out); OPAL_DECLSPEC int mca_base_component_event_register_list (const mca_base_component_t *component, mca_base_event_list_item_t *list, int count); From f96df24be46ce4005911fa9eac47db26f780804b Mon Sep 17 00:00:00 2001 From: Chris Chambreau Date: Thu, 23 Dec 2021 15:38:45 -0800 Subject: [PATCH 05/23] Add user_data argument to MPI_T_event_handle_free function. Signed-off-by: Chris Chambreau --- ompi/include/mpi.h.in | 2 ++ ompi/mpi/tool/event_handle_free.c | 1 + 2 files changed, 3 insertions(+) diff --git a/ompi/include/mpi.h.in b/ompi/include/mpi.h.in index da21d8fde8d..0c8786a70a8 100644 --- a/ompi/include/mpi.h.in +++ b/ompi/include/mpi.h.in @@ -3016,6 +3016,7 @@ OMPI_DECLSPEC int PMPI_T_event_callback_set_info (MPI_T_event_registration even OMPI_DECLSPEC int PMPI_T_event_callback_get_info (MPI_T_event_registration event_registration, MPI_T_cb_safety cb_safety, MPI_Info *info_used); OMPI_DECLSPEC int PMPI_T_event_handle_free (MPI_T_event_registration event_registration, + void *user_data, MPI_T_event_free_cb_function free_cb_function); OMPI_DECLSPEC int PMPI_T_event_set_dropped_handler (MPI_T_event_registration handle, MPI_T_event_dropped_cb_function dropped_cb_function); @@ -3122,6 +3123,7 @@ OMPI_DECLSPEC int MPI_T_event_handle_set_info (MPI_T_event_registration event_r OMPI_DECLSPEC int MPI_T_event_handle_get_info (MPI_T_event_registration event_registration, MPI_Info *info_used); OMPI_DECLSPEC int MPI_T_event_handle_free (MPI_T_event_registration event_registration, + void *user_data, MPI_T_event_free_cb_function free_cb_function); OMPI_DECLSPEC int MPI_T_event_register_callback (MPI_T_event_registration event_registration, MPI_T_cb_safety cb_safety, MPI_Info info, void *user_data, diff --git a/ompi/mpi/tool/event_handle_free.c b/ompi/mpi/tool/event_handle_free.c index 3453fdca43b..5a1ddabfde4 100644 --- a/ompi/mpi/tool/event_handle_free.c +++ b/ompi/mpi/tool/event_handle_free.c @@ -25,6 +25,7 @@ int MPI_T_event_handle_free (MPI_T_event_registration event_registration, + void *user_data, MPI_T_event_free_cb_function free_cb_function) { int ret = MPI_SUCCESS; From 0b2f31ea6e8a3fb06c391b8c57fef34eda7bb364 Mon Sep 17 00:00:00 2001 From: Chris Chambreau Date: Thu, 23 Dec 2021 16:13:45 -0800 Subject: [PATCH 06/23] Fix generation of event_get_info displacements and related copy_data functionality Signed-off-by: Chris Chambreau --- ompi/mpi/tool/event_get_info.c | 3 ++- opal/mca/base/mca_base_event.c | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ompi/mpi/tool/event_get_info.c b/ompi/mpi/tool/event_get_info.c index 16e01aeb5ae..9547c1d836f 100644 --- a/ompi/mpi/tool/event_get_info.c +++ b/ompi/mpi/tool/event_get_info.c @@ -106,7 +106,8 @@ int MPI_T_event_get_info (int event_index, char *name, int *name_len, if (array_of_displacements) { for (int i = 0 ; i < max_datatypes ; i++) { - array_of_displacements[i] = (MPI_Aint) event->event_offsets[i]; + array_of_displacements[i] = (MPI_Aint) current_displacement; + current_displacement += event->event_datatypes[i]->size; } } diff --git a/opal/mca/base/mca_base_event.c b/opal/mca/base/mca_base_event.c index 5ca60474ca0..fa96b1f49f2 100644 --- a/opal/mca/base/mca_base_event.c +++ b/opal/mca/base/mca_base_event.c @@ -612,8 +612,14 @@ int mca_base_event_read (mca_base_raised_event_t *revent, unsigned int element_i void mca_base_event_copy (mca_base_raised_event_t *revent, void *buffer) { mca_base_event_t *event = revent->re_event; + void *buffer_ptr = buffer; - memcpy (buffer, revent->re_data, event->event_extent); + for (size_t i = 0 ; i < event->event_datatype_count ; ++i) { + if (buffer) { + memcpy (buffer_ptr, revent->re_data + event->event_offsets[i], event->event_datatypes[i]->size); + buffer_ptr += event->event_datatypes[i]->size; + } + } } int mca_base_event_read_some (mca_base_raised_event_t *revent, void *array_of_buffers[]) From 1f5eaf5ba2ce513537976f58443a830e25909f15 Mon Sep 17 00:00:00 2001 From: Chris Chambreau Date: Thu, 23 Dec 2021 16:21:53 -0800 Subject: [PATCH 07/23] Minor cleanup - Correct MPI_T_event_dropped_cb_function arguments - Check for negative event index Signed-off-by: Chris Chambreau --- ompi/include/mpi.h.in | 3 ++- ompi/mpi/tool/event_get_info.c | 4 ++-- opal/mca/base/mca_base_event.c | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ompi/include/mpi.h.in b/ompi/include/mpi.h.in index 0c8786a70a8..4c1b90b4dd8 100644 --- a/ompi/include/mpi.h.in +++ b/ompi/include/mpi.h.in @@ -941,8 +941,9 @@ typedef enum ompi_mpi_t_source_order_t MPI_T_source_order; typedef void (*MPI_T_event_free_cb_function) (MPI_T_event_registration handle, MPI_T_cb_safety cb_safety, void *user_data); -typedef void (*MPI_T_event_dropped_cb_function) (int count, +typedef void (*MPI_T_event_dropped_cb_function) (MPI_Count count, MPI_T_event_registration handle, + int source_index, MPI_T_cb_safety cb_safety, void *user_data); typedef void (*MPI_T_event_cb_function) (MPI_T_event_instance event, diff --git a/ompi/mpi/tool/event_get_info.c b/ompi/mpi/tool/event_get_info.c index 9547c1d836f..967e30ac0cc 100644 --- a/ompi/mpi/tool/event_get_info.c +++ b/ompi/mpi/tool/event_get_info.c @@ -34,7 +34,7 @@ int MPI_T_event_get_info (int event_index, char *name, int *name_len, char *desc, int *desc_len, int *bind) { mca_base_event_t * const event; - int ret, max_datatypes = 0; + int ret, max_datatypes = 0, current_displacement = 0; if (!mpit_is_initialized ()) { return MPI_T_ERR_NOT_INITIALIZED; @@ -114,7 +114,7 @@ int MPI_T_event_get_info (int event_index, char *name, int *name_len, *num_elements = max_datatypes; } - if (verbosity) { + if (NULL != verbosity) { *verbosity = event->event_verbosity; } diff --git a/opal/mca/base/mca_base_event.c b/opal/mca/base/mca_base_event.c index fa96b1f49f2..ee176734f85 100644 --- a/opal/mca/base/mca_base_event.c +++ b/opal/mca/base/mca_base_event.c @@ -148,7 +148,7 @@ int mca_base_registration_get_event (mca_base_event_registration_t *registration static int mca_base_event_get_by_index_internal (int index, mca_base_event_t **event, bool invalidok) { - if (index >= event_count) { + if (0 > index || index >= event_count) { return OPAL_ERR_VALUE_OUT_OF_BOUNDS; } From 3fc89db0cfbc49895df8deb22816b3eaed9e8fd4 Mon Sep 17 00:00:00 2001 From: Howard Pritchard Date: Tue, 18 Jan 2022 09:36:55 -0700 Subject: [PATCH 08/23] mpi_t events: convert to new profiling approach Signed-off-by: Howard Pritchard --- ompi/mpi/tool/event_callback_get_info.c | 9 +++++---- ompi/mpi/tool/event_callback_set_info.c | 10 +++++----- ompi/mpi/tool/event_copy.c | 9 +++++---- ompi/mpi/tool/event_get_index.c | 10 +++++----- ompi/mpi/tool/event_get_info.c | 8 ++++---- ompi/mpi/tool/event_get_num.c | 10 +++++----- ompi/mpi/tool/event_get_source.c | 10 +++++----- ompi/mpi/tool/event_get_timestamp.c | 10 ++++------ ompi/mpi/tool/event_handle_alloc.c | 10 +++++----- ompi/mpi/tool/event_handle_free.c | 10 +++++----- ompi/mpi/tool/event_handle_get_info.c | 10 +++++----- ompi/mpi/tool/event_handle_set_info.c | 10 +++++----- ompi/mpi/tool/event_read.c | 10 +++++----- ompi/mpi/tool/event_register_callback.c | 10 +++++----- ompi/mpi/tool/event_set_dropped_handler.c | 9 +++++---- 15 files changed, 73 insertions(+), 72 deletions(-) diff --git a/ompi/mpi/tool/event_callback_get_info.c b/ompi/mpi/tool/event_callback_get_info.c index 220f6543044..2e3baf5a5dc 100644 --- a/ompi/mpi/tool/event_callback_get_info.c +++ b/ompi/mpi/tool/event_callback_get_info.c @@ -14,14 +14,15 @@ * $HEADER$ */ + +#include "ompi_config.h" #include "ompi/mpi/tool/mpit-internal.h" -#if OPAL_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES +#if OMPI_BUILD_MPI_PROFILING +#if OPAL_HAVE_WEAK_SYMBOLS #pragma weak MPI_T_event_callback_get_info = PMPI_T_event_callback_get_info #endif - -#if OMPI_PROFILING_DEFINES -#include "ompi/mpi/tool/profile/defines.h" +#define MPI_T_event_callback_get_info PMPI_T_event_callback_get_info #endif diff --git a/ompi/mpi/tool/event_callback_set_info.c b/ompi/mpi/tool/event_callback_set_info.c index daf356cf656..bc22ba65ede 100644 --- a/ompi/mpi/tool/event_callback_set_info.c +++ b/ompi/mpi/tool/event_callback_set_info.c @@ -14,17 +14,17 @@ * $HEADER$ */ +#include "ompi_config.h" + #include "ompi/mpi/tool/mpit-internal.h" -#if OPAL_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES +#if OMPI_BUILD_MPI_PROFILING +#if OPAL_HAVE_WEAK_SYMBOLS #pragma weak MPI_T_event_callback_set_info = PMPI_T_event_callback_set_info #endif - -#if OMPI_PROFILING_DEFINES -#include "ompi/mpi/tool/profile/defines.h" +#define MPI_T_event_callback_set_info PMPI_T_event_callback_set_info #endif - int MPI_T_event_callback_set_info (MPI_T_event_registration event_registration, MPI_T_cb_safety cb_safety, MPI_Info info) { diff --git a/ompi/mpi/tool/event_copy.c b/ompi/mpi/tool/event_copy.c index f68711629f8..3e9881b9043 100644 --- a/ompi/mpi/tool/event_copy.c +++ b/ompi/mpi/tool/event_copy.c @@ -13,14 +13,15 @@ * $HEADER$ */ +#include "ompi_config.h" + #include "ompi/mpi/tool/mpit-internal.h" -#if OPAL_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES +#if OMPI_BUILD_MPI_PROFILING +#if OPAL_HAVE_WEAK_SYMBOLS #pragma weak MPI_T_event_copy = PMPI_T_event_copy #endif - -#if OMPI_PROFILING_DEFINES -#include "ompi/mpi/tool/profile/defines.h" +#define MPI_T_event_copy PMPI_T_event_copy #endif diff --git a/ompi/mpi/tool/event_get_index.c b/ompi/mpi/tool/event_get_index.c index 08b0aaabfe0..af0ad83ebc1 100644 --- a/ompi/mpi/tool/event_get_index.c +++ b/ompi/mpi/tool/event_get_index.c @@ -12,17 +12,17 @@ * $HEADER$ */ +#include "ompi_config.h" + #include "ompi/mpi/tool/mpit-internal.h" -#if OPAL_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES +#if OMPI_BUILD_MPI_PROFILING +#if OPAL_HAVE_WEAK_SYMBOLS #pragma weak MPI_T_event_get_index = PMPI_T_event_get_index #endif - -#if OMPI_PROFILING_DEFINES -#include "ompi/mpi/tool/profile/defines.h" +#define MPI_T_event_get_index PMPI_T_event_get_index #endif - int MPI_T_event_get_index (const char *name, int *event_index) { mca_base_event_t *event = NULL; diff --git a/ompi/mpi/tool/event_get_info.c b/ompi/mpi/tool/event_get_info.c index 967e30ac0cc..fc5636ce660 100644 --- a/ompi/mpi/tool/event_get_info.c +++ b/ompi/mpi/tool/event_get_info.c @@ -13,18 +13,18 @@ * $HEADER$ */ +#include "ompi_config.h" + #include "ompi/mpi/tool/mpit-internal.h" /* needed to convert between opal and ompi datatypes until a function is provided */ #include "ompi/datatype/ompi_datatype_internal.h" -#if OMPI_PROFILING_DEFINES - +#if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS #pragma weak MPI_T_event_get_info = PMPI_T_event_get_info #endif - -#include "ompi/mpi/tool/profile/defines.h" +#define MPI_T_event_get_info PMPI_T_event_get_info #endif int MPI_T_event_get_info (int event_index, char *name, int *name_len, diff --git a/ompi/mpi/tool/event_get_num.c b/ompi/mpi/tool/event_get_num.c index 24058785861..48d49c5f01c 100644 --- a/ompi/mpi/tool/event_get_num.c +++ b/ompi/mpi/tool/event_get_num.c @@ -12,17 +12,17 @@ * $HEADER$ */ +#include "ompi_config.h" + #include "ompi/mpi/tool/mpit-internal.h" -#if OPAL_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES +#if OMPI_BUILD_MPI_PROFILING +#if OPAL_HAVE_WEAK_SYMBOLS #pragma weak MPI_T_event_get_num = PMPI_T_event_get_num #endif - -#if OMPI_PROFILING_DEFINES -#include "ompi/mpi/tool/profile/defines.h" +#define MPI_T_event_get_num PMPI_T_event_get_num #endif - int MPI_T_event_get_num (int *num_event) { if (!mpit_is_initialized ()) { diff --git a/ompi/mpi/tool/event_get_source.c b/ompi/mpi/tool/event_get_source.c index 936cce9efe1..6273900907b 100644 --- a/ompi/mpi/tool/event_get_source.c +++ b/ompi/mpi/tool/event_get_source.c @@ -13,17 +13,17 @@ * $HEADER$ */ +#include "ompi_config.h" + #include "ompi/mpi/tool/mpit-internal.h" -#if OPAL_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES +#if OMPI_BUILD_MPI_PROFILING +#if OPAL_HAVE_WEAK_SYMBOLS #pragma weak MPI_T_event_get_source = PMPI_T_event_get_source #endif - -#if OMPI_PROFILING_DEFINES -#include "ompi/mpi/tool/profile/defines.h" +#define MPI_T_event_get_source PMPI_T_event_get_source #endif - int MPI_T_event_get_source (MPI_T_event_instance event, int *source_index) { if (!mpit_is_initialized ()) { diff --git a/ompi/mpi/tool/event_get_timestamp.c b/ompi/mpi/tool/event_get_timestamp.c index 88edbaf0d65..ff0b61df759 100644 --- a/ompi/mpi/tool/event_get_timestamp.c +++ b/ompi/mpi/tool/event_get_timestamp.c @@ -13,19 +13,17 @@ * $HEADER$ */ -#include "ompi/mpi/tool/mpit-internal.h" +#include "ompi_config.h" -#if OMPI_PROFILING_DEFINES +#include "ompi/mpi/tool/mpit-internal.h" +#if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS #pragma weak MPI_T_event_get_timestamp = PMPI_T_event_get_timestamp #endif - -#include "ompi/mpi/tool/profile/defines.h" - +#define MPI_T_event_get_timestamp PMPI_T_event_get_timestamp #endif - int MPI_T_event_get_timestamp (MPI_T_event_instance event, MPI_Count *event_time) { uint64_t mca_time; diff --git a/ompi/mpi/tool/event_handle_alloc.c b/ompi/mpi/tool/event_handle_alloc.c index e93a9f57163..c0dfb8d0401 100644 --- a/ompi/mpi/tool/event_handle_alloc.c +++ b/ompi/mpi/tool/event_handle_alloc.c @@ -13,17 +13,17 @@ * $HEADER$ */ +#include "ompi_config.h" + #include "ompi/mpi/tool/mpit-internal.h" -#if OPAL_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES +#if OMPI_BUILD_MPI_PROFILING +#if OPAL_HAVE_WEAK_SYMBOLS #pragma weak MPI_T_event_handle_alloc = PMPI_T_event_handle_alloc #endif - -#if OMPI_PROFILING_DEFINES -#include "ompi/mpi/tool/profile/defines.h" +#define MPI_T_event_handle_alloc PMPI_T_event_handle_alloc #endif - int MPI_T_event_handle_alloc (int event_index, void *obj_handle, MPI_Info info, MPI_T_event_registration *event_registration) { diff --git a/ompi/mpi/tool/event_handle_free.c b/ompi/mpi/tool/event_handle_free.c index 5a1ddabfde4..43ffb4991fa 100644 --- a/ompi/mpi/tool/event_handle_free.c +++ b/ompi/mpi/tool/event_handle_free.c @@ -13,17 +13,17 @@ * $HEADER$ */ +#include "ompi_config.h" + #include "ompi/mpi/tool/mpit-internal.h" -#if OPAL_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES +#if OMPI_BUILD_MPI_PROFILING +#if OPAL_HAVE_WEAK_SYMBOLS #pragma weak MPI_T_event_handle_free = PMPI_T_event_handle_free #endif - -#if OMPI_PROFILING_DEFINES -#include "ompi/mpi/tool/profile/defines.h" +#define MPI_T_event_handle_free PMPI_T_event_handle_free #endif - int MPI_T_event_handle_free (MPI_T_event_registration event_registration, void *user_data, MPI_T_event_free_cb_function free_cb_function) diff --git a/ompi/mpi/tool/event_handle_get_info.c b/ompi/mpi/tool/event_handle_get_info.c index e4636dc9306..bb1a29a672a 100644 --- a/ompi/mpi/tool/event_handle_get_info.c +++ b/ompi/mpi/tool/event_handle_get_info.c @@ -14,17 +14,17 @@ * $HEADER$ */ +#include "ompi_config.h" + #include "ompi/mpi/tool/mpit-internal.h" -#if OPAL_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES +#if OMPI_BUILD_MPI_PROFILING +#if OPAL_HAVE_WEAK_SYMBOLS #pragma weak MPI_T_event_handle_get_info = PMPI_T_event_handle_get_info #endif - -#if OMPI_PROFILING_DEFINES -#include "ompi/mpi/tool/profile/defines.h" +#define MPI_T_event_handle_get_info PMPI_T_event_handle_get_info #endif - int MPI_T_event_handle_get_info (MPI_T_event_registration event_registration, MPI_Info *info_used) { diff --git a/ompi/mpi/tool/event_handle_set_info.c b/ompi/mpi/tool/event_handle_set_info.c index 5b5d1740c07..7f6f2253485 100644 --- a/ompi/mpi/tool/event_handle_set_info.c +++ b/ompi/mpi/tool/event_handle_set_info.c @@ -14,17 +14,17 @@ * $HEADER$ */ +#include "ompi_config.h" + #include "ompi/mpi/tool/mpit-internal.h" -#if OPAL_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES +#if OMPI_BUILD_MPI_PROFILING +#if OPAL_HAVE_WEAK_SYMBOLS #pragma weak MPI_T_event_handle_set_info = PMPI_T_event_handle_set_info #endif - -#if OMPI_PROFILING_DEFINES -#include "ompi/mpi/tool/profile/defines.h" +#define MPI_T_event_handle_set_info PMPI_T_event_handle_set_info #endif - int MPI_T_event_handle_set_info (MPI_T_event_registration event_registration, MPI_Info info) { diff --git a/ompi/mpi/tool/event_read.c b/ompi/mpi/tool/event_read.c index 0a7a9540f3e..5d550ee6738 100644 --- a/ompi/mpi/tool/event_read.c +++ b/ompi/mpi/tool/event_read.c @@ -13,17 +13,17 @@ * $HEADER$ */ +#include "ompi_config.h" + #include "ompi/mpi/tool/mpit-internal.h" -#if OPAL_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES +#if OMPI_BUILD_MPI_PROFILING +#if OPAL_HAVE_WEAK_SYMBOLS #pragma weak MPI_T_event_read = PMPI_T_event_read #endif - -#if OMPI_PROFILING_DEFINES -#include "ompi/mpi/tool/profile/defines.h" +#define MPI_T_event_read PMPI_T_event_read #endif - int MPI_T_event_read (MPI_T_event_instance event, int element_index, void *buffer) { int ret; diff --git a/ompi/mpi/tool/event_register_callback.c b/ompi/mpi/tool/event_register_callback.c index 45cc1073484..5175c8d8a62 100644 --- a/ompi/mpi/tool/event_register_callback.c +++ b/ompi/mpi/tool/event_register_callback.c @@ -13,17 +13,17 @@ * $HEADER$ */ +#include "ompi_config.h" + #include "ompi/mpi/tool/mpit-internal.h" -#if OPAL_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES +#if OMPI_BUILD_MPI_PROFILING +#if OPAL_HAVE_WEAK_SYMBOLS #pragma weak MPI_T_event_register_callback = PMPI_T_event_register_callback #endif - -#if OMPI_PROFILING_DEFINES -#include "ompi/mpi/tool/profile/defines.h" +#define MPI_T_event_register_callback PMPI_T_event_register_callback #endif - int MPI_T_event_register_callback (MPI_T_event_registration event_registration, MPI_T_cb_safety cb_safety, MPI_Info info, void *user_data, MPI_T_event_cb_function event_cb_function) diff --git a/ompi/mpi/tool/event_set_dropped_handler.c b/ompi/mpi/tool/event_set_dropped_handler.c index 5b5267edf33..eb53f0f48b8 100644 --- a/ompi/mpi/tool/event_set_dropped_handler.c +++ b/ompi/mpi/tool/event_set_dropped_handler.c @@ -13,14 +13,15 @@ * $HEADER$ */ +#include "ompi_config.h" + #include "ompi/mpi/tool/mpit-internal.h" -#if OPAL_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES +#if OMPI_BUILD_MPI_PROFILING +#if OPAL_HAVE_WEAK_SYMBOLS #pragma weak MPI_T_event_set_dropped_handler = PMPI_T_event_set_dropped_handler #endif - -#if OMPI_PROFILING_DEFINES -#include "ompi/mpi/tool/profile/defines.h" +#define MPI_T_event_set_dropped_handler PMPI_T_event_set_dropped_handler #endif int MPI_T_event_set_dropped_handler (MPI_T_event_registration handle, MPI_T_event_dropped_cb_function dropped_cb_function) From ce3e7732403f6bc4f409a6dc43ce4c35bf6b7633 Mon Sep 17 00:00:00 2001 From: Howard Pritchard Date: Tue, 18 Jan 2022 09:47:40 -0700 Subject: [PATCH 09/23] mpi_t events fix some missing files for new profile interface generation method Signed-off-by: Howard Pritchard --- ompi/mpi/tool/source_get_info.c | 9 +++++---- ompi/mpi/tool/source_get_num.c | 10 +++++----- ompi/mpi/tool/source_get_timestamp.c | 9 +++++---- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/ompi/mpi/tool/source_get_info.c b/ompi/mpi/tool/source_get_info.c index b545c166e55..b1257e8ae9d 100644 --- a/ompi/mpi/tool/source_get_info.c +++ b/ompi/mpi/tool/source_get_info.c @@ -12,14 +12,15 @@ * $HEADER$ */ +#include "ompi_config.h" + #include "ompi/mpi/tool/mpit-internal.h" -#if OPAL_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES +#if OMPI_BUILD_MPI_PROFILING +#if OPAL_HAVE_WEAK_SYMBOLS #pragma weak MPI_T_source_get_info = PMPI_T_source_get_info #endif - -#if OMPI_PROFILING_DEFINES -#include "ompi/mpi/tool/profile/defines.h" +#define MPI_T_source_get_info PMPI_T_source_get_info #endif int MPI_T_source_get_info (int source_id, char *name, int *name_len, char *desc, int *desc_len, MPI_T_source_order *ordering, diff --git a/ompi/mpi/tool/source_get_num.c b/ompi/mpi/tool/source_get_num.c index 0c2c879b96d..c4b456755da 100644 --- a/ompi/mpi/tool/source_get_num.c +++ b/ompi/mpi/tool/source_get_num.c @@ -12,17 +12,17 @@ * $HEADER$ */ +#include "ompi_config.h" + #include "ompi/mpi/tool/mpit-internal.h" -#if OPAL_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES +#if OMPI_BUILD_MPI_PROFILING +#if OPAL_HAVE_WEAK_SYMBOLS #pragma weak MPI_T_source_get_num = PMPI_T_source_get_num #endif - -#if OMPI_PROFILING_DEFINES -#include "ompi/mpi/tool/profile/defines.h" +#define MPI_T_source_get_num PMPI_T_source_get_num #endif - int MPI_T_source_get_num (int *num_source) { if (!mpit_is_initialized ()) { diff --git a/ompi/mpi/tool/source_get_timestamp.c b/ompi/mpi/tool/source_get_timestamp.c index d6b382e4a86..0bc7ba10f10 100644 --- a/ompi/mpi/tool/source_get_timestamp.c +++ b/ompi/mpi/tool/source_get_timestamp.c @@ -12,14 +12,15 @@ * $HEADER$ */ +#include "ompi_config.h" + #include "ompi/mpi/tool/mpit-internal.h" -#if OPAL_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES +#if OMPI_BUILD_MPI_PROFILING +#if OPAL_HAVE_WEAK_SYMBOLS #pragma weak MPI_T_source_get_timestamp = PMPI_T_source_get_timestamp #endif - -#if OMPI_PROFILING_DEFINES -#include "ompi/mpi/tool/profile/defines.h" +#define MPI_T_source_get_timestamp PMPI_T_source_get_timestamp #endif int MPI_T_source_get_timestamp (int source_id, MPI_Count *timestamp) From 9d323e07f23bd97766e0ebdfca81e748e93e5ab5 Mon Sep 17 00:00:00 2001 From: Howard Pritchard Date: Tue, 18 Jan 2022 13:01:04 -0700 Subject: [PATCH 10/23] pr review feedback Signed-off-by: Howard Pritchard --- ompi/mca/osc/rdma/osc_rdma_active_target.c | 12 +- ompi/mca/osc/rdma/osc_rdma_comm.c | 4 +- ompi/mca/osc/rdma/osc_rdma_passive_target.c | 16 +-- ompi/mca/pml/ob1/pml_ob1.c | 6 +- ompi/mca/pml/ob1/pml_ob1_irecv.c | 10 +- ompi/mca/pml/ob1/pml_ob1_isend.c | 6 +- ompi/mca/pml/ob1/pml_ob1_recvfrag.c | 41 +++--- ompi/mca/pml/ob1/pml_ob1_recvreq.c | 18 +-- ompi/mca/pml/ob1/pml_ob1_recvreq.h | 8 +- ompi/mca/pml/ob1/pml_ob1_sendreq.c | 12 +- ompi/mca/pml/ob1/pml_ob1_sendreq.h | 4 +- ompi/mpi/tool/event_get_info.c | 142 ++++++++++---------- ompi/mpi/tool/event_handle_alloc.c | 33 +++-- ompi/mpi/tool/event_handle_free.c | 17 +-- ompi/mpi/tool/event_register_callback.c | 1 - ompi/mpi/tool/source_get_info.c | 10 +- ompi/mpi/tool/source_get_timestamp.c | 2 +- opal/mca/base/Makefile.am | 1 - opal/mca/base/mca_base_event.c | 15 ++- opal/mca/base/mca_base_event.h | 8 +- opal/mca/base/mca_base_source.c | 19 ++- 21 files changed, 196 insertions(+), 189 deletions(-) diff --git a/ompi/mca/osc/rdma/osc_rdma_active_target.c b/ompi/mca/osc/rdma/osc_rdma_active_target.c index 10026b6abaf..564777593bd 100644 --- a/ompi/mca/osc/rdma/osc_rdma_active_target.c +++ b/ompi/mca/osc/rdma/osc_rdma_active_target.c @@ -182,7 +182,7 @@ static void ompi_osc_rdma_handle_post (ompi_osc_rdma_module_t *module, int rank, rank, (int) (npeers - state->num_post_msgs - 1)); /* an atomic is not really necessary as this function is currently used but it doesn't hurt */ ompi_osc_rdma_counter_add (&state->num_post_msgs, 1); - mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_PSCW_ACCESS_START].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, + MCA_BASE_EVENT_RAISE(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_PSCW_ACCESS_START].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, module->win, NULL, &rank); return; } @@ -309,7 +309,7 @@ int ompi_osc_rdma_post_atomic (ompi_group_t *group, int mpi_assert, ompi_win_t * return OMPI_SUCCESS; } - mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_PSCW_EXPOSE_START].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, + MCA_BASE_EVENT_RAISE(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_PSCW_EXPOSE_START].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, module->win, NULL, NULL); /* translate group ranks into the communicator */ @@ -399,7 +399,7 @@ int ompi_osc_rdma_start_atomic (ompi_group_t *group, int mpi_assert, ompi_win_t "from %d processes", peer->rank, (int) (group_size - state->num_post_msgs - 1)); opal_list_remove_item (&module->pending_posts, &pending_post->super); OBJ_RELEASE(pending_post); - mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_PSCW_ACCESS_START].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, + MCA_BASE_EVENT_RAISE(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_PSCW_ACCESS_START].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, module->win, NULL, &peer->rank); ompi_osc_rdma_counter_add (&state->num_post_msgs, 1); break; @@ -471,7 +471,7 @@ int ompi_osc_rdma_complete_atomic (ompi_win_t *win) ompi_osc_rdma_peer_t *peer = peers[i]; intptr_t target = (intptr_t) peer->state + offsetof (ompi_osc_rdma_state_t, num_complete_msgs); - mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_PSCW_ACCESS_COMPLETE].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, + MCA_BASE_EVENT_RAISE(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_PSCW_ACCESS_COMPLETE].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, module->win, NULL, &peer->rank); if (!ompi_osc_rdma_peer_local_state (peer)) { @@ -517,7 +517,7 @@ int ompi_osc_rdma_wait_atomic (ompi_win_t *win) opal_atomic_mb (); } - mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_PSCW_EXPOSE_COMPLETE].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, + MCA_BASE_EVENT_RAISE(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_PSCW_EXPOSE_COMPLETE].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, module->win, NULL, NULL); OPAL_THREAD_LOCK(&module->lock); @@ -569,7 +569,7 @@ int ompi_osc_rdma_test_atomic (ompi_win_t *win, int *flag) module->pw_group = NULL; OPAL_THREAD_UNLOCK(&(module->lock)); - mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_PSCW_EXPOSE_COMPLETE].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, + MCA_BASE_EVENT_RAISE(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_PSCW_EXPOSE_COMPLETE].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, module->win, NULL, NULL); OBJ_RELEASE(group); diff --git a/ompi/mca/osc/rdma/osc_rdma_comm.c b/ompi/mca/osc/rdma/osc_rdma_comm.c index c553ca86cb1..2ab3a2b1f46 100644 --- a/ompi/mca/osc/rdma/osc_rdma_comm.c +++ b/ompi/mca/osc/rdma/osc_rdma_comm.c @@ -460,7 +460,7 @@ static int ompi_osc_rdma_put_real (ompi_osc_rdma_sync_t *sync, ompi_osc_rdma_pee OSC_RDMA_VERBOSE(MCA_BASE_VERBOSE_TRACE, "initiating btl put of %lu bytes to remote address %" PRIx64 ", sync " "object %p...", (unsigned long) size, target_address, (void *) sync); - mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_PUT_STARTED].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, + MCA_BASE_EVENT_RAISE(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_PUT_STARTED].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, module->win, NULL, &((mca_osc_rdma_rdma_event_t){.target = peer->rank, .address = target_address, .size = size})); /* flag outstanding rma requests */ @@ -727,7 +727,7 @@ static int ompi_osc_rdma_get_contig (ompi_osc_rdma_sync_t *sync, ompi_osc_rdma_p ompi_osc_rdma_sync_rdma_inc (sync); } - mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_GET_STARTED].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, + MCA_BASE_EVENT_RAISE(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_GET_STARTED].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, module->win, NULL, &((mca_osc_rdma_rdma_event_t){.target = peer->rank, .address = source_address, .size = size})); do { diff --git a/ompi/mca/osc/rdma/osc_rdma_passive_target.c b/ompi/mca/osc/rdma/osc_rdma_passive_target.c index d88882a5fee..8676792c955 100644 --- a/ompi/mca/osc/rdma/osc_rdma_passive_target.c +++ b/ompi/mca/osc/rdma/osc_rdma_passive_target.c @@ -56,13 +56,13 @@ int ompi_osc_rdma_flush (int target, struct ompi_win_t *win) } OPAL_THREAD_UNLOCK(&module->lock); - mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_FLUSH_STARTED].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, + MCA_BASE_EVENT_RAISE(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_FLUSH_STARTED].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, module->win, NULL, &target); /* finish all outstanding fragments */ ompi_osc_rdma_sync_rdma_complete (lock); - mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_FLUSH_COMPLETE].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, + MCA_BASE_EVENT_RAISE(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_FLUSH_COMPLETE].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, module->win, NULL, &target); OSC_RDMA_VERBOSE(MCA_BASE_VERBOSE_TRACE, "flush on target %d complete", target); @@ -91,7 +91,7 @@ int ompi_osc_rdma_flush_all (struct ompi_win_t *win) ompi_osc_rdma_sync_rdma_complete (&module->all_sync); } - mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_FLUSH_STARTED].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, + MCA_BASE_EVENT_RAISE(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_FLUSH_STARTED].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, module->win, NULL, &(int) {-1}); /* flush all locks */ @@ -103,7 +103,7 @@ int ompi_osc_rdma_flush_all (struct ompi_win_t *win) node, &node); } - mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_FLUSH_COMPLETE].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, + MCA_BASE_EVENT_RAISE(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_FLUSH_COMPLETE].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, module->win, NULL, &(int) {-1}); OSC_RDMA_VERBOSE(MCA_BASE_VERBOSE_TRACE, "flush_all complete"); @@ -171,7 +171,7 @@ static inline int ompi_osc_rdma_lock_atomic_internal (ompi_osc_rdma_module_t *mo } while (1); } - mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_LOCK_ACQUIRED].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, + MCA_BASE_EVENT_RAISE(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_LOCK_ACQUIRED].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, module->win, NULL, &peer->rank); return OMPI_SUCCESS; @@ -198,7 +198,7 @@ static inline int ompi_osc_rdma_unlock_atomic_internal (ompi_osc_rdma_module_t * peer->flags &= ~OMPI_OSC_RDMA_PEER_DEMAND_LOCKED; } - mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_LOCK_RELEASED].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, + MCA_BASE_EVENT_RAISE(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_LOCK_RELEASED].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, module->win, NULL, &peer->rank); @@ -375,7 +375,7 @@ int ompi_osc_rdma_lock_all_atomic (int mpi_assert, struct ompi_win_t *win) offsetof(ompi_osc_rdma_state_t, global_lock), 0x00000000ffffffffUL); - mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_LOCK_ACQUIRED].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, + MCA_BASE_EVENT_RAISE(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_LOCK_ACQUIRED].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, module->win, NULL, &(int) {-1}); } else { /* always lock myself */ @@ -433,7 +433,7 @@ int ompi_osc_rdma_unlock_all_atomic (struct ompi_win_t *win) (void) ompi_osc_rdma_lock_release_shared (module, module->leader, -0x0000000100000000UL, offsetof (ompi_osc_rdma_state_t, global_lock)); - mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_LOCK_RELEASED].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, + MCA_BASE_EVENT_RAISE(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_LOCK_RELEASED].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, module->win, NULL, &(int) {-1}); } } diff --git a/ompi/mca/pml/ob1/pml_ob1.c b/ompi/mca/pml/ob1/pml_ob1.c index 5f02f2aa6ce..65ffb343e4e 100644 --- a/ompi/mca/pml/ob1/pml_ob1.c +++ b/ompi/mca/pml/ob1/pml_ob1.c @@ -305,7 +305,7 @@ int mca_pml_ob1_add_comm(ompi_communicator_t* comm) * figure out if the messages are not received in the correct * order (if multiple network interfaces). */ - mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_MESSAGE_ARRIVED].event, + MCA_BASE_EVENT_RAISE (mca_pml_ob1_events[MCA_PML_OB1_EVENT_MESSAGE_ARRIVED].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, comm, NULL, hdr); /* There is no matching to be done, and no lock to be held on the communicator as @@ -322,7 +322,7 @@ int mca_pml_ob1_add_comm(ompi_communicator_t* comm) #else custom_match_umq_append(pml_comm->umq, hdr->hdr_tag, hdr->hdr_src, frag); #endif - mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_UNEX_INSERT].event, + MCA_BASE_EVENT_RAISE (mca_pml_ob1_events[MCA_PML_OB1_EVENT_UNEX_INSERT].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, comm, NULL, hdr); continue; } @@ -337,7 +337,7 @@ int mca_pml_ob1_add_comm(ompi_communicator_t* comm) #else custom_match_umq_append(pml_comm->umq, hdr->hdr_tag, hdr->hdr_src, frag); #endif - mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_UNEX_INSERT].event, + MCA_BASE_EVENT_RAISE (mca_pml_ob1_events[MCA_PML_OB1_EVENT_UNEX_INSERT].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, comm, NULL, hdr); /* And now the ugly part. As some fragments can be inserted in the cant_match list, diff --git a/ompi/mca/pml/ob1/pml_ob1_irecv.c b/ompi/mca/pml/ob1/pml_ob1_irecv.c index 4f54c6a5f85..d3207bd40a8 100644 --- a/ompi/mca/pml/ob1/pml_ob1_irecv.c +++ b/ompi/mca/pml/ob1/pml_ob1_irecv.c @@ -60,7 +60,7 @@ int mca_pml_ob1_irecv_init(void *addr, addr, count, datatype, src, tag, comm, true); - mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_REQUEST_ACTIVATE].event, + MCA_BASE_EVENT_RAISE (mca_pml_ob1_events[MCA_PML_OB1_EVENT_REQUEST_ACTIVATE].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, comm, NULL, &recvreq); /* Work around a leak in start by marking this request as complete. The @@ -91,7 +91,7 @@ int mca_pml_ob1_irecv(void *addr, addr, count, datatype, src, tag, comm, false); - mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_REQUEST_ACTIVATE].event, + MCA_BASE_EVENT_RAISE (mca_pml_ob1_events[MCA_PML_OB1_EVENT_REQUEST_ACTIVATE].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, comm, NULL, &recvreq); MCA_PML_OB1_RECV_REQUEST_START(recvreq); @@ -126,7 +126,7 @@ int mca_pml_ob1_recv(void *addr, MCA_PML_OB1_RECV_REQUEST_INIT(recvreq, addr, count, datatype, src, tag, comm, false); - mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_REQUEST_ACTIVATE].event, + MCA_BASE_EVENT_RAISE (mca_pml_ob1_events[MCA_PML_OB1_EVENT_REQUEST_ACTIVATE].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, comm, NULL, &recvreq); MCA_PML_OB1_RECV_REQUEST_START(recvreq); @@ -218,7 +218,7 @@ mca_pml_ob1_imrecv( void *buf, src, tag, comm, false); OBJ_RELEASE(comm); - mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_REQUEST_ACTIVATE].event, + MCA_BASE_EVENT_RAISE (mca_pml_ob1_events[MCA_PML_OB1_EVENT_REQUEST_ACTIVATE].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, comm, NULL, &recvreq); /* init/re-init the request */ @@ -310,7 +310,7 @@ mca_pml_ob1_mrecv( void *buf, src, tag, comm, false); OBJ_RELEASE(comm); - mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_REQUEST_ACTIVATE].event, + MCA_BASE_EVENT_RAISE (mca_pml_ob1_events[MCA_PML_OB1_EVENT_REQUEST_ACTIVATE].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, comm, NULL, &recvreq); /* init/re-init the request */ diff --git a/ompi/mca/pml/ob1/pml_ob1_isend.c b/ompi/mca/pml/ob1/pml_ob1_isend.c index a3e8c65404d..42eefb9964b 100644 --- a/ompi/mca/pml/ob1/pml_ob1_isend.c +++ b/ompi/mca/pml/ob1/pml_ob1_isend.c @@ -61,7 +61,7 @@ int mca_pml_ob1_isend_init(const void *buf, MCA_PML_OB1_SEND_REQUEST_INIT(sendreq, buf, count, datatype, dst, tag, comm, sendmode, true, ob1_proc); - mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_REQUEST_ACTIVATE].event, + MCA_BASE_EVENT_RAISE (mca_pml_ob1_events[MCA_PML_OB1_EVENT_REQUEST_ACTIVATE].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, comm, NULL, &sendreq); /* Work around a leak in start by marking this request as complete. The @@ -206,7 +206,7 @@ int mca_pml_ob1_isend(const void *buf, dst, tag, comm, sendmode, false, ob1_proc); - mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_REQUEST_ACTIVATE].event, + MCA_BASE_EVENT_RAISE (mca_pml_ob1_events[MCA_PML_OB1_EVENT_REQUEST_ACTIVATE].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, comm, NULL, &sendreq); MCA_PML_OB1_SEND_REQUEST_START_W_SEQ(sendreq, endpoint, seqn, rc); @@ -316,7 +316,7 @@ int mca_pml_ob1_send(const void *buf, MCA_PML_OB1_SEND_REQUEST_INIT(sendreq, buf, count, datatype, dst, tag, comm, sendmode, false, ob1_proc); - mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_REQUEST_ACTIVATE].event, + MCA_BASE_EVENT_RAISE (mca_pml_ob1_events[MCA_PML_OB1_EVENT_REQUEST_ACTIVATE].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, comm, NULL, &sendreq); MCA_PML_OB1_SEND_REQUEST_START_W_SEQ(sendreq, endpoint, seqn, rc); diff --git a/ompi/mca/pml/ob1/pml_ob1_recvfrag.c b/ompi/mca/pml/ob1/pml_ob1_recvfrag.c index f8763f32f77..e68cb16ed3c 100644 --- a/ompi/mca/pml/ob1/pml_ob1_recvfrag.c +++ b/ompi/mca/pml/ob1/pml_ob1_recvfrag.c @@ -1,3 +1,4 @@ + /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana @@ -494,8 +495,8 @@ void mca_pml_ob1_recv_frag_callback_match (mca_btl_base_module_t *btl, * figure out if the messages are not received in the correct * order (if multiple network interfaces). */ - mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_MESSAGE_ARRIVED].event, - MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, comm_ptr, NULL, hdr); + MCA_BASE_EVENT_RAISE (mca_pml_ob1_events[MCA_PML_OB1_EVENT_MESSAGE_ARRIVED].event, + MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, comm_ptr, NULL, (void *)hdr); /* get next expected message sequence number - if threaded * run, lock to make sure that if another thread is processing @@ -541,8 +542,8 @@ void mca_pml_ob1_recv_frag_callback_match (mca_btl_base_module_t *btl, * received in the correct sequence. Otherwise, we delay the event * generation until we reach the correct sequence number. */ - mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_SEARCH_POSTED_BEGIN].event, - MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, comm_ptr, NULL, hdr); + MCA_BASE_EVENT_RAISE (mca_pml_ob1_events[MCA_PML_OB1_EVENT_SEARCH_POSTED_BEGIN].event, + MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, comm_ptr, NULL, (void *)hdr); match = match_one(btl, hdr, segments, num_segments, comm_ptr, proc, NULL); @@ -550,8 +551,8 @@ void mca_pml_ob1_recv_frag_callback_match (mca_btl_base_module_t *btl, * before going into check_cantmatch_for_match so we can make * a difference for the searching time for all messages. */ - mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_SEARCH_POSTED_END].event, - MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, comm_ptr, NULL, hdr); + MCA_BASE_EVENT_RAISE (mca_pml_ob1_events[MCA_PML_OB1_EVENT_SEARCH_POSTED_END].event, + MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, comm_ptr, NULL, (void *)hdr); /* release matching lock before processing fragment */ OB1_MATCHING_UNLOCK(&comm->matching_lock); @@ -897,9 +898,9 @@ static mca_pml_ob1_recv_request_t *match_incomming(const mca_pml_ob1_match_hdr_t req_tag = (*match)->req_recv.req_base.req_tag; if(req_tag == tag || (req_tag == OMPI_ANY_TAG && tag >= 0)) { opal_list_remove_item(queue, (opal_list_item_t*)(*match)); - mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_POSTED_REMOVE].event, + MCA_BASE_EVENT_RAISE (mca_pml_ob1_events[MCA_PML_OB1_EVENT_POSTED_REMOVE].event, MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, - (*match)->req_recv.req_base.req_comm, NULL, match); + (*match)->req_recv.req_base.req_comm, NULL, (void *)match); return *match; } @@ -926,9 +927,9 @@ static mca_pml_ob1_recv_request_t *match_incomming_no_any_source (const mca_pml_ if (req_tag == tag || (req_tag == OMPI_ANY_TAG && tag >= 0)) { opal_list_remove_item (&proc->specific_receives, (opal_list_item_t *) recv_req); - mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_POSTED_REMOVE].event, + MCA_BASE_EVENT_RAISE (mca_pml_ob1_events[MCA_PML_OB1_EVENT_POSTED_REMOVE].event, MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, - recv_req->req_recv.req_base.req_comm, NULL, &recv_req); + recv_req->req_recv.req_base.req_comm, NULL, (void *)&recv_req); return recv_req; } } @@ -994,9 +995,9 @@ static mca_pml_ob1_recv_request_t *match_one (mca_btl_base_module_t *btl, return NULL; } - mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_POSTED_REMOVE].event, + MCA_BASE_EVENT_RAISE (mca_pml_ob1_events[MCA_PML_OB1_EVENT_POSTED_REMOVE].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, - match->req_recv.req_base.req_comm, NULL, &match); + match->req_recv.req_base.req_comm, NULL, (void *)&match); SPC_TIMER_STOP(OMPI_SPC_MATCH_TIME, &timer); return match; } @@ -1013,8 +1014,8 @@ static mca_pml_ob1_recv_request_t *match_one (mca_btl_base_module_t *btl, SPC_RECORD(OMPI_SPC_UNEXPECTED_IN_QUEUE, 1); SPC_UPDATE_WATERMARK(OMPI_SPC_MAX_UNEXPECTED_IN_QUEUE, OMPI_SPC_UNEXPECTED_IN_QUEUE); - mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_UNEX_INSERT].event, - MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, comm, NULL, hdr); + MCA_BASE_EVENT_RAISE (mca_pml_ob1_events[MCA_PML_OB1_EVENT_UNEX_INSERT].event, + MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, comm, NULL, (void *)hdr); SPC_TIMER_STOP(OMPI_SPC_MATCH_TIME, &timer); return NULL; } while(true); @@ -1088,8 +1089,8 @@ static int mca_pml_ob1_recv_frag_match (mca_btl_base_module_t *btl, * figure out if the messages are not received in the correct * order (if multiple network interfaces). */ - mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_MESSAGE_ARRIVED].event, - MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, comm_ptr, NULL, hdr); + MCA_BASE_EVENT_RAISE (mca_pml_ob1_events[MCA_PML_OB1_EVENT_MESSAGE_ARRIVED].event, + MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, comm_ptr, NULL, (void *)hdr); /* get next expected message sequence number - if threaded * run, lock to make sure that if another thread is processing @@ -1184,8 +1185,8 @@ mca_pml_ob1_recv_frag_match_proc (mca_btl_base_module_t *btl, * received in the correct sequence. Otherwise, we delay the event * generation until we reach the correct sequence number. */ - mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_SEARCH_POSTED_BEGIN].event, - MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, comm_ptr, NULL, hdr); + MCA_BASE_EVENT_RAISE (mca_pml_ob1_events[MCA_PML_OB1_EVENT_SEARCH_POSTED_BEGIN].event, + MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, comm_ptr, NULL, (void *)hdr); match = match_one(btl, hdr, segments, num_segments, comm_ptr, proc, frag); @@ -1193,8 +1194,8 @@ mca_pml_ob1_recv_frag_match_proc (mca_btl_base_module_t *btl, * before going into check_cantmatch_for_match we can make a * difference for the searching time for all messages. */ - mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_SEARCH_POSTED_END].event, - MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, comm_ptr, NULL, hdr); + MCA_BASE_EVENT_RAISE (mca_pml_ob1_events[MCA_PML_OB1_EVENT_SEARCH_POSTED_END].event, + MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, comm_ptr, NULL, (void *)hdr); /* release matching lock before processing fragment */ OB1_MATCHING_UNLOCK(&comm->matching_lock); diff --git a/ompi/mca/pml/ob1/pml_ob1_recvreq.c b/ompi/mca/pml/ob1/pml_ob1_recvreq.c index a71045cebfb..a028ad59a5f 100644 --- a/ompi/mca/pml/ob1/pml_ob1_recvreq.c +++ b/ompi/mca/pml/ob1/pml_ob1_recvreq.c @@ -74,7 +74,7 @@ static int mca_pml_ob1_recv_request_free(struct ompi_request_t** request) assert (false == recvreq->req_recv.req_base.req_free_called); recvreq->req_recv.req_base.req_free_called = true; - mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_REQUEST_FREE].event, + MCA_BASE_EVENT_RAISE (mca_pml_ob1_events[MCA_PML_OB1_EVENT_REQUEST_FREE].event, MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, recvreq->req_recv.req_base.req_comm, NULL, &recvreq); @@ -151,7 +151,7 @@ static int mca_pml_ob1_recv_request_cancel(struct ompi_request_t* ompi_request, } void *req = &(request->req_recv.req_base); - mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_RECEIVE_CANCELED].event, + MCA_BASE_EVENT_RAISE (mca_pml_ob1_events[MCA_PML_OB1_EVENT_RECEIVE_CANCELED].event, MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, comm, NULL, &req); /** * As now the PML is done with this request we have to force the pml_complete @@ -494,7 +494,7 @@ static int mca_pml_ob1_recv_request_put_frag (mca_pml_ob1_rdma_frag_t *frag) recvreq->req_ack_sent = true; - mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_TRANSFER].event, + MCA_BASE_EVENT_RAISE (mca_pml_ob1_events[MCA_PML_OB1_EVENT_TRANSFER].event, MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, comm, NULL, &((mca_pml_ob1_transfer_event_t) {.request = recvreq, .length = frag->rdma_length})); @@ -536,7 +536,7 @@ int mca_pml_ob1_recv_request_get_frag (mca_pml_ob1_rdma_frag_t *frag) local_handle = recvreq->local_handle; } - mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_TRANSFER].event, + MCA_BASE_EVENT_RAISE (mca_pml_ob1_events[MCA_PML_OB1_EVENT_TRANSFER].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, recvreq->req_recv.req_base.req_comm, NULL, &((mca_pml_ob1_transfer_event_t){.request = frag->rdma_req, .length = frag->rdma_length})); @@ -1126,7 +1126,7 @@ static inline void append_recv_req_to_queue(opal_list_t *queue, if (req->req_recv.req_base.req_type != MCA_PML_REQUEST_PROBE && req->req_recv.req_base.req_type != MCA_PML_REQUEST_MPROBE) { ompi_communicator_t *comm = req->req_recv.req_base.req_comm; - mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_POSTED_INSERT].event, + MCA_BASE_EVENT_RAISE (mca_pml_ob1_events[MCA_PML_OB1_EVENT_POSTED_INSERT].event, MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, comm, NULL, &req); } } @@ -1291,7 +1291,7 @@ void mca_pml_ob1_recv_req_start(mca_pml_ob1_recv_request_t *req) * The laps of time between the ACTIVATE event and the SEARCH_UNEX one include * the cost of the request lock. */ - mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_SEARCH_UNEX_BEGIN].event, + MCA_BASE_EVENT_RAISE (mca_pml_ob1_events[MCA_PML_OB1_EVENT_SEARCH_UNEX_BEGIN].event, MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, comm, NULL, &req); /* assign sequence number */ @@ -1351,7 +1351,7 @@ void mca_pml_ob1_recv_req_start(mca_pml_ob1_recv_request_t *req) } if(OPAL_UNLIKELY(NULL == frag)) { - mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_SEARCH_UNEX_END].event, + MCA_BASE_EVENT_RAISE (mca_pml_ob1_events[MCA_PML_OB1_EVENT_SEARCH_UNEX_END].event, MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, comm, NULL, &req); /* We didn't find any matches. Record this irecv so we can match it when the message comes in. */ @@ -1370,10 +1370,10 @@ void mca_pml_ob1_recv_req_start(mca_pml_ob1_recv_request_t *req) if(OPAL_LIKELY(!IS_PROB_REQ(req))) { hdr = (mca_pml_ob1_hdr_t*)frag->segments->seg_addr.pval; - mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_UNEX_REMOVE].event, + MCA_BASE_EVENT_RAISE (mca_pml_ob1_events[MCA_PML_OB1_EVENT_UNEX_REMOVE].event, MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, comm, NULL, &hdr->hdr_match); - mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_SEARCH_UNEX_END].event, + MCA_BASE_EVENT_RAISE (mca_pml_ob1_events[MCA_PML_OB1_EVENT_SEARCH_UNEX_END].event, MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, comm, NULL, &req); #if MCA_PML_OB1_CUSTOM_MATCH diff --git a/ompi/mca/pml/ob1/pml_ob1_recvreq.h b/ompi/mca/pml/ob1/pml_ob1_recvreq.h index 18362bc44f8..e2e6389ff89 100644 --- a/ompi/mca/pml/ob1/pml_ob1_recvreq.h +++ b/ompi/mca/pml/ob1/pml_ob1_recvreq.h @@ -124,7 +124,7 @@ do { \ */ #define MCA_PML_OB1_RECV_REQUEST_MPI_COMPLETE( recvreq ) \ do { \ - mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_REQUEST_COMPLETE].event, \ + MCA_BASE_EVENT_RAISE (mca_pml_ob1_events[MCA_PML_OB1_EVENT_REQUEST_COMPLETE].event, \ MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, \ (recvreq)->req_recv.req_base.req_comm, NULL, &(recvreq)); \ ompi_request_complete( &(recvreq->req_recv.req_base.req_ompi), true ); \ @@ -163,7 +163,7 @@ recv_request_pml_complete(mca_pml_ob1_recv_request_t *recvreq) if(false == recvreq->req_recv.req_base.req_pml_complete){ if(recvreq->req_recv.req_bytes_packed > 0) { - mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_TRANSFER_END].event, + MCA_BASE_EVENT_RAISE (mca_pml_ob1_events[MCA_PML_OB1_EVENT_TRANSFER_END].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, recvreq->req_recv.req_base.req_comm, NULL, &recvreq); } @@ -260,7 +260,7 @@ static inline void recv_req_matched(mca_pml_ob1_recv_request_t *req, prepare_recv_req_converter(req); } #endif /* OPAL_ENABLE_HETEROGENEOUS_SUPPORT */ - mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_TRANSFER_BEGIN].event, + MCA_BASE_EVENT_RAISE (mca_pml_ob1_events[MCA_PML_OB1_EVENT_TRANSFER_BEGIN].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, req->req_recv.req_base.req_comm, NULL, &req); } @@ -300,7 +300,7 @@ do { } \ OPAL_THREAD_LOCK(&(req)->lock); \ \ - mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_TRANSFER].event, \ + MCA_BASE_EVENT_RAISE (mca_pml_ob1_events[MCA_PML_OB1_EVENT_TRANSFER].event, \ MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, \ (req)->req_recv.req_base.req_comm, NULL, \ &((mca_pml_ob1_transfer_event_t){.request = req, .length = max_data})); \ diff --git a/ompi/mca/pml/ob1/pml_ob1_sendreq.c b/ompi/mca/pml/ob1/pml_ob1_sendreq.c index c3598925683..5691ef6fc4b 100644 --- a/ompi/mca/pml/ob1/pml_ob1_sendreq.c +++ b/ompi/mca/pml/ob1/pml_ob1_sendreq.c @@ -107,7 +107,7 @@ static int mca_pml_ob1_send_request_free(struct ompi_request_t** request) if(false == sendreq->req_send.req_base.req_free_called) { sendreq->req_send.req_base.req_free_called = true; - mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_REQUEST_FREE].event, + MCA_BASE_EVENT_RAISE (mca_pml_ob1_events[MCA_PML_OB1_EVENT_REQUEST_FREE].event, MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, sendreq->req_send.req_base.req_comm, NULL, &sendreq); @@ -210,7 +210,7 @@ mca_pml_ob1_match_completion_free_request( mca_bml_base_btl_t* bml_btl, { if( sendreq->req_send.req_bytes_packed > 0 ) { void *req = &(sendreq->req_send.req_base); - mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_TRANSFER_BEGIN].event, + MCA_BASE_EVENT_RAISE (mca_pml_ob1_events[MCA_PML_OB1_EVENT_TRANSFER_BEGIN].event, MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, sendreq->req_send.req_base.req_comm, NULL, &req); } @@ -257,7 +257,7 @@ mca_pml_ob1_rndv_completion_request( mca_bml_base_btl_t* bml_btl, { if( sendreq->req_send.req_bytes_packed > 0 ) { void *req = &(sendreq->req_send.req_base); - mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_TRANSFER_BEGIN].event, + MCA_BASE_EVENT_RAISE (mca_pml_ob1_events[MCA_PML_OB1_EVENT_TRANSFER_BEGIN].event, MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, sendreq->req_send.req_base.req_comm, NULL, &req); } @@ -914,7 +914,7 @@ int mca_pml_ob1_send_request_start_rdma( mca_pml_ob1_send_request_t* sendreq, */ if( sendreq->req_send.req_bytes_packed > 0 ) { void *req = &(sendreq->req_send.req_base); - mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_TRANSFER_BEGIN].event, + MCA_BASE_EVENT_RAISE (mca_pml_ob1_events[MCA_PML_OB1_EVENT_TRANSFER_BEGIN].event, MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, sendreq->req_send.req_base.req_comm, NULL, &req); } @@ -1224,7 +1224,7 @@ mca_pml_ob1_send_request_schedule_once(mca_pml_ob1_send_request_t* sendreq) sendreq->req_send.req_base.req_proc); void *req = &(sendreq->req_send.req_base); - mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_TRANSFER].event, + MCA_BASE_EVENT_RAISE (mca_pml_ob1_events[MCA_PML_OB1_EVENT_TRANSFER].event, MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, sendreq->req_send.req_base.req_comm, NULL, &req); @@ -1384,7 +1384,7 @@ int mca_pml_ob1_send_request_put_frag( mca_pml_ob1_rdma_frag_t *frag ) } void *req = &(((mca_pml_ob1_send_request_t*)frag->rdma_req)->req_send.req_base); - mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_TRANSFER].event, + MCA_BASE_EVENT_RAISE (mca_pml_ob1_events[MCA_PML_OB1_EVENT_TRANSFER].event, MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, sendreq->req_send.req_base.req_comm, NULL, &req); diff --git a/ompi/mca/pml/ob1/pml_ob1_sendreq.h b/ompi/mca/pml/ob1/pml_ob1_sendreq.h index df6bb23ad57..34f1be96f18 100644 --- a/ompi/mca/pml/ob1/pml_ob1_sendreq.h +++ b/ompi/mca/pml/ob1/pml_ob1_sendreq.h @@ -211,7 +211,7 @@ do { (sendreq)->req_send.req_base.req_tag; \ (sendreq)->req_send.req_base.req_ompi.req_status._ucount = \ (sendreq)->req_send.req_bytes_packed; \ - mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_REQUEST_COMPLETE].event, \ + MCA_BASE_EVENT_RAISE (mca_pml_ob1_events[MCA_PML_OB1_EVENT_REQUEST_COMPLETE].event, \ MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, \ (sendreq)->req_send.req_base.req_comm, NULL, &(sendreq)); \ \ @@ -261,7 +261,7 @@ send_request_pml_complete(mca_pml_ob1_send_request_t *sendreq) { if(false == sendreq->req_send.req_base.req_pml_complete) { if(sendreq->req_send.req_bytes_packed > 0) { - mca_base_event_raise (mca_pml_ob1_events[MCA_PML_OB1_EVENT_TRANSFER_END].event, + MCA_BASE_EVENT_RAISE (mca_pml_ob1_events[MCA_PML_OB1_EVENT_TRANSFER_END].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, sendreq->req_send.req_base.req_comm, NULL, &sendreq); } diff --git a/ompi/mpi/tool/event_get_info.c b/ompi/mpi/tool/event_get_info.c index fc5636ce660..9fb301ba733 100644 --- a/ompi/mpi/tool/event_get_info.c +++ b/ompi/mpi/tool/event_get_info.c @@ -42,95 +42,95 @@ int MPI_T_event_get_info (int event_index, char *name, int *name_len, ompi_mpit_lock (); - do { - /* Find the performance variable. mca_base_event_get() handles the - bounds checking. */ - ret = mca_base_event_get_by_index (event_index, (mca_base_event_t **) &event); - if (OMPI_SUCCESS != ret) { - break; - } + /* Find the performance variable. mca_base_event_get() handles the + bounds checking. */ + ret = mca_base_event_get_by_index (event_index, (mca_base_event_t **) &event); + if (OMPI_SUCCESS != ret) { + goto fn_fail; + } - /* Check the variable binding is something sane */ - if (event->event_bind > MPI_T_BIND_MPI_INFO || event->event_bind < MPI_T_BIND_NO_OBJECT) { - /* This variable specified an invalid binding (not an MPI object). */ - ret = MPI_T_ERR_INVALID_INDEX; - break; - } + /* Check the variable binding is something sane */ + if (event->event_bind > MPI_T_BIND_MPI_INFO || event->event_bind < MPI_T_BIND_NO_OBJECT) { + /* This variable specified an invalid binding (not an MPI object). */ + ret = MPI_T_ERR_INVALID_INDEX; + goto fn_fail; + } - /* Copy name and description */ - mpit_copy_string (name, name_len, event->event_name); - mpit_copy_string (desc, desc_len, event->event_description); - - // num_elements is INOUT - // - // Can query number of datatypes, returned in num_elements - // if array_of_datatypes or displacements are NULL, just return data_type_count. - // Otherwise, if array_of_datatypes or displacements are not NULL, use num_elements - // as maximum datatypes or displacements returned. - // - // Unless the user passes the NULL pointer for num_elements, - // the function returns the number of elements required for this event type. - // - // If the number of elements used by the event type is larger than the value of num_elements - // provided by the user, the number of datatype handles and displacements returned in the - // corresponding arrays is truncated to the value of num_elements passed in by the user. - - max_datatypes = 0; - if (num_elements) { - if (NULL != array_of_datatypes || NULL != array_of_displacements) { - if (*num_elements < (int) (event->event_datatype_count)) - max_datatypes = *num_elements; - else - max_datatypes = event->event_datatype_count; + /* Copy name and description */ + mpit_copy_string (name, name_len, event->event_name); + mpit_copy_string (desc, desc_len, event->event_description); + + // num_elements is INOUT + // + // Can query number of datatypes, returned in num_elements + // if array_of_datatypes or displacements are NULL, just return data_type_count. + // Otherwise, if array_of_datatypes or displacements are not NULL, use num_elements + // as maximum datatypes or displacements returned. + // + // Unless the user passes the NULL pointer for num_elements, + // the function returns the number of elements required for this event type. + // + // If the number of elements used by the event type is larger than the value of num_elements + // provided by the user, the number of datatype handles and displacements returned in the + // corresponding arrays is truncated to the value of num_elements passed in by the user. + + max_datatypes = 0; + if (num_elements) { + if (NULL != array_of_datatypes || NULL != array_of_displacements) { + if (*num_elements < (int) (event->event_datatype_count)) { + max_datatypes = *num_elements; + } else { + max_datatypes = event->event_datatype_count; } - *num_elements = event->event_datatype_count; } + *num_elements = event->event_datatype_count; + } - if (max_datatypes) { - if (array_of_datatypes) { - for (int i = 0 ; i < max_datatypes ; i++) { - ompi_datatype_t *ompi_datatype = NULL; + if (max_datatypes) { + if (array_of_datatypes) { + for (int i = 0 ; i < max_datatypes ; i++) { + ompi_datatype_t *ompi_datatype = NULL; - for (int j = 0 ; j < OMPI_DATATYPE_MPI_MAX_PREDEFINED ; ++j) { - if (ompi_datatype_basicDatatypes[j]->super.id == event->event_datatypes[i]->id) { - ompi_datatype = (ompi_datatype_t *) ompi_datatype_basicDatatypes[j]; - break; - } + for (int j = 0 ; j < OMPI_DATATYPE_MPI_MAX_PREDEFINED ; ++j) { + if (ompi_datatype_basicDatatypes[j]->super.id == event->event_datatypes[i]->id) { + ompi_datatype = (ompi_datatype_t *) ompi_datatype_basicDatatypes[j]; + break; } + } - assert (NULL != ompi_datatype); + assert (NULL != ompi_datatype); - array_of_datatypes[i] = ompi_datatype; - } + array_of_datatypes[i] = ompi_datatype; } + } - if (array_of_displacements) { - for (int i = 0 ; i < max_datatypes ; i++) { - array_of_displacements[i] = (MPI_Aint) current_displacement; - current_displacement += event->event_datatypes[i]->size; - } + if (array_of_displacements) { + for (int i = 0 ; i < max_datatypes ; i++) { + array_of_displacements[i] = (MPI_Aint) current_displacement; + current_displacement += event->event_datatypes[i]->size; } - - *num_elements = max_datatypes; } - if (NULL != verbosity) { - *verbosity = event->event_verbosity; - } + *num_elements = max_datatypes; + } - if (NULL != enumtype) { - *enumtype = event->event_enumerator ? (MPI_T_enum) event->event_enumerator : MPI_T_ENUM_NULL; - } + if (NULL != verbosity) { + *verbosity = event->event_verbosity; + } - if (NULL != bind) { - *bind = event->event_bind; - } + if (NULL != enumtype) { + *enumtype = event->event_enumerator ? (MPI_T_enum) event->event_enumerator : MPI_T_ENUM_NULL; + } - if (NULL != info) { - *info = OBJ_NEW(ompi_info_t); - } - } while (0); + if (NULL != bind) { + *bind = event->event_bind; + } + + if (NULL != info) { + *info = OBJ_NEW(ompi_info_t); + } +fn_fail: ompi_mpit_unlock (); return ret; diff --git a/ompi/mpi/tool/event_handle_alloc.c b/ompi/mpi/tool/event_handle_alloc.c index c0dfb8d0401..b21633431f1 100644 --- a/ompi/mpi/tool/event_handle_alloc.c +++ b/ompi/mpi/tool/event_handle_alloc.c @@ -36,24 +36,23 @@ int MPI_T_event_handle_alloc (int event_index, void *obj_handle, MPI_Info info, ompi_mpit_lock (); - do { - /* Find the performance variable. mca_base_event_get() handles the - bounds checking. */ - ret = mca_base_event_get_by_index (event_index, (mca_base_event_t **) &event); - if (OMPI_SUCCESS != ret) { - break; - } - - /* Check the variable binding is something sane */ - if (event->event_bind > MPI_T_BIND_MPI_INFO || event->event_bind < MPI_T_BIND_NO_OBJECT) { - /* This variable specified an invalid binding (not an MPI object). */ - ret = MPI_T_ERR_INVALID_INDEX; - break; - } - - ret = mca_base_event_registration_alloc (event, obj_handle, &info->super, event_registration); - } while (0); + /* Find the performance variable. mca_base_event_get() handles the + bounds checking. */ + ret = mca_base_event_get_by_index (event_index, (mca_base_event_t **) &event); + if (OMPI_SUCCESS != ret) { + goto fn_fail; + } + + /* Check the variable binding is something sane */ + if (event->event_bind > MPI_T_BIND_MPI_INFO || event->event_bind < MPI_T_BIND_NO_OBJECT) { + /* This variable specified an invalid binding (not an MPI object). */ + ret = MPI_T_ERR_INVALID_INDEX; + goto fn_fail; + } + + ret = mca_base_event_registration_alloc (event, obj_handle, &info->super, event_registration); +fn_fail: ompi_mpit_unlock (); return ompit_opal_to_mpit_error(ret); diff --git a/ompi/mpi/tool/event_handle_free.c b/ompi/mpi/tool/event_handle_free.c index 43ffb4991fa..fcd6c620463 100644 --- a/ompi/mpi/tool/event_handle_free.c +++ b/ompi/mpi/tool/event_handle_free.c @@ -36,16 +36,13 @@ int MPI_T_event_handle_free (MPI_T_event_registration event_registration, ompi_mpit_lock (); - do { - /* Check that this is a valid handle */ - if (MPI_T_EVENT_REGISTRATION_NULL == event_registration) { - ret = MPI_T_ERR_INVALID_HANDLE; - break; - } - - mca_base_event_registration_free (event_registration, (mca_base_event_registration_free_cb_fn_t) free_cb_function); - /* *event_registration = MPI_T_EVENT_REGISTRATION_NULL; */ - } while (0); + /* Check that this is a valid handle */ + if (MPI_T_EVENT_REGISTRATION_NULL == event_registration) { + ret = MPI_T_ERR_INVALID_HANDLE; + } else { + mca_base_event_registration_free (event_registration, + (mca_base_event_registration_free_cb_fn_t) free_cb_function); + } ompi_mpit_unlock (); diff --git a/ompi/mpi/tool/event_register_callback.c b/ompi/mpi/tool/event_register_callback.c index 5175c8d8a62..399ab119b25 100644 --- a/ompi/mpi/tool/event_register_callback.c +++ b/ompi/mpi/tool/event_register_callback.c @@ -28,7 +28,6 @@ int MPI_T_event_register_callback (MPI_T_event_registration event_registration, MPI_T_cb_safety cb_safety, MPI_Info info, void *user_data, MPI_T_event_cb_function event_cb_function) { - mca_base_event_t * const event; int ret; if (!mpit_is_initialized ()) { diff --git a/ompi/mpi/tool/source_get_info.c b/ompi/mpi/tool/source_get_info.c index b1257e8ae9d..b6057d9668f 100644 --- a/ompi/mpi/tool/source_get_info.c +++ b/ompi/mpi/tool/source_get_info.c @@ -38,16 +38,18 @@ int MPI_T_source_get_info (int source_id, char *name, int *name_len, char *desc, return MPI_T_ERR_INVALID_INDEX; } - if (NULL == name && name_len) - *name_len = strlen(source->source_name); + if (NULL == name && name_len) { + *name_len = strlen(source->source_name); + } if (name && name_len) { strncpy (name, source->source_name, *name_len); *name_len = strlen (name); } - if (NULL == desc && desc_len) - *desc_len = strlen(source->source_description); + if (NULL == desc && desc_len) { + *desc_len = strlen(source->source_description); + } if (desc && desc_len) { strncpy (desc, source->source_description, *desc_len); diff --git a/ompi/mpi/tool/source_get_timestamp.c b/ompi/mpi/tool/source_get_timestamp.c index 0bc7ba10f10..4347a93ce00 100644 --- a/ompi/mpi/tool/source_get_timestamp.c +++ b/ompi/mpi/tool/source_get_timestamp.c @@ -41,7 +41,7 @@ int MPI_T_source_get_timestamp (int source_id, MPI_Count *timestamp) return MPI_T_ERR_INVALID_INDEX; } - *timestamp = source->source_time (); + *timestamp = (MPI_Count)source->source_time (); return MPI_SUCCESS; } diff --git a/opal/mca/base/Makefile.am b/opal/mca/base/Makefile.am index 5f177a27a8b..903b9fd6716 100644 --- a/opal/mca/base/Makefile.am +++ b/opal/mca/base/Makefile.am @@ -45,7 +45,6 @@ headers = \ mca_base_event.h \ mca_base_source.h - # Library libmca_base_la_SOURCES = \ diff --git a/opal/mca/base/mca_base_event.c b/opal/mca/base/mca_base_event.c index ee176734f85..02907972018 100644 --- a/opal/mca/base/mca_base_event.c +++ b/opal/mca/base/mca_base_event.c @@ -32,9 +32,7 @@ static opal_hash_table_t mca_base_event_index_hash; static opal_pointer_array_t registered_events; static bool mca_base_event_initialized = false; static int event_count = 0; - -#define min(a,b) ((a) < (b) ? (a) : (b)) -#define max(a,b) ((a) > (b) ? (a) : (b)) +static opal_mutex_t mca_base_event_lock = OPAL_MUTEX_STATIC_INIT; static int mca_base_event_get_by_index_internal (int index, mca_base_event_t **event, bool invalidok); static int mca_base_event_get_by_fullname_internal (const char *full_name, mca_base_event_t **event, bool invalidok); @@ -47,7 +45,8 @@ int mca_base_event_init (void) { int ret = OPAL_SUCCESS; - if (!mca_base_event_initialized) { + OPAL_THREAD_LOCK(&mca_base_event_lock); + if (false == mca_base_event_initialized) { mca_base_event_initialized = true; OBJ_CONSTRUCT(®istered_events, opal_pointer_array_t); @@ -61,6 +60,7 @@ int mca_base_event_init (void) OBJ_DESTRUCT(&mca_base_event_index_hash); } } + OPAL_THREAD_UNLOCK(&mca_base_event_lock); return ret; } @@ -69,7 +69,8 @@ int mca_base_event_finalize (void) { int i; - if (mca_base_event_initialized) { + OPAL_THREAD_LOCK(&mca_base_event_lock); + if (true == mca_base_event_initialized) { mca_base_event_initialized = false; for (i = 0 ; i < event_count ; ++i) { @@ -84,6 +85,7 @@ int mca_base_event_finalize (void) OBJ_DESTRUCT(®istered_events); OBJ_DESTRUCT(&mca_base_event_index_hash); } + OPAL_THREAD_UNLOCK(&mca_base_event_lock); return OPAL_SUCCESS; } @@ -192,7 +194,6 @@ int mca_base_event_register (const char *project, const char *framework, const c /* update this assert if more MPIT verbosity levels are added */ assert (verbosity >= OPAL_INFO_LVL_1 && verbosity <= OPAL_INFO_LVL_9); - flags &= ~MCA_BASE_EVENT_FLAG_INVALID; /* check if this variable is already registered */ @@ -513,7 +514,7 @@ int mca_base_event_dump(int index, char ***out, mca_base_var_dump_type_t output_ return OPAL_SUCCESS; } -void mca_base_event_raise_internal (mca_base_event_t *event, mca_base_cb_safety_t cb_safety, void *obj, mca_base_source_t *source, void *data) +void MCA_BASE_EVENT_RAISE_internal (mca_base_event_t *event, mca_base_cb_safety_t cb_safety, void *obj, mca_base_source_t *source, void *data) { mca_base_raised_event_t revent = {.re_timestamp = source ? source->source_time () : event->event_source->source_time (), .re_source = source ? source->source_index : event->event_source->source_index, diff --git a/opal/mca/base/mca_base_event.h b/opal/mca/base/mca_base_event.h index 8003c8a1f71..4d00d415136 100644 --- a/opal/mca/base/mca_base_event.h +++ b/opal/mca/base/mca_base_event.h @@ -99,7 +99,7 @@ typedef struct mca_base_event_t { /** Enumerator for integer values */ mca_base_var_enum_t *event_enumerator; - /** Type of object to which this variable must be bound or MCA_BASE_VAR_BIND_NULL */ + /** Type of object to which this variable must be bound or MCA_BASE_VAR_BIND_NO_OBJECT */ int event_bind; /** event source (may be NULL) */ @@ -182,14 +182,14 @@ OPAL_DECLSPEC int mca_base_component_event_register (const mca_base_component_t OPAL_DECLSPEC int mca_base_component_event_register_list (const mca_base_component_t *component, mca_base_event_list_item_t *list, int count); -OPAL_DECLSPEC void mca_base_event_raise_internal (mca_base_event_t *event, mca_base_cb_safety_t cb_safety, void *obj, mca_base_source_t *source, +OPAL_DECLSPEC void MCA_BASE_EVENT_RAISE_internal (mca_base_event_t *event, mca_base_cb_safety_t cb_safety, void *obj, mca_base_source_t *source, void *data); -#define mca_base_event_raise(eventp, cb_safety, obj, source, data) \ +#define MCA_BASE_EVENT_RAISE(eventp, cb_safety, obj, source, data) \ do { \ if (OPAL_UNLIKELY(0 != opal_list_get_size (&(eventp)->event_bound_registrations))) { \ /* at least one registration is bound to this event. raise the event with the user code */ \ - mca_base_event_raise_internal (eventp, cb_safety, obj, source, data); \ + MCA_BASE_EVENT_RAISE_internal (eventp, cb_safety, obj, source, data); \ } \ } while (0); diff --git a/opal/mca/base/mca_base_source.c b/opal/mca/base/mca_base_source.c index ca5b2831403..61c093b5465 100644 --- a/opal/mca/base/mca_base_source.c +++ b/opal/mca/base/mca_base_source.c @@ -26,9 +26,11 @@ #include "opal/class/opal_hash_table.h" static opal_pointer_array_t registered_sources; -static int mca_base_source_initialized; +static bool mca_base_source_initialized = false; static int source_count; +static opal_mutex_t mca_base_source_lock = OPAL_MUTEX_STATIC_INIT; + int mca_base_source_default_source = -1; static uint64_t mca_base_source_default_time_source (void) @@ -65,7 +67,8 @@ int mca_base_source_init (void) { int ret = OPAL_SUCCESS; - if (!mca_base_source_initialized++) { + OPAL_THREAD_LOCK(&mca_base_source_lock); + if (false == mca_base_source_initialized) { mca_base_source_initialized = true; OBJ_CONSTRUCT(®istered_sources, opal_pointer_array_t); @@ -77,6 +80,7 @@ int mca_base_source_init (void) mca_base_source_default_time_source_ticks ()); } + OPAL_THREAD_UNLOCK(&mca_base_source_lock); return ret; } @@ -85,7 +89,8 @@ int mca_base_source_finalize (void) { int i; - if (0 == --mca_base_source_initialized) { + OPAL_THREAD_LOCK(&mca_base_source_lock); + if (true == mca_base_source_initialized) { for (i = 0 ; i < source_count ; ++i) { mca_base_source_t *source = opal_pointer_array_get_item (®istered_sources, i); if (source) { @@ -96,7 +101,9 @@ int mca_base_source_finalize (void) source_count = 0; OBJ_DESTRUCT(®istered_sources); + mca_base_source_initialized = false; } + OPAL_THREAD_UNLOCK(&mca_base_source_lock); return OPAL_SUCCESS; } @@ -224,7 +231,7 @@ int mca_base_component_source_register (const mca_base_component_t *component, c } /* mca_base_source_t class */ -static void mca_base_source_contructor (mca_base_source_t *source) +static void mca_base_source_constructor (mca_base_source_t *source) { memset ((char *) source + sizeof (source->super), 0, sizeof (*source) - sizeof (source->super)); } @@ -232,7 +239,9 @@ static void mca_base_source_contructor (mca_base_source_t *source) static void mca_base_source_destructor (mca_base_source_t *source) { free (source->source_name); + source->source_name = NULL; free (source->source_description); + source->source_description = NULL; } -OBJ_CLASS_INSTANCE(mca_base_source_t, opal_object_t, mca_base_source_contructor, mca_base_source_destructor); +OBJ_CLASS_INSTANCE(mca_base_source_t, opal_object_t, mca_base_source_constructor, mca_base_source_destructor); From 050f06cc1edf30b5760829c83460cd4d968925ba Mon Sep 17 00:00:00 2001 From: Howard Pritchard Date: Tue, 18 Jan 2022 16:11:58 -0700 Subject: [PATCH 11/23] pr feedback - switch to opal_clock_gettime Signed-off-by: Howard Pritchard --- opal/mca/base/mca_base_source.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/opal/mca/base/mca_base_source.c b/opal/mca/base/mca_base_source.c index 61c093b5465..250e851928d 100644 --- a/opal/mca/base/mca_base_source.c +++ b/opal/mca/base/mca_base_source.c @@ -24,6 +24,7 @@ #include "opal/class/opal_pointer_array.h" #include "opal/class/opal_hash_table.h" +#include "opal/util/clock_gettime.h" static opal_pointer_array_t registered_sources; static bool mca_base_source_initialized = false; @@ -36,29 +37,23 @@ int mca_base_source_default_source = -1; static uint64_t mca_base_source_default_time_source (void) { uint64_t time_value; - -#if OPAL_HAVE_CLOCK_GETTIME struct timespec current; - clock_gettime (CLOCK_MONOTONIC, ¤t); + (void)opal_clock_gettime(¤t); time_value = 1000000000ul * current.tv_sec + current.tv_nsec; -#else - struct timeval current; - - gettimeofday (¤t, NULL); - time_value = 1000000ul * current.tv_sec + current.tv_usec; -#endif return time_value; } static uint64_t mca_base_source_default_time_source_ticks (void) { -#if OPAL_HAVE_CLOCK_GETTIME - return 1000000000; -#else - return 1000000; -#endif + struct timespec spec; + if (0 == opal_clock_getres(&spec)){ + return (uint64_t)(spec.tv_sec + spec.tv_nsec); + } else { + /* guess */ + return 1000000; + } } /***************************************************************************************************/ From 8b683d40cfd5fc4bb382ebc36bc9f901d00f8ab5 Mon Sep 17 00:00:00 2001 From: Howard Pritchard Date: Tue, 18 Jan 2022 16:24:13 -0700 Subject: [PATCH 12/23] suppress a compiler warning by fixing some code Signed-off-by: Howard Pritchard --- opal/mca/base/mca_base_event.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/opal/mca/base/mca_base_event.c b/opal/mca/base/mca_base_event.c index 02907972018..e7d7dd4d236 100644 --- a/opal/mca/base/mca_base_event.c +++ b/opal/mca/base/mca_base_event.c @@ -189,7 +189,7 @@ int mca_base_event_register (const char *project, const char *framework, const c mca_base_event_t *event; /* ensure the caller did not set an invalid flag */ - assert (!(flags & 0x3f)); + assert (!(flags & (MCA_BASE_EVENT_FLAG_IWG-1))); /* update this assert if more MPIT verbosity levels are added */ assert (verbosity >= OPAL_INFO_LVL_1 && verbosity <= OPAL_INFO_LVL_9); @@ -613,7 +613,7 @@ int mca_base_event_read (mca_base_raised_event_t *revent, unsigned int element_i void mca_base_event_copy (mca_base_raised_event_t *revent, void *buffer) { mca_base_event_t *event = revent->re_event; - void *buffer_ptr = buffer; + uint8_t *buffer_ptr = (uint8_t *)buffer; for (size_t i = 0 ; i < event->event_datatype_count ; ++i) { if (buffer) { From 700ac1065dd3810a8ddf3b1965c5515d5778b4a2 Mon Sep 17 00:00:00 2001 From: Chris Chambreau Date: Wed, 1 Jun 2022 15:00:26 -0700 Subject: [PATCH 13/23] pr feedback - remove assert Signed-off-by: Chris Chambreau --- ompi/mpi/tool/event_get_info.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/ompi/mpi/tool/event_get_info.c b/ompi/mpi/tool/event_get_info.c index 9fb301ba733..2950d80434a 100644 --- a/ompi/mpi/tool/event_get_info.c +++ b/ompi/mpi/tool/event_get_info.c @@ -98,8 +98,6 @@ int MPI_T_event_get_info (int event_index, char *name, int *name_len, } } - assert (NULL != ompi_datatype); - array_of_datatypes[i] = ompi_datatype; } } From 9b42cd4160c414c92b88d1656103d44c0ed2997c Mon Sep 17 00:00:00 2001 From: Chris Chambreau Date: Wed, 1 Jun 2022 15:10:01 -0700 Subject: [PATCH 14/23] pr feedback - corrected comment references to events Signed-off-by: Chris Chambreau --- ompi/mpi/tool/event_handle_alloc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ompi/mpi/tool/event_handle_alloc.c b/ompi/mpi/tool/event_handle_alloc.c index b21633431f1..7fdf1b5715e 100644 --- a/ompi/mpi/tool/event_handle_alloc.c +++ b/ompi/mpi/tool/event_handle_alloc.c @@ -36,16 +36,16 @@ int MPI_T_event_handle_alloc (int event_index, void *obj_handle, MPI_Info info, ompi_mpit_lock (); - /* Find the performance variable. mca_base_event_get() handles the + /* Find the event. mca_base_event_get_by_index() handles the bounds checking. */ ret = mca_base_event_get_by_index (event_index, (mca_base_event_t **) &event); if (OMPI_SUCCESS != ret) { goto fn_fail; } - /* Check the variable binding is something sane */ + /* Check the event binding is something sane */ if (event->event_bind > MPI_T_BIND_MPI_INFO || event->event_bind < MPI_T_BIND_NO_OBJECT) { - /* This variable specified an invalid binding (not an MPI object). */ + /* This event specified an invalid binding (not an MPI object). */ ret = MPI_T_ERR_INVALID_INDEX; goto fn_fail; } From 94027c4458e339dbeee3462998c0c2cbcce9d256 Mon Sep 17 00:00:00 2001 From: Chris Chambreau Date: Wed, 1 Jun 2022 15:11:54 -0700 Subject: [PATCH 15/23] pr feedback - added locking for setting dropped event handler Signed-off-by: Chris Chambreau --- ompi/mpi/tool/event_set_dropped_handler.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ompi/mpi/tool/event_set_dropped_handler.c b/ompi/mpi/tool/event_set_dropped_handler.c index eb53f0f48b8..63f666d1320 100644 --- a/ompi/mpi/tool/event_set_dropped_handler.c +++ b/ompi/mpi/tool/event_set_dropped_handler.c @@ -36,7 +36,11 @@ int MPI_T_event_set_dropped_handler (MPI_T_event_registration handle, MPI_T_even return MPI_T_ERR_INVALID_HANDLE; } + ompi_mpit_lock (); + mca_base_event_registration_set_dropped_handler (handle, (mca_base_event_dropped_cb_fn_t) dropped_cb_function); + ompi_mpit_unlock (); + return MPI_SUCCESS; } From 881b652ca45c6d65e4d352cf3b2648af6aa5c209 Mon Sep 17 00:00:00 2001 From: Chris Chambreau Date: Wed, 29 Jun 2022 13:42:21 -0700 Subject: [PATCH 16/23] Protect source data access with thread locking. Signed-off-by: Chris Chambreau --- opal/mca/base/mca_base_source.c | 38 +++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/opal/mca/base/mca_base_source.c b/opal/mca/base/mca_base_source.c index 250e851928d..55cbb9b2987 100644 --- a/opal/mca/base/mca_base_source.c +++ b/opal/mca/base/mca_base_source.c @@ -63,19 +63,24 @@ int mca_base_source_init (void) int ret = OPAL_SUCCESS; OPAL_THREAD_LOCK(&mca_base_source_lock); + if (false == mca_base_source_initialized) { mca_base_source_initialized = true; OBJ_CONSTRUCT(®istered_sources, opal_pointer_array_t); opal_pointer_array_init(®istered_sources, 16, 512, 16); + OPAL_THREAD_UNLOCK(&mca_base_source_lock); + + /* mca_base_source_register will use lock */ mca_base_source_default_source = mca_base_source_register ("opal", "mca", "base", "default_source", "Default source for MCA events", true, mca_base_source_default_time_source, mca_base_source_default_time_source_ticks ()); } - OPAL_THREAD_UNLOCK(&mca_base_source_lock); + else + OPAL_THREAD_UNLOCK(&mca_base_source_lock); return ret; } @@ -107,17 +112,28 @@ int mca_base_source_finalize (void) mca_base_source_t *mca_base_source_get (int source_index) { - return opal_pointer_array_get_item (®istered_sources, source_index); + mca_base_source_t *ret; + + OPAL_THREAD_LOCK(&mca_base_source_lock); + + ret = opal_pointer_array_get_item (®istered_sources, source_index); + + OPAL_THREAD_UNLOCK(&mca_base_source_lock); + + return ret; } int mca_base_source_set_time_source (int source_index, mca_base_source_time_fn_t time_source, uint64_t time_ticks) { + /* Uses source lock/unlock */ mca_base_source_t *source = mca_base_source_get (source_index); if (NULL == source) { return OPAL_ERR_NOT_FOUND; } + OPAL_THREAD_LOCK(&mca_base_source_lock); + if (!time_source) { time_source = mca_base_source_default_time_source; time_ticks = mca_base_source_default_time_source_ticks (); @@ -126,6 +142,8 @@ int mca_base_source_set_time_source (int source_index, mca_base_source_time_fn_t source->source_time = time_source; source->source_ticks = time_ticks; + OPAL_THREAD_UNLOCK(&mca_base_source_lock); + return OPAL_SUCCESS; } @@ -133,12 +151,19 @@ int mca_base_source_set_time_source (int source_index, mca_base_source_time_fn_t int mca_base_source_get_count (int *count) { + OPAL_THREAD_LOCK(&mca_base_source_lock); + *count = source_count; + + OPAL_THREAD_UNLOCK(&mca_base_source_lock); + return OPAL_SUCCESS; } static inline int mca_base_source_get_by_name (const char *name, mca_base_source_t **source_out) { + OPAL_THREAD_LOCK(&mca_base_source_lock); + /* there are expected to be a relatively small number of sources so a linear search should be fine */ for (int i = 0 ; i < source_count ; ++i) { mca_base_source_t *source = opal_pointer_array_get_item (®istered_sources, i); @@ -147,10 +172,12 @@ static inline int mca_base_source_get_by_name (const char *name, mca_base_source *source_out = source; } + OPAL_THREAD_UNLOCK(&mca_base_source_lock); return OPAL_SUCCESS; } } + OPAL_THREAD_UNLOCK(&mca_base_source_lock); return OPAL_ERR_NOT_FOUND; } @@ -161,9 +188,12 @@ int mca_base_source_register (const char *project, const char *framework, const char *source_name; int ret; + OPAL_THREAD_LOCK(&mca_base_source_lock); + /* generate the variable's full name */ ret = mca_base_var_generate_full_name4 (NULL, framework, component, name, &source_name); if (OPAL_SUCCESS != ret) { + OPAL_THREAD_UNLOCK(&mca_base_source_lock); return ret; } @@ -174,6 +204,7 @@ int mca_base_source_register (const char *project, const char *framework, const /* create a new parameter entry */ source = OBJ_NEW(mca_base_source_t); if (NULL == source) { + OPAL_THREAD_UNLOCK(&mca_base_source_lock); return OPAL_ERR_OUT_OF_RESOURCE; } @@ -200,6 +231,7 @@ int mca_base_source_register (const char *project, const char *framework, const if (OPAL_SUCCESS != ret) { OBJ_RELEASE(source); + OPAL_THREAD_UNLOCK(&mca_base_source_lock); return ret; } } else { @@ -215,6 +247,8 @@ int mca_base_source_register (const char *project, const char *framework, const source->source_time = source_time; source->source_ticks = source_ticks; + OPAL_THREAD_UNLOCK(&mca_base_source_lock); + return OPAL_SUCCESS; } int mca_base_component_source_register (const mca_base_component_t *component, const char *name, const char *description, bool ordered, From 60c41023111702a531e461da731aec8929151617 Mon Sep 17 00:00:00 2001 From: Chris Chambreau Date: Wed, 29 Jun 2022 13:44:24 -0700 Subject: [PATCH 17/23] Add OPAL_LIKELY Signed-off-by: Chris Chambreau --- opal/mca/base/mca_base_source.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opal/mca/base/mca_base_source.c b/opal/mca/base/mca_base_source.c index 55cbb9b2987..491a33995cd 100644 --- a/opal/mca/base/mca_base_source.c +++ b/opal/mca/base/mca_base_source.c @@ -48,7 +48,7 @@ static uint64_t mca_base_source_default_time_source (void) static uint64_t mca_base_source_default_time_source_ticks (void) { struct timespec spec; - if (0 == opal_clock_getres(&spec)){ + if (OPAL_LIKELY(0 == opal_clock_getres(&spec))){ return (uint64_t)(spec.tv_sec + spec.tv_nsec); } else { /* guess */ From 00536b58942a302f939bcfee40e54cb9ee6d3413 Mon Sep 17 00:00:00 2001 From: Chris Chambreau Date: Wed, 29 Jun 2022 15:39:56 -0700 Subject: [PATCH 18/23] Correct OSC event descriptions. Signed-off-by: Chris Chambreau --- ompi/mca/osc/rdma/osc_rdma_component.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ompi/mca/osc/rdma/osc_rdma_component.c b/ompi/mca/osc/rdma/osc_rdma_component.c index b2674cb6373..7e285e9a148 100644 --- a/ompi/mca/osc/rdma/osc_rdma_component.c +++ b/ompi/mca/osc/rdma/osc_rdma_component.c @@ -108,7 +108,7 @@ mca_base_event_list_item_t mca_osc_rdma_events[] = { .offsets = &(unsigned long) {0}, .num_datatypes = 1, .elements = mca_osc_rdma_target_element, .bind = MCA_BASE_VAR_BIND_MPI_WIN}, - [OMPI_OSC_RDMA_EVENT_LOCK_RELEASED] = {.name = "lock_released", .desc = "Passive-target lock required", + [OMPI_OSC_RDMA_EVENT_LOCK_RELEASED] = {.name = "lock_released", .desc = "Passive-target lock released", .verbosity = OPAL_INFO_LVL_5, .datatypes = &(opal_datatype_t *) {&ompi_mpi_int.dt.super}, .offsets = &(unsigned long) {0}, .num_datatypes = 1, .elements = mca_osc_rdma_target_element, .bind = MCA_BASE_VAR_BIND_MPI_WIN}, @@ -123,12 +123,12 @@ mca_base_event_list_item_t mca_osc_rdma_events[] = { .offsets = mca_osc_rdma_rdma_event_offsets, .num_datatypes = 3, .elements = mca_osc_rdma_rdma_event_elements, .bind = MCA_BASE_VAR_BIND_MPI_WIN}, - [OMPI_OSC_RDMA_EVENT_GET_STARTED] = {.name = "get_started", .desc = "Put started to target. Complete event may not exist.", + [OMPI_OSC_RDMA_EVENT_GET_STARTED] = {.name = "get_started", .desc = "Get started to target. Complete event may not exist.", .verbosity = OPAL_INFO_LVL_5, .datatypes = mca_osc_rdma_rdma_event_types, .offsets = mca_osc_rdma_rdma_event_offsets, .num_datatypes = 3, .elements = mca_osc_rdma_rdma_event_elements, .bind = MCA_BASE_VAR_BIND_MPI_WIN}, - [OMPI_OSC_RDMA_EVENT_GET_COMPLETE] = {.name = "get_complete", .desc = "Put completed on target", + [OMPI_OSC_RDMA_EVENT_GET_COMPLETE] = {.name = "get_complete", .desc = "Get completed on target", .verbosity = OPAL_INFO_LVL_5, .datatypes = mca_osc_rdma_rdma_event_types, .offsets = mca_osc_rdma_rdma_event_offsets, .num_datatypes = 3, .elements = mca_osc_rdma_rdma_event_elements, .bind = MCA_BASE_VAR_BIND_MPI_WIN}, @@ -143,22 +143,22 @@ mca_base_event_list_item_t mca_osc_rdma_events[] = { .offsets = &(unsigned long) {0}, .num_datatypes = 1, .elements = mca_osc_rdma_target_element, .bind = MCA_BASE_VAR_BIND_MPI_WIN}, - [OMPI_OSC_RDMA_EVENT_PSCW_EXPOSE_START] = {.name = "pscw_expose_start", .desc = "PSWW exposure started", + [OMPI_OSC_RDMA_EVENT_PSCW_EXPOSE_START] = {.name = "pscw_expose_start", .desc = "PSCW exposure started", .verbosity = OPAL_INFO_LVL_5, .datatypes = &(opal_datatype_t *) {&ompi_mpi_int.dt.super}, .offsets = &(unsigned long) {0}, .num_datatypes = 0, .elements = mca_osc_rdma_target_element, .bind = MCA_BASE_VAR_BIND_MPI_WIN}, - [OMPI_OSC_RDMA_EVENT_PSCW_EXPOSE_COMPLETE] = {.name = "pscw_expose_complete", .desc = "PSWW exposure complete", + [OMPI_OSC_RDMA_EVENT_PSCW_EXPOSE_COMPLETE] = {.name = "pscw_expose_complete", .desc = "PSCW exposure complete", .verbosity = OPAL_INFO_LVL_5, .datatypes = &(opal_datatype_t *) {&ompi_mpi_int.dt.super}, .offsets = &(unsigned long) {0}, .num_datatypes = 0, .elements = mca_osc_rdma_target_element, .bind = MCA_BASE_VAR_BIND_MPI_WIN}, - [OMPI_OSC_RDMA_EVENT_PSCW_ACCESS_START] = {.name = "pscw_access_start", .desc = "PSWW access epoch started", + [OMPI_OSC_RDMA_EVENT_PSCW_ACCESS_START] = {.name = "pscw_access_start", .desc = "PSCW access epoch started", .verbosity = OPAL_INFO_LVL_5, .datatypes = &(opal_datatype_t *) {&ompi_mpi_int.dt.super}, .offsets = &(unsigned long) {0}, .num_datatypes = 1, .elements = mca_osc_rdma_target_element, .bind = MCA_BASE_VAR_BIND_MPI_WIN}, - [OMPI_OSC_RDMA_EVENT_PSCW_ACCESS_COMPLETE] = {.name = "pscw_access_complete", .desc = "PSWW access epoch complete", + [OMPI_OSC_RDMA_EVENT_PSCW_ACCESS_COMPLETE] = {.name = "pscw_access_complete", .desc = "PSCW access epoch complete", .verbosity = OPAL_INFO_LVL_5, .datatypes = &(opal_datatype_t *) {&ompi_mpi_int.dt.super}, .offsets = &(unsigned long) {0}, .num_datatypes = 1, .elements = mca_osc_rdma_target_element, .bind = MCA_BASE_VAR_BIND_MPI_WIN}, From bb40829aa29df949a4be1652fb7365e641fddc37 Mon Sep 17 00:00:00 2001 From: Chris Chambreau Date: Wed, 29 Jun 2022 21:04:27 -0700 Subject: [PATCH 19/23] Ensure consistency between ompi and opal callback safety requirement values. Signed-off-by: Chris Chambreau --- ompi/include/mpi.h.in | 14 ++++++++++---- opal/mca/base/mca_base_event.h | 10 +++++----- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/ompi/include/mpi.h.in b/ompi/include/mpi.h.in index 4c1b90b4dd8..52d92d7bbdd 100644 --- a/ompi/include/mpi.h.in +++ b/ompi/include/mpi.h.in @@ -917,12 +917,18 @@ enum { /* * MPIT callback safety levels + * + * Values are set in configure.ac for consistency with mca_base_event.h */ +#undef OPAL_MCA_BASE_CB_REQUIRE_NONE +#undef OPAL_MCA_BASE_CB_REQUIRE_MPI_RESTRICTED +#undef OPAL_MCA_BASE_CB_REQUIRE_THREAD_SAFE +#undef OPAL_MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE typedef enum { - MPI_T_CB_REQUIRE_NONE, - MPI_T_CB_REQUIRE_MPI_RESTRICTED, - MPI_T_CB_REQUIRE_THREAD_SAFE, - MPI_T_CB_REQUIRE_ASYNC_SIGNAL_SAFE + MPI_T_CB_REQUIRE_NONE = OPAL_MCA_BASE_CB_REQUIRE_NONE, + MPI_T_CB_REQUIRE_MPI_RESTRICTED = OPAL_MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, + MPI_T_CB_REQUIRE_THREAD_SAFE = OPAL_MCA_BASE_CB_REQUIRE_THREAD_SAFE, + MPI_T_CB_REQUIRE_ASYNC_SIGNAL_SAFE = OPAL_MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE } MPI_T_cb_safety; /* diff --git a/opal/mca/base/mca_base_event.h b/opal/mca/base/mca_base_event.h index 4d00d415136..bc270798887 100644 --- a/opal/mca/base/mca_base_event.h +++ b/opal/mca/base/mca_base_event.h @@ -42,13 +42,13 @@ typedef enum { /** * @basic Callback safety levels * - * If these are modified then similar modifications will be needed in mpi.h.in. + * Values are set in configure.ac for consistency with mpi.h */ typedef enum { - MCA_BASE_CB_REQUIRE_NONE, - MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, - MCA_BASE_CB_REQUIRE_THREAD_SAFE, - MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, + MCA_BASE_CB_REQUIRE_NONE = OPAL_MCA_BASE_CB_REQUIRE_NONE, + MCA_BASE_CB_REQUIRE_MPI_RESTRICTED = OPAL_MCA_BASE_CB_REQUIRE_MPI_RESTRICTED, + MCA_BASE_CB_REQUIRE_THREAD_SAFE = OPAL_MCA_BASE_CB_REQUIRE_THREAD_SAFE, + MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE = OPAL_MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE, MCA_BASE_CB_SAFETY_MAX, } mca_base_cb_safety_t; From 4fdca8356626740604f88ef3d878f1bd18ba8413 Mon Sep 17 00:00:00 2001 From: Chris Chambreau Date: Thu, 30 Jun 2022 12:08:54 -0700 Subject: [PATCH 20/23] Ensure thread safety for incremented variables. Signed-off-by: Chris Chambreau --- opal/mca/base/mca_base_var_group.c | 35 ++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/opal/mca/base/mca_base_var_group.c b/opal/mca/base/mca_base_var_group.c index 6d2aaed9eb1..de27a7723c9 100644 --- a/opal/mca/base/mca_base_var_group.c +++ b/opal/mca/base/mca_base_var_group.c @@ -62,6 +62,8 @@ static void mca_base_var_group_destructor(mca_base_var_group_t *group); OBJ_CLASS_INSTANCE(mca_base_var_group_t, opal_object_t, mca_base_var_group_constructor, mca_base_var_group_destructor); +static opal_mutex_t mca_base_var_group_lock = OPAL_MUTEX_STATIC_INIT; + int mca_base_var_group_init(void) { int ret; @@ -82,7 +84,9 @@ int mca_base_var_group_init(void) } mca_base_var_group_initialized = true; + OPAL_THREAD_LOCK(&mca_base_var_group_lock); mca_base_var_group_count = 0; + OPAL_THREAD_UNLOCK(&mca_base_var_group_lock); } return OPAL_SUCCESS; @@ -103,7 +107,9 @@ int mca_base_var_group_finalize(void) } OBJ_DESTRUCT(&mca_base_var_groups); OBJ_DESTRUCT(&mca_base_var_group_index_hash); + OPAL_THREAD_LOCK(&mca_base_var_group_lock); mca_base_var_group_count = 0; + OPAL_THREAD_UNLOCK(&mca_base_var_group_lock); mca_base_var_group_initialized = false; } @@ -168,6 +174,7 @@ static bool compare_strings(const char *str1, const char *str2) static int group_find_linear(const char *project_name, const char *framework_name, const char *component_name, bool invalidok) { + OPAL_THREAD_LOCK(&mca_base_var_group_lock); for (int i = 0; i < mca_base_var_group_count; ++i) { mca_base_var_group_t *group; @@ -179,9 +186,11 @@ static int group_find_linear(const char *project_name, const char *framework_nam if (compare_strings(project_name, group->group_project) && compare_strings(framework_name, group->group_framework) && compare_strings(component_name, group->group_component)) { + OPAL_THREAD_UNLOCK(&mca_base_var_group_lock); return i; } } + OPAL_THREAD_UNLOCK(&mca_base_var_group_lock); return OPAL_ERR_NOT_FOUND; } @@ -241,7 +250,9 @@ static int group_register(const char *project_name, const char *framework_name, return ret; } group->group_isvalid = true; + OPAL_THREAD_LOCK(&mca_base_var_group_lock); mca_base_var_groups_timestamp++; + OPAL_THREAD_UNLOCK(&mca_base_var_group_lock); /* group already exists. return it's index */ return group_id; @@ -305,8 +316,10 @@ static int group_register(const char *project_name, const char *framework_name, opal_hash_table_set_value_ptr(&mca_base_var_group_index_hash, group->group_full_name, strlen(group->group_full_name), (void *) (uintptr_t) group_id); + OPAL_THREAD_LOCK(&mca_base_var_group_lock); mca_base_var_group_count++; mca_base_var_groups_timestamp++; + OPAL_THREAD_UNLOCK(&mca_base_var_group_lock); if (0 <= parent_id) { mca_base_var_group_t *parent_group; @@ -406,7 +419,9 @@ int mca_base_var_group_deregister(int group_index) /* ordering of variables and subgroups must be the same if the * group is re-registered */ + OPAL_THREAD_LOCK(&mca_base_var_group_lock); mca_base_var_groups_timestamp++; + OPAL_THREAD_UNLOCK(&mca_base_var_group_lock); return OPAL_SUCCESS; } @@ -445,7 +460,9 @@ int mca_base_var_group_add_var(const int group_index, const int param_index) return ret; } + OPAL_THREAD_LOCK(&mca_base_var_group_lock); mca_base_var_groups_timestamp++; + OPAL_THREAD_UNLOCK(&mca_base_var_group_lock); /* return the group index */ return (int) opal_value_array_get_size(&group->group_vars) - 1; @@ -474,7 +491,9 @@ int mca_base_var_group_add_pvar(const int group_index, const int param_index) return ret; } + OPAL_THREAD_LOCK(&mca_base_var_group_lock); mca_base_var_groups_timestamp++; + OPAL_THREAD_UNLOCK(&mca_base_var_group_lock); /* return the group index */ return (int) opal_value_array_get_size(&group->group_pvars) - 1; @@ -531,7 +550,9 @@ int mca_base_var_group_add_event (const int group_index, const int event_index) return ret; } + OPAL_THREAD_LOCK(&mca_base_var_group_lock); mca_base_var_groups_timestamp++; + OPAL_THREAD_UNLOCK(&mca_base_var_group_lock); /* return the group index */ return (int) opal_value_array_get_size (&group->group_events) - 1; @@ -612,10 +633,20 @@ static void mca_base_var_group_destructor(mca_base_var_group_t *group) int mca_base_var_group_get_count(void) { - return mca_base_var_group_count; + int ret; + + OPAL_THREAD_LOCK(&mca_base_var_group_lock); + ret = mca_base_var_group_count; + OPAL_THREAD_UNLOCK(&mca_base_var_group_lock); + return ret; } int mca_base_var_group_get_stamp(void) { - return mca_base_var_groups_timestamp; + int ret; + + OPAL_THREAD_LOCK(&mca_base_var_group_lock); + ret = mca_base_var_groups_timestamp; + OPAL_THREAD_UNLOCK(&mca_base_var_group_lock); + return ret; } From 596a04ece92baeeef487ebaae4ea0eda951c642c Mon Sep 17 00:00:00 2001 From: Chris Chambreau Date: Thu, 30 Jun 2022 14:10:39 -0700 Subject: [PATCH 21/23] Add function to lookup ompi datatype from opal datatype id. Signed-off-by: Chris Chambreau --- ompi/datatype/Makefile.am | 1 + ompi/datatype/ompi_datatype.h | 2 ++ .../ompi_datatype_lookup_by_opal_id.c | 28 +++++++++++++++++++ ompi/mpi/tool/event_get_info.c | 13 +-------- 4 files changed, 32 insertions(+), 12 deletions(-) create mode 100644 ompi/datatype/ompi_datatype_lookup_by_opal_id.c diff --git a/ompi/datatype/Makefile.am b/ompi/datatype/Makefile.am index 643e8147fdd..aa059568e68 100644 --- a/ompi/datatype/Makefile.am +++ b/ompi/datatype/Makefile.am @@ -41,6 +41,7 @@ libdatatype_la_SOURCES = \ ompi_datatype_create_subarray.c \ ompi_datatype_external.c \ ompi_datatype_external32.c \ + ompi_datatype_lookup_by_opal_id.c \ ompi_datatype_match_size.c \ ompi_datatype_module.c \ ompi_datatype_sndrcv.c \ diff --git a/ompi/datatype/ompi_datatype.h b/ompi/datatype/ompi_datatype.h index 0c77079b916..004832c3312 100644 --- a/ompi/datatype/ompi_datatype.h +++ b/ompi/datatype/ompi_datatype.h @@ -295,6 +295,8 @@ ompi_datatype_copy_content_same_ddt( const ompi_datatype_t* type, size_t count, return 0; } +OMPI_DECLSPEC ompi_datatype_t* ompi_datatype_lookup_by_opal_id( uint16_t opal_id ); + OMPI_DECLSPEC const ompi_datatype_t* ompi_datatype_match_size( int size, uint16_t datakind, uint16_t datalang ); /* diff --git a/ompi/datatype/ompi_datatype_lookup_by_opal_id.c b/ompi/datatype/ompi_datatype_lookup_by_opal_id.c new file mode 100644 index 00000000000..6c77069fe9c --- /dev/null +++ b/ompi/datatype/ompi_datatype_lookup_by_opal_id.c @@ -0,0 +1,28 @@ +/* -*- Mode: C; c-basic-offset:4 ; -*- */ +/* + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "ompi_config.h" +#include "ompi/datatype/ompi_datatype.h" +#include "ompi/datatype/ompi_datatype_internal.h" + + +ompi_datatype_t* ompi_datatype_lookup_by_opal_id( uint16_t opal_id ) +{ + int32_t i; + const ompi_datatype_t* datatype = NULL; + + for (int j = 0 ; j < OMPI_DATATYPE_MPI_MAX_PREDEFINED ; ++j) { + if (ompi_datatype_basicDatatypes[j]->super.id == opal_id) { + datatype = (ompi_datatype_t *) ompi_datatype_basicDatatypes[j]; + break; + } + } + + return datatype; +} diff --git a/ompi/mpi/tool/event_get_info.c b/ompi/mpi/tool/event_get_info.c index 2950d80434a..60f772e8eeb 100644 --- a/ompi/mpi/tool/event_get_info.c +++ b/ompi/mpi/tool/event_get_info.c @@ -17,9 +17,6 @@ #include "ompi/mpi/tool/mpit-internal.h" -/* needed to convert between opal and ompi datatypes until a function is provided */ -#include "ompi/datatype/ompi_datatype_internal.h" - #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS #pragma weak MPI_T_event_get_info = PMPI_T_event_get_info @@ -89,16 +86,8 @@ int MPI_T_event_get_info (int event_index, char *name, int *name_len, if (max_datatypes) { if (array_of_datatypes) { for (int i = 0 ; i < max_datatypes ; i++) { - ompi_datatype_t *ompi_datatype = NULL; - - for (int j = 0 ; j < OMPI_DATATYPE_MPI_MAX_PREDEFINED ; ++j) { - if (ompi_datatype_basicDatatypes[j]->super.id == event->event_datatypes[i]->id) { - ompi_datatype = (ompi_datatype_t *) ompi_datatype_basicDatatypes[j]; - break; - } - } - array_of_datatypes[i] = ompi_datatype; + array_of_datatypes[i] = ompi_datatype_lookup_by_opal_id(event->event_datatypes[i]->id); } } From 2233aefce1252cca4ad9ea79f63797f0934bf8bd Mon Sep 17 00:00:00 2001 From: Howard Pritchard Date: Tue, 2 Jan 2024 12:27:20 -0700 Subject: [PATCH 22/23] fix compile problem after rebase Signed-off-by: Howard Pritchard --- opal/mca/base/mca_base_event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opal/mca/base/mca_base_event.c b/opal/mca/base/mca_base_event.c index e7d7dd4d236..567501627c8 100644 --- a/opal/mca/base/mca_base_event.c +++ b/opal/mca/base/mca_base_event.c @@ -503,7 +503,7 @@ int mca_base_event_dump(int index, char ***out, mca_base_var_dump_type_t output_ if (NULL != event->event_enumerator) { char *values; - ret = event->event_enumerator->dump(event->event_enumerator, &values); + ret = event->event_enumerator->dump(event->event_enumerator, &values, MCA_BASE_VAR_ENUM_DUMP_READABLE); if (OPAL_SUCCESS == ret) { (void)asprintf (out[0] + line++, "Elements: %s", values); free (values); From 40a660667b38231dd9d8c768a79d8684255f887a Mon Sep 17 00:00:00 2001 From: Kingshuk Haldar Date: Mon, 10 Mar 2025 20:49:04 +0100 Subject: [PATCH 23/23] Do not use mutex lock during mca_base_source_get_by_name() Signed-off-by: Kingshuk Haldar --- opal/mca/base/mca_base_source.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/opal/mca/base/mca_base_source.c b/opal/mca/base/mca_base_source.c index 491a33995cd..8b8b4fdb6b1 100644 --- a/opal/mca/base/mca_base_source.c +++ b/opal/mca/base/mca_base_source.c @@ -160,10 +160,12 @@ int mca_base_source_get_count (int *count) return OPAL_SUCCESS; } +/* This function should be under mca_base_source_lock. */ +/* Due to this being called only from mca_base_source_register() currently, */ +/* and that is under such lock, there aren't any locks here. */ +/* This should be considered if this needs to be called from somewhere else. */ static inline int mca_base_source_get_by_name (const char *name, mca_base_source_t **source_out) { - OPAL_THREAD_LOCK(&mca_base_source_lock); - /* there are expected to be a relatively small number of sources so a linear search should be fine */ for (int i = 0 ; i < source_count ; ++i) { mca_base_source_t *source = opal_pointer_array_get_item (®istered_sources, i); @@ -172,12 +174,10 @@ static inline int mca_base_source_get_by_name (const char *name, mca_base_source *source_out = source; } - OPAL_THREAD_UNLOCK(&mca_base_source_lock); return OPAL_SUCCESS; } } - OPAL_THREAD_UNLOCK(&mca_base_source_lock); return OPAL_ERR_NOT_FOUND; }