Skip to content

Commit b666434

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 ed05ee1 commit b666434

Some content is hidden

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

50 files changed

+2809
-134
lines changed

ompi/include/mpi.h.in

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
* Copyright (c) 2021 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-2019 Triad National Security, LLC. All rights
29+
* reserved.
2830
* $COPYRIGHT$
2931
*
3032
* Additional copyrights may follow
@@ -443,6 +445,8 @@ typedef struct mca_base_var_enum_t *MPI_T_enum;
443445
typedef struct ompi_mpit_cvar_handle_t *MPI_T_cvar_handle;
444446
typedef struct mca_base_pvar_handle_t *MPI_T_pvar_handle;
445447
typedef struct mca_base_pvar_session_t *MPI_T_pvar_session;
448+
typedef struct mca_base_raised_event_t *MPI_T_event_instance;
449+
typedef struct mca_base_event_registration_t *MPI_T_event_registration;
446450

447451
/*
448452
* MPI_Status
@@ -849,6 +853,41 @@ enum {
849853
MPI_T_PVAR_CLASS_GENERIC
850854
};
851855

856+
/*
857+
* MPIT callback safety levels
858+
*/
859+
typedef enum {
860+
MPI_T_CB_REQUIRE_NONE,
861+
MPI_T_CB_REQUIRE_MPI_RESTRICTED,
862+
MPI_T_CB_REQUIRE_THREAD_SAFE,
863+
MPI_T_CB_REQUIRE_ASYNC_SIGNAL_SAFE
864+
} MPI_T_cb_safety;
865+
866+
/*
867+
* MPIT source ordering
868+
*/
869+
enum ompi_mpi_t_order_t {
870+
MPI_T_ORDERED,
871+
MPI_T_UNORDERED,
872+
};
873+
874+
typedef enum ompi_mpi_t_order_t MPI_T_order;
875+
876+
/*
877+
* MPI Tool event functions
878+
*/
879+
typedef void (*MPI_T_event_free_cb_function) (MPI_T_event_registration handle,
880+
MPI_T_cb_safety cb_safety,
881+
void *user_data);
882+
typedef void (*MPI_T_event_dropped_cb_function) (int count,
883+
MPI_T_event_registration handle,
884+
MPI_T_cb_safety cb_safety,
885+
void *user_data);
886+
typedef void (*MPI_T_event_cb_function) (MPI_T_event_instance event,
887+
MPI_T_event_registration handle,
888+
MPI_T_cb_safety cb_safety,
889+
void *user_data);
890+
852891
/*
853892
* NULL handles
854893
*/
@@ -883,6 +922,7 @@ enum {
883922
#define MPI_T_PVAR_HANDLE_NULL ((MPI_T_pvar_handle) 0)
884923
#define MPI_T_PVAR_SESSION_NULL ((MPI_T_pvar_session) 0)
885924
#define MPI_T_CVAR_HANDLE_NULL ((MPI_T_cvar_handle) 0)
925+
#define MPI_T_EVENT_REGISTRATION_NULL ((MPI_T_event_registration) 0)
886926

887927
/* MPI-2 specifies that the name "MPI_TYPE_NULL_DELETE_FN" (and all
888928
related friends) must be accessible in C, C++, and Fortran. This is
@@ -2826,6 +2866,40 @@ OMPI_DECLSPEC int PMPI_T_enum_get_info(MPI_T_enum enumtype, int *num, char *nam
28262866
OMPI_DECLSPEC int PMPI_T_enum_get_item(MPI_T_enum enumtype, int index, int *value, char *name,
28272867
int *name_len);
28282868

2869+
OMPI_DECLSPEC int PMPI_T_event_get_num (int *num_events);
2870+
OMPI_DECLSPEC int PMPI_T_event_get_info (int event_index, char *name, int *name_len,
2871+
int *verbosity, MPI_Datatype *array_of_datatypes,
2872+
MPI_Aint *array_of_displacements, int *num_elements,
2873+
MPI_Aint *extent, MPI_T_enum *enumtype, MPI_Info *info,
2874+
char *desc, int *desc_len, int *bind);
2875+
OMPI_DECLSPEC int PMPI_T_event_get_index (const char *name, int *event_index);
2876+
OMPI_DECLSPEC int PMPI_T_event_handle_alloc (int event_index, void *obj_handle,
2877+
MPI_Info info, MPI_T_event_registration *event_registration);
2878+
OMPI_DECLSPEC int PMPI_T_event_handle_set_info (MPI_T_event_registration event_registration, MPI_Info info);
2879+
OMPI_DECLSPEC int PMPI_T_event_handle_get_info (MPI_T_event_registration event_registration,
2880+
MPI_Info *info_used);
2881+
OMPI_DECLSPEC int PMPI_T_event_register_callback (MPI_T_event_registration event_registration,
2882+
MPI_T_cb_safety cb_safety, MPI_Info info, void *user_data,
2883+
MPI_T_event_cb_function event_cb_function);
2884+
OMPI_DECLSPEC int PMPI_T_event_callback_set_info (MPI_T_event_registration event_registration,
2885+
MPI_T_cb_safety cb_safety, MPI_Info info);
2886+
OMPI_DECLSPEC int PMPI_T_event_callback_get_info (MPI_T_event_registration event_registration,
2887+
MPI_T_cb_safety cb_safety, MPI_Info *info_used);
2888+
OMPI_DECLSPEC int PMPI_T_event_handle_free (MPI_T_event_registration event_registration,
2889+
MPI_T_event_free_cb_function free_cb_function);
2890+
OMPI_DECLSPEC int PMPI_T_event_set_dropped_handler (MPI_T_event_registration handle,
2891+
MPI_T_event_dropped_cb_function dropped_cb_function);
2892+
OMPI_DECLSPEC int PMPI_T_event_read (MPI_T_event_instance event, int element_index, void *buffer);
2893+
OMPI_DECLSPEC int PMPI_T_event_copy (MPI_T_event_instance event, void *buffer);
2894+
OMPI_DECLSPEC int PMPI_T_event_get_timestamp (MPI_T_event_instance event, MPI_Count *event_time);
2895+
OMPI_DECLSPEC int PMPI_T_event_get_source (MPI_T_event_instance event, int *source_index);
2896+
OMPI_DECLSPEC int PMPI_T_source_get_num (int *num_source);
2897+
OMPI_DECLSPEC int PMPI_T_source_get_info (int source_id, char *name, int *name_len,
2898+
char *desc, int *desc_len, MPI_T_order *ordering,
2899+
MPI_Count *ticks_per_second, MPI_Count *max_timestamp,
2900+
MPI_Info *info);
2901+
OMPI_DECLSPEC int PMPI_T_source_get_timestamp (int source_id, MPI_Count *timestamp);
2902+
28292903
/*
28302904
* Tool MPI API
28312905
*/
@@ -2892,6 +2966,41 @@ OMPI_DECLSPEC int MPI_Attr_put(MPI_Comm comm, int keyval, void *attribute_val)
28922966
OMPI_DECLSPEC int PMPI_Attr_put(MPI_Comm comm, int keyval, void *attribute_val)
28932967
__mpi_interface_deprecated__("PMPI_Attr_put was deprecated in MPI-2.0; use PMPI_Comm_set_attr instead");
28942968

2969+
OMPI_DECLSPEC int MPI_T_event_get_num (int *num_events);
2970+
OMPI_DECLSPEC int MPI_T_event_get_info (int event_index, char *name, int *name_len,
2971+
int *verbosity, MPI_Datatype *array_of_datatypes,
2972+
MPI_Aint *array_of_displacements, int *num_elements,
2973+
MPI_Aint *extent, MPI_T_enum *enumtype, MPI_Info *info,
2974+
char *desc, int *desc_len, int *bind);
2975+
OMPI_DECLSPEC int MPI_T_event_get_index (const char *name, int *event_index);
2976+
OMPI_DECLSPEC int MPI_T_event_handle_alloc (int event_index, void *obj_handle,
2977+
MPI_Info info, MPI_T_event_registration *event_registration);
2978+
OMPI_DECLSPEC int MPI_T_event_handle_set_info (MPI_T_event_registration event_registration, MPI_Info info);
2979+
OMPI_DECLSPEC int MPI_T_event_handle_get_info (MPI_T_event_registration event_registration,
2980+
MPI_Info *info_used);
2981+
OMPI_DECLSPEC int MPI_T_event_handle_free (MPI_T_event_registration event_registration,
2982+
MPI_T_event_free_cb_function free_cb_function);
2983+
OMPI_DECLSPEC int MPI_T_event_register_callback (MPI_T_event_registration event_registration,
2984+
MPI_T_cb_safety cb_safety, MPI_Info info, void *user_data,
2985+
MPI_T_event_cb_function event_cb_function);
2986+
OMPI_DECLSPEC int MPI_T_event_callback_set_info (MPI_T_event_registration event_registration,
2987+
MPI_T_cb_safety cb_safety, MPI_Info info);
2988+
OMPI_DECLSPEC int MPI_T_event_callback_get_info (MPI_T_event_registration event_registration,
2989+
MPI_T_cb_safety cb_safety, MPI_Info *info_used);
2990+
OMPI_DECLSPEC int MPI_T_event_set_dropped_handler (MPI_T_event_registration handle,
2991+
MPI_T_event_dropped_cb_function dropped_cb_function);
2992+
OMPI_DECLSPEC int MPI_T_event_read (MPI_T_event_instance event, int element_index, void *buffer);
2993+
OMPI_DECLSPEC int MPI_T_event_copy (MPI_T_event_instance event, void *buffer);
2994+
OMPI_DECLSPEC int MPI_T_event_get_timestamp (MPI_T_event_instance event, MPI_Count *event_time);
2995+
OMPI_DECLSPEC int MPI_T_event_get_source (MPI_T_event_instance event, int *source_index);
2996+
2997+
OMPI_DECLSPEC int MPI_T_source_get_num (int *num_source);
2998+
OMPI_DECLSPEC int MPI_T_source_get_info (int source_id, char *name, int *name_len,
2999+
char *desc, int *desc_len, MPI_T_order *ordering,
3000+
MPI_Count *ticks_per_second, MPI_Count *max_timestamp,
3001+
MPI_Info *info);
3002+
OMPI_DECLSPEC int MPI_T_source_get_timestamp (int source_id, MPI_Count *timestamp);
3003+
28953004
/*
28963005
* Even though MPI_Copy_function and MPI_Delete_function are
28973006
* 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
@@ -52,6 +52,34 @@
5252
#include "osc_rdma_peer.h"
5353

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

5684
#define RANK_ARRAY_COUNT(module) ((ompi_comm_size ((module)->comm) + (module)->node_count - 1) / (module)->node_count)
5785

ompi/mca/osc/rdma/osc_rdma_active_target.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,8 @@ static void ompi_osc_rdma_handle_post (ompi_osc_rdma_module_t *module, int rank,
209209
rank, (int) (npeers - state->num_post_msgs - 1));
210210
/* an atomic is not really necessary as this function is currently used but it doesn't hurt */
211211
ompi_osc_rdma_counter_add (&state->num_post_msgs, 1);
212+
mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_PSCW_ACCESS_START].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE,
213+
module->win, NULL, &rank);
212214
return;
213215
}
214216
}
@@ -334,6 +336,9 @@ int ompi_osc_rdma_post_atomic (ompi_group_t *group, int mpi_assert, ompi_win_t *
334336
return OMPI_SUCCESS;
335337
}
336338

339+
mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_PSCW_EXPOSE_START].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE,
340+
module->win, NULL, NULL);
341+
337342
/* translate group ranks into the communicator */
338343
peers = ompi_osc_rdma_get_peers (module, module->pw_group);
339344
if (OPAL_UNLIKELY(NULL == peers)) {
@@ -421,6 +426,8 @@ int ompi_osc_rdma_start_atomic (ompi_group_t *group, int mpi_assert, ompi_win_t
421426
"from %d processes", peer->rank, (int) (group_size - state->num_post_msgs - 1));
422427
opal_list_remove_item (&module->pending_posts, &pending_post->super);
423428
OBJ_RELEASE(pending_post);
429+
mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_PSCW_ACCESS_START].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE,
430+
module->win, NULL, &peer->rank);
424431
ompi_osc_rdma_counter_add (&state->num_post_msgs, 1);
425432
break;
426433
}
@@ -491,6 +498,9 @@ int ompi_osc_rdma_complete_atomic (ompi_win_t *win)
491498
ompi_osc_rdma_peer_t *peer = peers[i];
492499
intptr_t target = (intptr_t) peer->state + offsetof (ompi_osc_rdma_state_t, num_complete_msgs);
493500

501+
mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_PSCW_ACCESS_COMPLETE].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE,
502+
module->win, NULL, &peer->rank);
503+
494504
if (!ompi_osc_rdma_peer_local_state (peer)) {
495505
ret = ompi_osc_rdma_lock_btl_op (module, peer, target, MCA_BTL_ATOMIC_ADD, 1, true);
496506
assert (OMPI_SUCCESS == ret);
@@ -534,6 +544,9 @@ int ompi_osc_rdma_wait_atomic (ompi_win_t *win)
534544
opal_atomic_mb ();
535545
}
536546

547+
mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_PSCW_EXPOSE_COMPLETE].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE,
548+
module->win, NULL, NULL);
549+
537550
OPAL_THREAD_LOCK(&module->lock);
538551
group = module->pw_group;
539552
module->pw_group = NULL;
@@ -583,6 +596,9 @@ int ompi_osc_rdma_test_atomic (ompi_win_t *win, int *flag)
583596
module->pw_group = NULL;
584597
OPAL_THREAD_UNLOCK(&(module->lock));
585598

599+
mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_PSCW_EXPOSE_COMPLETE].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE,
600+
module->win, NULL, NULL);
601+
586602
OBJ_RELEASE(group);
587603

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

ompi/mca/osc/rdma/osc_rdma_comm.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* $HEADER$
1414
*/
1515

16+
#include "osc_rdma.h"
1617
#include "osc_rdma_comm.h"
1718
#include "osc_rdma_sync.h"
1819
#include "osc_rdma_request.h"
@@ -450,6 +451,9 @@ static int ompi_osc_rdma_put_real (ompi_osc_rdma_sync_t *sync, ompi_osc_rdma_pee
450451
OSC_RDMA_VERBOSE(MCA_BASE_VERBOSE_TRACE, "initiating btl put of %lu bytes to remote address %" PRIx64 ", sync "
451452
"object %p...", (unsigned long) size, target_address, (void *) sync);
452453

454+
mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_PUT_STARTED].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE,
455+
module->win, NULL, &((mca_osc_rdma_rdma_event_t){.target = peer->rank, .address = target_address, .size = size}));
456+
453457
/* flag outstanding rma requests */
454458
ompi_osc_rdma_sync_rdma_inc (sync);
455459

@@ -702,6 +706,9 @@ static int ompi_osc_rdma_get_contig (ompi_osc_rdma_sync_t *sync, ompi_osc_rdma_p
702706
ompi_osc_rdma_sync_rdma_inc (sync);
703707
}
704708

709+
mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_GET_STARTED].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE,
710+
module->win, NULL, &((mca_osc_rdma_rdma_event_t){.target = peer->rank, .address = source_address, .size = size}));
711+
705712
do {
706713
ret = btl->btl_get (btl, peer->data_endpoint, ptr,
707714
aligned_source_base, local_handle, source_handle,

0 commit comments

Comments
 (0)