Skip to content

Commit 9fd3e4e

Browse files
hjelmnhppritcha
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 e852c0e commit 9fd3e4e

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-2022 Triad National Security, LLC. All rights
3029
* reserved.
3130
* $COPYRIGHT$
@@ -461,6 +460,8 @@ typedef struct ompi_mpit_cvar_handle_t *MPI_T_cvar_handle;
461460
typedef struct mca_base_pvar_handle_t *MPI_T_pvar_handle;
462461
typedef struct mca_base_pvar_session_t *MPI_T_pvar_session;
463462
typedef struct ompi_instance_t *MPI_Session;
463+
typedef struct mca_base_raised_event_t *MPI_T_event_instance;
464+
typedef struct mca_base_event_registration_t *MPI_T_event_registration;
464465

465466
/*
466467
* MPI_Status
@@ -920,6 +921,41 @@ enum {
920921
MPI_T_PVAR_CLASS_GENERIC
921922
};
922923

924+
/*
925+
* MPIT callback safety levels
926+
*/
927+
typedef enum {
928+
MPI_T_CB_REQUIRE_NONE,
929+
MPI_T_CB_REQUIRE_MPI_RESTRICTED,
930+
MPI_T_CB_REQUIRE_THREAD_SAFE,
931+
MPI_T_CB_REQUIRE_ASYNC_SIGNAL_SAFE
932+
} MPI_T_cb_safety;
933+
934+
/*
935+
* MPIT source ordering
936+
*/
937+
enum ompi_mpi_t_order_t {
938+
MPI_T_ORDERED,
939+
MPI_T_UNORDERED,
940+
};
941+
942+
typedef enum ompi_mpi_t_order_t MPI_T_order;
943+
944+
/*
945+
* MPI Tool event functions
946+
*/
947+
typedef void (*MPI_T_event_free_cb_function) (MPI_T_event_registration handle,
948+
MPI_T_cb_safety cb_safety,
949+
void *user_data);
950+
typedef void (*MPI_T_event_dropped_cb_function) (int count,
951+
MPI_T_event_registration handle,
952+
MPI_T_cb_safety cb_safety,
953+
void *user_data);
954+
typedef void (*MPI_T_event_cb_function) (MPI_T_event_instance event,
955+
MPI_T_event_registration handle,
956+
MPI_T_cb_safety cb_safety,
957+
void *user_data);
958+
923959
/*
924960
* NULL handles
925961
*/
@@ -955,6 +991,7 @@ enum {
955991
#define MPI_T_PVAR_HANDLE_NULL ((MPI_T_pvar_handle) 0)
956992
#define MPI_T_PVAR_SESSION_NULL ((MPI_T_pvar_session) 0)
957993
#define MPI_T_CVAR_HANDLE_NULL ((MPI_T_cvar_handle) 0)
994+
#define MPI_T_EVENT_REGISTRATION_NULL ((MPI_T_event_registration) 0)
958995

959996
/* MPI-2 specifies that the name "MPI_TYPE_NULL_DELETE_FN" (and all
960997
related friends) must be accessible in C, C++, and Fortran. This is
@@ -2953,6 +2990,40 @@ OMPI_DECLSPEC int PMPI_T_enum_get_info(MPI_T_enum enumtype, int *num, char *nam
29532990
OMPI_DECLSPEC int PMPI_T_enum_get_item(MPI_T_enum enumtype, int index, int *value, char *name,
29542991
int *name_len);
29552992

2993+
OMPI_DECLSPEC int PMPI_T_event_get_num (int *num_events);
2994+
OMPI_DECLSPEC int PMPI_T_event_get_info (int event_index, char *name, int *name_len,
2995+
int *verbosity, MPI_Datatype *array_of_datatypes,
2996+
MPI_Aint *array_of_displacements, int *num_elements,
2997+
MPI_Aint *extent, MPI_T_enum *enumtype, MPI_Info *info,
2998+
char *desc, int *desc_len, int *bind);
2999+
OMPI_DECLSPEC int PMPI_T_event_get_index (const char *name, int *event_index);
3000+
OMPI_DECLSPEC int PMPI_T_event_handle_alloc (int event_index, void *obj_handle,
3001+
MPI_Info info, MPI_T_event_registration *event_registration);
3002+
OMPI_DECLSPEC int PMPI_T_event_handle_set_info (MPI_T_event_registration event_registration, MPI_Info info);
3003+
OMPI_DECLSPEC int PMPI_T_event_handle_get_info (MPI_T_event_registration event_registration,
3004+
MPI_Info *info_used);
3005+
OMPI_DECLSPEC int PMPI_T_event_register_callback (MPI_T_event_registration event_registration,
3006+
MPI_T_cb_safety cb_safety, MPI_Info info, void *user_data,
3007+
MPI_T_event_cb_function event_cb_function);
3008+
OMPI_DECLSPEC int PMPI_T_event_callback_set_info (MPI_T_event_registration event_registration,
3009+
MPI_T_cb_safety cb_safety, MPI_Info info);
3010+
OMPI_DECLSPEC int PMPI_T_event_callback_get_info (MPI_T_event_registration event_registration,
3011+
MPI_T_cb_safety cb_safety, MPI_Info *info_used);
3012+
OMPI_DECLSPEC int PMPI_T_event_handle_free (MPI_T_event_registration event_registration,
3013+
MPI_T_event_free_cb_function free_cb_function);
3014+
OMPI_DECLSPEC int PMPI_T_event_set_dropped_handler (MPI_T_event_registration handle,
3015+
MPI_T_event_dropped_cb_function dropped_cb_function);
3016+
OMPI_DECLSPEC int PMPI_T_event_read (MPI_T_event_instance event, int element_index, void *buffer);
3017+
OMPI_DECLSPEC int PMPI_T_event_copy (MPI_T_event_instance event, void *buffer);
3018+
OMPI_DECLSPEC int PMPI_T_event_get_timestamp (MPI_T_event_instance event, MPI_Count *event_time);
3019+
OMPI_DECLSPEC int PMPI_T_event_get_source (MPI_T_event_instance event, int *source_index);
3020+
OMPI_DECLSPEC int PMPI_T_source_get_num (int *num_source);
3021+
OMPI_DECLSPEC int PMPI_T_source_get_info (int source_id, char *name, int *name_len,
3022+
char *desc, int *desc_len, MPI_T_order *ordering,
3023+
MPI_Count *ticks_per_second, MPI_Count *max_timestamp,
3024+
MPI_Info *info);
3025+
OMPI_DECLSPEC int PMPI_T_source_get_timestamp (int source_id, MPI_Count *timestamp);
3026+
29563027
/*
29573028
* Tool MPI API
29583029
*/
@@ -3032,6 +3103,41 @@ OMPI_DECLSPEC int PMPI_Info_get_valuelen(MPI_Info info, const char *key, int *v
30323103
int *flag)
30333104
__mpi_interface_deprecated_in_mpi40__("PMPI_Info_get_valuelen was deprecated in MPI-4.0; use PMPI_Info_get_string instead");
30343105

3106+
OMPI_DECLSPEC int MPI_T_event_get_num (int *num_events);
3107+
OMPI_DECLSPEC int MPI_T_event_get_info (int event_index, char *name, int *name_len,
3108+
int *verbosity, MPI_Datatype *array_of_datatypes,
3109+
MPI_Aint *array_of_displacements, int *num_elements,
3110+
MPI_Aint *extent, MPI_T_enum *enumtype, MPI_Info *info,
3111+
char *desc, int *desc_len, int *bind);
3112+
OMPI_DECLSPEC int MPI_T_event_get_index (const char *name, int *event_index);
3113+
OMPI_DECLSPEC int MPI_T_event_handle_alloc (int event_index, void *obj_handle,
3114+
MPI_Info info, MPI_T_event_registration *event_registration);
3115+
OMPI_DECLSPEC int MPI_T_event_handle_set_info (MPI_T_event_registration event_registration, MPI_Info info);
3116+
OMPI_DECLSPEC int MPI_T_event_handle_get_info (MPI_T_event_registration event_registration,
3117+
MPI_Info *info_used);
3118+
OMPI_DECLSPEC int MPI_T_event_handle_free (MPI_T_event_registration event_registration,
3119+
MPI_T_event_free_cb_function free_cb_function);
3120+
OMPI_DECLSPEC int MPI_T_event_register_callback (MPI_T_event_registration event_registration,
3121+
MPI_T_cb_safety cb_safety, MPI_Info info, void *user_data,
3122+
MPI_T_event_cb_function event_cb_function);
3123+
OMPI_DECLSPEC int MPI_T_event_callback_set_info (MPI_T_event_registration event_registration,
3124+
MPI_T_cb_safety cb_safety, MPI_Info info);
3125+
OMPI_DECLSPEC int MPI_T_event_callback_get_info (MPI_T_event_registration event_registration,
3126+
MPI_T_cb_safety cb_safety, MPI_Info *info_used);
3127+
OMPI_DECLSPEC int MPI_T_event_set_dropped_handler (MPI_T_event_registration handle,
3128+
MPI_T_event_dropped_cb_function dropped_cb_function);
3129+
OMPI_DECLSPEC int MPI_T_event_read (MPI_T_event_instance event, int element_index, void *buffer);
3130+
OMPI_DECLSPEC int MPI_T_event_copy (MPI_T_event_instance event, void *buffer);
3131+
OMPI_DECLSPEC int MPI_T_event_get_timestamp (MPI_T_event_instance event, MPI_Count *event_time);
3132+
OMPI_DECLSPEC int MPI_T_event_get_source (MPI_T_event_instance event, int *source_index);
3133+
3134+
OMPI_DECLSPEC int MPI_T_source_get_num (int *num_source);
3135+
OMPI_DECLSPEC int MPI_T_source_get_info (int source_id, char *name, int *name_len,
3136+
char *desc, int *desc_len, MPI_T_order *ordering,
3137+
MPI_Count *ticks_per_second, MPI_Count *max_timestamp,
3138+
MPI_Info *info);
3139+
OMPI_DECLSPEC int MPI_T_source_get_timestamp (int source_id, MPI_Count *timestamp);
3140+
30353141
/*
30363142
* Even though MPI_Copy_function and MPI_Delete_function are
30373143
* 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
@@ -57,6 +57,34 @@
5757
#include "osc_rdma_peer.h"
5858

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

6189
#define RANK_ARRAY_COUNT(module) ((ompi_comm_size ((module)->comm) + (module)->node_count - 1) / (module)->node_count)
6290

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"
@@ -461,6 +460,9 @@ static int ompi_osc_rdma_put_real (ompi_osc_rdma_sync_t *sync, ompi_osc_rdma_pee
461460
OSC_RDMA_VERBOSE(MCA_BASE_VERBOSE_TRACE, "initiating btl put of %lu bytes to remote address %" PRIx64 ", sync "
462461
"object %p...", (unsigned long) size, target_address, (void *) sync);
463462

463+
mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_PUT_STARTED].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE,
464+
module->win, NULL, &((mca_osc_rdma_rdma_event_t){.target = peer->rank, .address = target_address, .size = size}));
465+
464466
/* flag outstanding rma requests */
465467
ompi_osc_rdma_sync_rdma_inc (sync);
466468

@@ -725,6 +727,9 @@ static int ompi_osc_rdma_get_contig (ompi_osc_rdma_sync_t *sync, ompi_osc_rdma_p
725727
ompi_osc_rdma_sync_rdma_inc (sync);
726728
}
727729

730+
mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_GET_STARTED].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE,
731+
module->win, NULL, &((mca_osc_rdma_rdma_event_t){.target = peer->rank, .address = source_address, .size = size}));
732+
728733
do {
729734
ret = ompi_osc_rdma_btl_get(module, peer->data_btl_index, peer->data_endpoint,
730735
ptr, aligned_source_base, local_handle, source_handle,

0 commit comments

Comments
 (0)