Skip to content

Commit 1d73fcd

Browse files
hjelmncchambreau
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 1b0dfcd commit 1d73fcd

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

+2802
-135
lines changed

ompi/include/mpi.h.in

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
* and Technology (RIST). All rights reserved.
2222
* Copyright (c) 2017-2019 IBM Corporation. All rights reserved.
2323
* Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
24+
* Copyright (c) 2018-2019 Triad National Security, LLC. All rights
25+
* reserved.
2426
* $COPYRIGHT$
2527
*
2628
* Additional copyrights may follow
@@ -417,6 +419,8 @@ typedef struct mca_base_var_enum_t *MPI_T_enum;
417419
typedef struct ompi_mpit_cvar_handle_t *MPI_T_cvar_handle;
418420
typedef struct mca_base_pvar_handle_t *MPI_T_pvar_handle;
419421
typedef struct mca_base_pvar_session_t *MPI_T_pvar_session;
422+
typedef struct mca_base_raised_event_t *MPI_T_event_instance;
423+
typedef struct mca_base_event_registration_t *MPI_T_event_registration;
420424

421425
/*
422426
* MPI_Status
@@ -814,6 +818,41 @@ enum {
814818
MPI_T_PVAR_CLASS_GENERIC
815819
};
816820

821+
/*
822+
* MPIT callback safety levels
823+
*/
824+
typedef enum {
825+
MPI_T_CB_REQUIRE_NONE,
826+
MPI_T_CB_REQUIRE_MPI_RESTRICTED,
827+
MPI_T_CB_REQUIRE_THREAD_SAFE,
828+
MPI_T_CB_REQUIRE_ASYNC_SIGNAL_SAFE
829+
} MPI_T_cb_safety;
830+
831+
/*
832+
* MPIT source ordering
833+
*/
834+
enum ompi_mpi_t_order_t {
835+
MPI_T_ORDERED,
836+
MPI_T_UNORDERED,
837+
};
838+
839+
typedef enum ompi_mpi_t_order_t MPI_T_order;
840+
841+
/*
842+
* MPI Tool event functions
843+
*/
844+
typedef void (*MPI_T_event_free_cb_function) (MPI_T_event_registration handle,
845+
MPI_T_cb_safety cb_safety,
846+
void *user_data);
847+
typedef void (*MPI_T_event_dropped_cb_function) (int count,
848+
MPI_T_event_registration handle,
849+
MPI_T_cb_safety cb_safety,
850+
void *user_data);
851+
typedef void (*MPI_T_event_cb_function) (MPI_T_event_instance event,
852+
MPI_T_event_registration handle,
853+
MPI_T_cb_safety cb_safety,
854+
void *user_data);
855+
817856
/*
818857
* NULL handles
819858
*/
@@ -848,6 +887,7 @@ enum {
848887
#define MPI_T_PVAR_HANDLE_NULL ((MPI_T_pvar_handle) 0)
849888
#define MPI_T_PVAR_SESSION_NULL ((MPI_T_pvar_session) 0)
850889
#define MPI_T_CVAR_HANDLE_NULL ((MPI_T_cvar_handle) 0)
890+
#define MPI_T_EVENT_REGISTRATION_NULL ((MPI_T_event_registration) 0)
851891

852892
/* MPI-2 specifies that the name "MPI_TYPE_NULL_DELETE_FN" (and all
853893
related friends) must be accessible in C, C++, and Fortran. This is
@@ -2650,6 +2690,40 @@ OMPI_DECLSPEC int PMPI_T_enum_get_info(MPI_T_enum enumtype, int *num, char *nam
26502690
OMPI_DECLSPEC int PMPI_T_enum_get_item(MPI_T_enum enumtype, int index, int *value, char *name,
26512691
int *name_len);
26522692

2693+
OMPI_DECLSPEC int PMPI_T_event_get_num (int *num_events);
2694+
OMPI_DECLSPEC int PMPI_T_event_get_info (int event_index, char *name, int *name_len,
2695+
int *verbosity, MPI_Datatype *array_of_datatypes,
2696+
MPI_Aint *array_of_displacements, int *num_elements,
2697+
MPI_Aint *extent, MPI_T_enum *enumtype, MPI_Info *info,
2698+
char *desc, int *desc_len, int *bind);
2699+
OMPI_DECLSPEC int PMPI_T_event_get_index (const char *name, int *event_index);
2700+
OMPI_DECLSPEC int PMPI_T_event_handle_alloc (int event_index, void *obj_handle,
2701+
MPI_Info info, MPI_T_event_registration *event_registration);
2702+
OMPI_DECLSPEC int PMPI_T_event_handle_set_info (MPI_T_event_registration event_registration, MPI_Info info);
2703+
OMPI_DECLSPEC int PMPI_T_event_handle_get_info (MPI_T_event_registration event_registration,
2704+
MPI_Info *info_used);
2705+
OMPI_DECLSPEC int PMPI_T_event_register_callback (MPI_T_event_registration event_registration,
2706+
MPI_T_cb_safety cb_safety, MPI_Info info, void *user_data,
2707+
MPI_T_event_cb_function event_cb_function);
2708+
OMPI_DECLSPEC int PMPI_T_event_callback_set_info (MPI_T_event_registration event_registration,
2709+
MPI_T_cb_safety cb_safety, MPI_Info info);
2710+
OMPI_DECLSPEC int PMPI_T_event_callback_get_info (MPI_T_event_registration event_registration,
2711+
MPI_T_cb_safety cb_safety, MPI_Info *info_used);
2712+
OMPI_DECLSPEC int PMPI_T_event_handle_free (MPI_T_event_registration event_registration,
2713+
MPI_T_event_free_cb_function free_cb_function);
2714+
OMPI_DECLSPEC int PMPI_T_event_set_dropped_handler (MPI_T_event_registration handle,
2715+
MPI_T_event_dropped_cb_function dropped_cb_function);
2716+
OMPI_DECLSPEC int PMPI_T_event_read (MPI_T_event_instance event, int element_index, void *buffer);
2717+
OMPI_DECLSPEC int PMPI_T_event_copy (MPI_T_event_instance event, void *buffer);
2718+
OMPI_DECLSPEC int PMPI_T_event_get_timestamp (MPI_T_event_instance event, MPI_Count *event_time);
2719+
OMPI_DECLSPEC int PMPI_T_event_get_source (MPI_T_event_instance event, int *source_index);
2720+
OMPI_DECLSPEC int PMPI_T_source_get_num (int *num_source);
2721+
OMPI_DECLSPEC int PMPI_T_source_get_info (int source_id, char *name, int *name_len,
2722+
char *desc, int *desc_len, MPI_T_order *ordering,
2723+
MPI_Count *ticks_per_second, MPI_Count *max_timestamp,
2724+
MPI_Info *info);
2725+
OMPI_DECLSPEC int PMPI_T_source_get_timestamp (int source_id, MPI_Count *timestamp);
2726+
26532727
/*
26542728
* Tool MPI API
26552729
*/
@@ -2716,6 +2790,41 @@ OMPI_DECLSPEC int MPI_Attr_put(MPI_Comm comm, int keyval, void *attribute_val)
27162790
OMPI_DECLSPEC int PMPI_Attr_put(MPI_Comm comm, int keyval, void *attribute_val)
27172791
__mpi_interface_deprecated__("PMPI_Attr_put was deprecated in MPI-2.0; use PMPI_Comm_set_attr instead");
27182792

2793+
OMPI_DECLSPEC int MPI_T_event_get_num (int *num_events);
2794+
OMPI_DECLSPEC int MPI_T_event_get_info (int event_index, char *name, int *name_len,
2795+
int *verbosity, MPI_Datatype *array_of_datatypes,
2796+
MPI_Aint *array_of_displacements, int *num_elements,
2797+
MPI_Aint *extent, MPI_T_enum *enumtype, MPI_Info *info,
2798+
char *desc, int *desc_len, int *bind);
2799+
OMPI_DECLSPEC int MPI_T_event_get_index (const char *name, int *event_index);
2800+
OMPI_DECLSPEC int MPI_T_event_handle_alloc (int event_index, void *obj_handle,
2801+
MPI_Info info, MPI_T_event_registration *event_registration);
2802+
OMPI_DECLSPEC int MPI_T_event_handle_set_info (MPI_T_event_registration event_registration, MPI_Info info);
2803+
OMPI_DECLSPEC int MPI_T_event_handle_get_info (MPI_T_event_registration event_registration,
2804+
MPI_Info *info_used);
2805+
OMPI_DECLSPEC int MPI_T_event_handle_free (MPI_T_event_registration event_registration,
2806+
MPI_T_event_free_cb_function free_cb_function);
2807+
OMPI_DECLSPEC int MPI_T_event_register_callback (MPI_T_event_registration event_registration,
2808+
MPI_T_cb_safety cb_safety, MPI_Info info, void *user_data,
2809+
MPI_T_event_cb_function event_cb_function);
2810+
OMPI_DECLSPEC int MPI_T_event_callback_set_info (MPI_T_event_registration event_registration,
2811+
MPI_T_cb_safety cb_safety, MPI_Info info);
2812+
OMPI_DECLSPEC int MPI_T_event_callback_get_info (MPI_T_event_registration event_registration,
2813+
MPI_T_cb_safety cb_safety, MPI_Info *info_used);
2814+
OMPI_DECLSPEC int MPI_T_event_set_dropped_handler (MPI_T_event_registration handle,
2815+
MPI_T_event_dropped_cb_function dropped_cb_function);
2816+
OMPI_DECLSPEC int MPI_T_event_read (MPI_T_event_instance event, int element_index, void *buffer);
2817+
OMPI_DECLSPEC int MPI_T_event_copy (MPI_T_event_instance event, void *buffer);
2818+
OMPI_DECLSPEC int MPI_T_event_get_timestamp (MPI_T_event_instance event, MPI_Count *event_time);
2819+
OMPI_DECLSPEC int MPI_T_event_get_source (MPI_T_event_instance event, int *source_index);
2820+
2821+
OMPI_DECLSPEC int MPI_T_source_get_num (int *num_source);
2822+
OMPI_DECLSPEC int MPI_T_source_get_info (int source_id, char *name, int *name_len,
2823+
char *desc, int *desc_len, MPI_T_order *ordering,
2824+
MPI_Count *ticks_per_second, MPI_Count *max_timestamp,
2825+
MPI_Info *info);
2826+
OMPI_DECLSPEC int MPI_T_source_get_timestamp (int source_id, MPI_Count *timestamp);
2827+
27192828
/*
27202829
* Even though MPI_Copy_function and MPI_Delete_function are
27212830
* 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
@@ -50,6 +50,34 @@
5050
#include "osc_rdma_peer.h"
5151

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

5482
#define RANK_ARRAY_COUNT(module) ((ompi_comm_size ((module)->comm) + (module)->node_count - 1) / (module)->node_count)
5583

ompi/mca/osc/rdma/osc_rdma_active_target.c

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

338+
mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_PSCW_EXPOSE_START].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE,
339+
module->win, NULL, NULL);
340+
336341
/* translate group ranks into the communicator */
337342
peers = ompi_osc_rdma_get_peers (module, module->pw_group);
338343
if (OPAL_UNLIKELY(NULL == peers)) {
@@ -419,6 +424,8 @@ int ompi_osc_rdma_start_atomic (ompi_group_t *group, int assert, ompi_win_t *win
419424
"from %d processes", peer->rank, (int) (group_size - state->num_post_msgs - 1));
420425
opal_list_remove_item (&module->pending_posts, &pending_post->super);
421426
OBJ_RELEASE(pending_post);
427+
mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_PSCW_ACCESS_START].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE,
428+
module->win, NULL, &peer->rank);
422429
ompi_osc_rdma_counter_add (&state->num_post_msgs, 1);
423430
break;
424431
}
@@ -487,6 +494,9 @@ int ompi_osc_rdma_complete_atomic (ompi_win_t *win)
487494
ompi_osc_rdma_peer_t *peer = peers[i];
488495
intptr_t target = (intptr_t) peer->state + offsetof (ompi_osc_rdma_state_t, num_complete_msgs);
489496

497+
mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_PSCW_ACCESS_COMPLETE].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE,
498+
module->win, NULL, &peer->rank);
499+
490500
if (!ompi_osc_rdma_peer_local_state (peer)) {
491501
ret = ompi_osc_rdma_lock_btl_op (module, peer, target, MCA_BTL_ATOMIC_ADD, 1, true);
492502
assert (OMPI_SUCCESS == ret);
@@ -530,6 +540,9 @@ int ompi_osc_rdma_wait_atomic (ompi_win_t *win)
530540
opal_atomic_mb ();
531541
}
532542

543+
mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_PSCW_EXPOSE_COMPLETE].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE,
544+
module->win, NULL, NULL);
545+
533546
OPAL_THREAD_LOCK(&module->lock);
534547
group = module->pw_group;
535548
module->pw_group = NULL;
@@ -579,6 +592,9 @@ int ompi_osc_rdma_test_atomic (ompi_win_t *win, int *flag)
579592
module->pw_group = NULL;
580593
OPAL_THREAD_UNLOCK(&(module->lock));
581594

595+
mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_PSCW_EXPOSE_COMPLETE].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE,
596+
module->win, NULL, NULL);
597+
582598
OBJ_RELEASE(group);
583599

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

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

@@ -698,6 +702,9 @@ static int ompi_osc_rdma_get_contig (ompi_osc_rdma_sync_t *sync, ompi_osc_rdma_p
698702
ompi_osc_rdma_sync_rdma_inc (sync);
699703
}
700704

705+
mca_base_event_raise(mca_osc_rdma_events[OMPI_OSC_RDMA_EVENT_GET_STARTED].event, MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE,
706+
module->win, NULL, &((mca_osc_rdma_rdma_event_t){.target = peer->rank, .address = source_address, .size = size}));
707+
701708
do {
702709
ret = module->selected_btl->btl_get (module->selected_btl, peer->data_endpoint, ptr,
703710
aligned_source_base, local_handle, source_handle,

0 commit comments

Comments
 (0)