Skip to content

Commit f44711f

Browse files
hjelmnjsquyres
authored andcommitted
Modify PERUSE code to implement MPI_T Events based on MPI 4.0 proposal.
Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
1 parent b1b2280 commit f44711f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2787
-136
lines changed

ompi/include/mpi.h.in

Lines changed: 107 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
* Copyright (c) 2021-2022 Amazon.com, Inc. or its affiliates. All Rights
2626
* reserved.
2727
* Copyright (c) 2021 Bull S.A.S. All rights reserved.
28-
* Copyright (c) 2018 Triad National Security, LLC. All rights
2928
* Copyright (c) 2018-2021 Triad National Security, LLC. All rights
3029
* reserved.
3130
* $COPYRIGHT$
@@ -455,6 +454,8 @@ typedef struct ompi_mpit_cvar_handle_t *MPI_T_cvar_handle;
455454
typedef struct mca_base_pvar_handle_t *MPI_T_pvar_handle;
456455
typedef struct mca_base_pvar_session_t *MPI_T_pvar_session;
457456
typedef struct ompi_instance_t *MPI_Session;
457+
typedef struct mca_base_raised_event_t *MPI_T_event_instance;
458+
typedef struct mca_base_event_registration_t *MPI_T_event_registration;
458459

459460
/*
460461
* MPI_Status
@@ -890,6 +891,41 @@ enum {
890891
MPI_T_PVAR_CLASS_GENERIC
891892
};
892893

894+
/*
895+
* MPIT callback safety levels
896+
*/
897+
typedef enum {
898+
MPI_T_CB_REQUIRE_NONE,
899+
MPI_T_CB_REQUIRE_MPI_RESTRICTED,
900+
MPI_T_CB_REQUIRE_THREAD_SAFE,
901+
MPI_T_CB_REQUIRE_ASYNC_SIGNAL_SAFE
902+
} MPI_T_cb_safety;
903+
904+
/*
905+
* MPIT source ordering
906+
*/
907+
enum ompi_mpi_t_order_t {
908+
MPI_T_ORDERED,
909+
MPI_T_UNORDERED,
910+
};
911+
912+
typedef enum ompi_mpi_t_order_t MPI_T_order;
913+
914+
/*
915+
* MPI Tool event functions
916+
*/
917+
typedef void (*MPI_T_event_free_cb_function) (MPI_T_event_registration handle,
918+
MPI_T_cb_safety cb_safety,
919+
void *user_data);
920+
typedef void (*MPI_T_event_dropped_cb_function) (int count,
921+
MPI_T_event_registration handle,
922+
MPI_T_cb_safety cb_safety,
923+
void *user_data);
924+
typedef void (*MPI_T_event_cb_function) (MPI_T_event_instance event,
925+
MPI_T_event_registration handle,
926+
MPI_T_cb_safety cb_safety,
927+
void *user_data);
928+
893929
/*
894930
* NULL handles
895931
*/
@@ -925,6 +961,7 @@ enum {
925961
#define MPI_T_PVAR_HANDLE_NULL ((MPI_T_pvar_handle) 0)
926962
#define MPI_T_PVAR_SESSION_NULL ((MPI_T_pvar_session) 0)
927963
#define MPI_T_CVAR_HANDLE_NULL ((MPI_T_cvar_handle) 0)
964+
#define MPI_T_EVENT_REGISTRATION_NULL ((MPI_T_event_registration) 0)
928965

929966
/* MPI-2 specifies that the name "MPI_TYPE_NULL_DELETE_FN" (and all
930967
related friends) must be accessible in C, C++, and Fortran. This is
@@ -2923,6 +2960,40 @@ OMPI_DECLSPEC int PMPI_T_enum_get_info(MPI_T_enum enumtype, int *num, char *nam
29232960
OMPI_DECLSPEC int PMPI_T_enum_get_item(MPI_T_enum enumtype, int index, int *value, char *name,
29242961
int *name_len);
29252962

2963+
OMPI_DECLSPEC int PMPI_T_event_get_num (int *num_events);
2964+
OMPI_DECLSPEC int PMPI_T_event_get_info (int event_index, char *name, int *name_len,
2965+
int *verbosity, MPI_Datatype *array_of_datatypes,
2966+
MPI_Aint *array_of_displacements, int *num_elements,
2967+
MPI_Aint *extent, MPI_T_enum *enumtype, MPI_Info *info,
2968+
char *desc, int *desc_len, int *bind);
2969+
OMPI_DECLSPEC int PMPI_T_event_get_index (const char *name, int *event_index);
2970+
OMPI_DECLSPEC int PMPI_T_event_handle_alloc (int event_index, void *obj_handle,
2971+
MPI_Info info, MPI_T_event_registration *event_registration);
2972+
OMPI_DECLSPEC int PMPI_T_event_handle_set_info (MPI_T_event_registration event_registration, MPI_Info info);
2973+
OMPI_DECLSPEC int PMPI_T_event_handle_get_info (MPI_T_event_registration event_registration,
2974+
MPI_Info *info_used);
2975+
OMPI_DECLSPEC int PMPI_T_event_register_callback (MPI_T_event_registration event_registration,
2976+
MPI_T_cb_safety cb_safety, MPI_Info info, void *user_data,
2977+
MPI_T_event_cb_function event_cb_function);
2978+
OMPI_DECLSPEC int PMPI_T_event_callback_set_info (MPI_T_event_registration event_registration,
2979+
MPI_T_cb_safety cb_safety, MPI_Info info);
2980+
OMPI_DECLSPEC int PMPI_T_event_callback_get_info (MPI_T_event_registration event_registration,
2981+
MPI_T_cb_safety cb_safety, MPI_Info *info_used);
2982+
OMPI_DECLSPEC int PMPI_T_event_handle_free (MPI_T_event_registration event_registration,
2983+
MPI_T_event_free_cb_function free_cb_function);
2984+
OMPI_DECLSPEC int PMPI_T_event_set_dropped_handler (MPI_T_event_registration handle,
2985+
MPI_T_event_dropped_cb_function dropped_cb_function);
2986+
OMPI_DECLSPEC int PMPI_T_event_read (MPI_T_event_instance event, int element_index, void *buffer);
2987+
OMPI_DECLSPEC int PMPI_T_event_copy (MPI_T_event_instance event, void *buffer);
2988+
OMPI_DECLSPEC int PMPI_T_event_get_timestamp (MPI_T_event_instance event, MPI_Count *event_time);
2989+
OMPI_DECLSPEC int PMPI_T_event_get_source (MPI_T_event_instance event, int *source_index);
2990+
OMPI_DECLSPEC int PMPI_T_source_get_num (int *num_source);
2991+
OMPI_DECLSPEC int PMPI_T_source_get_info (int source_id, char *name, int *name_len,
2992+
char *desc, int *desc_len, MPI_T_order *ordering,
2993+
MPI_Count *ticks_per_second, MPI_Count *max_timestamp,
2994+
MPI_Info *info);
2995+
OMPI_DECLSPEC int PMPI_T_source_get_timestamp (int source_id, MPI_Count *timestamp);
2996+
29262997
/*
29272998
* Tool MPI API
29282999
*/
@@ -2989,6 +3060,41 @@ OMPI_DECLSPEC int MPI_Attr_put(MPI_Comm comm, int keyval, void *attribute_val)
29893060
OMPI_DECLSPEC int PMPI_Attr_put(MPI_Comm comm, int keyval, void *attribute_val)
29903061
__mpi_interface_deprecated__("PMPI_Attr_put was deprecated in MPI-2.0; use PMPI_Comm_set_attr instead");
29913062

3063+
OMPI_DECLSPEC int MPI_T_event_get_num (int *num_events);
3064+
OMPI_DECLSPEC int MPI_T_event_get_info (int event_index, char *name, int *name_len,
3065+
int *verbosity, MPI_Datatype *array_of_datatypes,
3066+
MPI_Aint *array_of_displacements, int *num_elements,
3067+
MPI_Aint *extent, MPI_T_enum *enumtype, MPI_Info *info,
3068+
char *desc, int *desc_len, int *bind);
3069+
OMPI_DECLSPEC int MPI_T_event_get_index (const char *name, int *event_index);
3070+
OMPI_DECLSPEC int MPI_T_event_handle_alloc (int event_index, void *obj_handle,
3071+
MPI_Info info, MPI_T_event_registration *event_registration);
3072+
OMPI_DECLSPEC int MPI_T_event_handle_set_info (MPI_T_event_registration event_registration, MPI_Info info);
3073+
OMPI_DECLSPEC int MPI_T_event_handle_get_info (MPI_T_event_registration event_registration,
3074+
MPI_Info *info_used);
3075+
OMPI_DECLSPEC int MPI_T_event_handle_free (MPI_T_event_registration event_registration,
3076+
MPI_T_event_free_cb_function free_cb_function);
3077+
OMPI_DECLSPEC int MPI_T_event_register_callback (MPI_T_event_registration event_registration,
3078+
MPI_T_cb_safety cb_safety, MPI_Info info, void *user_data,
3079+
MPI_T_event_cb_function event_cb_function);
3080+
OMPI_DECLSPEC int MPI_T_event_callback_set_info (MPI_T_event_registration event_registration,
3081+
MPI_T_cb_safety cb_safety, MPI_Info info);
3082+
OMPI_DECLSPEC int MPI_T_event_callback_get_info (MPI_T_event_registration event_registration,
3083+
MPI_T_cb_safety cb_safety, MPI_Info *info_used);
3084+
OMPI_DECLSPEC int MPI_T_event_set_dropped_handler (MPI_T_event_registration handle,
3085+
MPI_T_event_dropped_cb_function dropped_cb_function);
3086+
OMPI_DECLSPEC int MPI_T_event_read (MPI_T_event_instance event, int element_index, void *buffer);
3087+
OMPI_DECLSPEC int MPI_T_event_copy (MPI_T_event_instance event, void *buffer);
3088+
OMPI_DECLSPEC int MPI_T_event_get_timestamp (MPI_T_event_instance event, MPI_Count *event_time);
3089+
OMPI_DECLSPEC int MPI_T_event_get_source (MPI_T_event_instance event, int *source_index);
3090+
3091+
OMPI_DECLSPEC int MPI_T_source_get_num (int *num_source);
3092+
OMPI_DECLSPEC int MPI_T_source_get_info (int source_id, char *name, int *name_len,
3093+
char *desc, int *desc_len, MPI_T_order *ordering,
3094+
MPI_Count *ticks_per_second, MPI_Count *max_timestamp,
3095+
MPI_Info *info);
3096+
OMPI_DECLSPEC int MPI_T_source_get_timestamp (int source_id, MPI_Count *timestamp);
3097+
29923098
/*
29933099
* Even though MPI_Copy_function and MPI_Delete_function are
29943100
* deprecated, we do not use the attributes marking them as such,

ompi/mca/osc/rdma/osc_rdma.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,34 @@
5555
#include "osc_rdma_peer.h"
5656

5757
#include "opal_stdint.h"
58+
#include "opal/mca/base/mca_base_event.h"
59+
60+
enum {
61+
OMPI_OSC_RDMA_EVENT_LOCK_ACQUIRED,
62+
OMPI_OSC_RDMA_EVENT_LOCK_RELEASED,
63+
OMPI_OSC_RDMA_EVENT_PUT_STARTED,
64+
OMPI_OSC_RDMA_EVENT_PUT_COMPLETE,
65+
OMPI_OSC_RDMA_EVENT_GET_STARTED,
66+
OMPI_OSC_RDMA_EVENT_GET_COMPLETE,
67+
OMPI_OSC_RDMA_EVENT_FLUSH_STARTED,
68+
OMPI_OSC_RDMA_EVENT_FLUSH_COMPLETE,
69+
OMPI_OSC_RDMA_EVENT_PSCW_EXPOSE_START,
70+
OMPI_OSC_RDMA_EVENT_PSCW_EXPOSE_COMPLETE,
71+
OMPI_OSC_RDMA_EVENT_PSCW_ACCESS_START,
72+
OMPI_OSC_RDMA_EVENT_PSCW_ACCESS_COMPLETE,
73+
OMPI_OSC_RDMA_EVENT_FENCE,
74+
OMPI_OSC_RDMA_EVENT_MAX,
75+
};
76+
77+
struct mca_osc_rdma_rdma_event_t {
78+
int target;
79+
uint64_t address;
80+
uint64_t size;
81+
};
82+
83+
typedef struct mca_osc_rdma_rdma_event_t mca_osc_rdma_rdma_event_t;
84+
85+
extern mca_base_event_list_item_t mca_osc_rdma_events[];
5886

5987
#define RANK_ARRAY_COUNT(module) ((ompi_comm_size ((module)->comm) + (module)->node_count - 1) / (module)->node_count)
6088

ompi/mca/osc/rdma/osc_rdma_active_target.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ static void ompi_osc_rdma_handle_post (ompi_osc_rdma_module_t *module, int rank,
182182
rank, (int) (npeers - state->num_post_msgs - 1));
183183
/* an atomic is not really necessary as this function is currently used but it doesn't hurt */
184184
ompi_osc_rdma_counter_add (&state->num_post_msgs, 1);
185+
mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_PSCW_ACCESS_START].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE,
186+
module->win, NULL, &rank);
185187
return;
186188
}
187189
}
@@ -307,6 +309,9 @@ int ompi_osc_rdma_post_atomic (ompi_group_t *group, int mpi_assert, ompi_win_t *
307309
return OMPI_SUCCESS;
308310
}
309311

312+
mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_PSCW_EXPOSE_START].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE,
313+
module->win, NULL, NULL);
314+
310315
/* translate group ranks into the communicator */
311316
peers = ompi_osc_rdma_get_peers (module, module->pw_group);
312317
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
394399
"from %d processes", peer->rank, (int) (group_size - state->num_post_msgs - 1));
395400
opal_list_remove_item (&module->pending_posts, &pending_post->super);
396401
OBJ_RELEASE(pending_post);
402+
mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_PSCW_ACCESS_START].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE,
403+
module->win, NULL, &peer->rank);
397404
ompi_osc_rdma_counter_add (&state->num_post_msgs, 1);
398405
break;
399406
}
@@ -464,6 +471,9 @@ int ompi_osc_rdma_complete_atomic (ompi_win_t *win)
464471
ompi_osc_rdma_peer_t *peer = peers[i];
465472
intptr_t target = (intptr_t) peer->state + offsetof (ompi_osc_rdma_state_t, num_complete_msgs);
466473

474+
mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_PSCW_ACCESS_COMPLETE].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE,
475+
module->win, NULL, &peer->rank);
476+
467477
if (!ompi_osc_rdma_peer_local_state (peer)) {
468478
ret = ompi_osc_rdma_lock_btl_op (module, peer, target, MCA_BTL_ATOMIC_ADD, 1, true);
469479
assert (OMPI_SUCCESS == ret);
@@ -507,6 +517,9 @@ int ompi_osc_rdma_wait_atomic (ompi_win_t *win)
507517
opal_atomic_mb ();
508518
}
509519

520+
mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_PSCW_EXPOSE_COMPLETE].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE,
521+
module->win, NULL, NULL);
522+
510523
OPAL_THREAD_LOCK(&module->lock);
511524
group = module->pw_group;
512525
module->pw_group = NULL;
@@ -556,6 +569,9 @@ int ompi_osc_rdma_test_atomic (ompi_win_t *win, int *flag)
556569
module->pw_group = NULL;
557570
OPAL_THREAD_UNLOCK(&(module->lock));
558571

572+
mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_PSCW_EXPOSE_COMPLETE].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE,
573+
module->win, NULL, NULL);
574+
559575
OBJ_RELEASE(group);
560576

561577
OSC_RDMA_VERBOSE(MCA_BASE_VERBOSE_TRACE, "test complete. returning flag: true");

ompi/mca/osc/rdma/osc_rdma_comm.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
* $HEADER$
1616
*/
1717

18-
#include "ompi_config.h"
19-
18+
#include "osc_rdma.h"
2019
#include "osc_rdma_comm.h"
2120
#include "osc_rdma_frag.h"
2221
#include "osc_rdma_sync.h"
@@ -458,6 +457,9 @@ static int ompi_osc_rdma_put_real (ompi_osc_rdma_sync_t *sync, ompi_osc_rdma_pee
458457
OSC_RDMA_VERBOSE(MCA_BASE_VERBOSE_TRACE, "initiating btl put of %lu bytes to remote address %" PRIx64 ", sync "
459458
"object %p...", (unsigned long) size, target_address, (void *) sync);
460459

460+
mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_PUT_STARTED].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE,
461+
module->win, NULL, &((mca_osc_rdma_rdma_event_t){.target = peer->rank, .address = target_address, .size = size}));
462+
461463
/* flag outstanding rma requests */
462464
ompi_osc_rdma_sync_rdma_inc (sync);
463465

@@ -714,6 +716,9 @@ static int ompi_osc_rdma_get_contig (ompi_osc_rdma_sync_t *sync, ompi_osc_rdma_p
714716
ompi_osc_rdma_sync_rdma_inc (sync);
715717
}
716718

719+
mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_GET_STARTED].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE,
720+
module->win, NULL, &((mca_osc_rdma_rdma_event_t){.target = peer->rank, .address = source_address, .size = size}));
721+
717722
do {
718723
ret = ompi_osc_rdma_btl_get(module, peer->data_btl_index, peer->data_endpoint,
719724
ptr, aligned_source_base, local_handle, source_handle,

0 commit comments

Comments
 (0)