Skip to content

Commit 782deaa

Browse files
committed
MPI_T: provide a stub implementation of events
man pages will be added in a separate PR. Signed-off-by: Howard Pritchard <[email protected]>
1 parent e852c0e commit 782deaa

21 files changed

+792
-3
lines changed

configure.ac

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,12 @@ AC_MSG_CHECKING([for bootstrap Libtool version])
190190
ltversion=`grep VERSION= $srcdir/config/ltmain.sh | head -n 1 | cut -d= -f2`
191191
AC_MSG_RESULT([$ltversion])
192192

193+
# Ensure mpi.h.in and mca_base_event.h have consistent callback safety values
194+
AC_DEFINE_UNQUOTED([OPAL_MCA_BASE_CB_REQUIRE_NONE], [0], [Keeping OPAL and OMPI values in sync])
195+
AC_DEFINE_UNQUOTED([OPAL_MCA_BASE_CB_REQUIRE_MPI_RESTRICTED], [1], [Keeping OPAL and OMPI values in sync])
196+
AC_DEFINE_UNQUOTED([OPAL_MCA_BASE_CB_REQUIRE_THREAD_SAFE], [2], [Keeping OPAL and OMPI values in sync])
197+
AC_DEFINE_UNQUOTED([OPAL_MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE], [3], [Keeping OPAL and OMPI values in sync])
198+
193199
# List header files to generate
194200

195201
AC_CONFIG_HEADERS([opal/include/opal_config.h])
@@ -1399,6 +1405,7 @@ if test $ac_cv_header_sys_synch_h = yes ; then
13991405
[Do not use outside of mpi.h. Define to 1 if you have the <sys/synch.h> header file.])
14001406
fi
14011407
1408+
14021409
# If there is a local hook for each project, call it. This allows 3rd
14031410
# parties to add configuration steps to OPAL and/or OMPI simply
14041411
# by placing a file in [opal|ompi]/config/whatever.m4 that

ompi/include/mpi.h.in

Lines changed: 116 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 unsigned long *MPI_T_event_instance;
464+
typedef unsigned long *MPI_T_event_registration;
464465

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

924+
/*
925+
* MPIT callback safety levels
926+
*
927+
* Values are set in configure.ac for consistency with mca_base_event.h
928+
*/
929+
#undef OPAL_MCA_BASE_CB_REQUIRE_NONE
930+
#undef OPAL_MCA_BASE_CB_REQUIRE_MPI_RESTRICTED
931+
#undef OPAL_MCA_BASE_CB_REQUIRE_THREAD_SAFE
932+
#undef OPAL_MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE
933+
typedef enum {
934+
MPI_T_CB_REQUIRE_NONE = OPAL_MCA_BASE_CB_REQUIRE_NONE,
935+
MPI_T_CB_REQUIRE_MPI_RESTRICTED = OPAL_MCA_BASE_CB_REQUIRE_MPI_RESTRICTED,
936+
MPI_T_CB_REQUIRE_THREAD_SAFE = OPAL_MCA_BASE_CB_REQUIRE_THREAD_SAFE,
937+
MPI_T_CB_REQUIRE_ASYNC_SIGNAL_SAFE = OPAL_MCA_BASE_CB_REQUIRE_ASYNC_SIGNAL_SAFE
938+
} MPI_T_cb_safety;
939+
940+
/*
941+
* MPIT source ordering
942+
*/
943+
enum ompi_mpi_t_source_order_t {
944+
MPI_T_ORDERED,
945+
MPI_T_UNORDERED,
946+
};
947+
948+
typedef enum ompi_mpi_t_source_order_t MPI_T_source_order;
949+
950+
/*
951+
* MPI Tool event functions
952+
*/
953+
typedef void (*MPI_T_event_free_cb_function) (MPI_T_event_registration handle,
954+
MPI_T_cb_safety cb_safety,
955+
void *user_data);
956+
typedef void (*MPI_T_event_dropped_cb_function) (MPI_Count count,
957+
MPI_T_event_registration handle,
958+
int source_index,
959+
MPI_T_cb_safety cb_safety,
960+
void *user_data);
961+
typedef void (*MPI_T_event_cb_function) (MPI_T_event_instance event,
962+
MPI_T_event_registration handle,
963+
MPI_T_cb_safety cb_safety,
964+
void *user_data);
965+
923966
/*
924967
* NULL handles
925968
*/
@@ -955,6 +998,7 @@ enum {
955998
#define MPI_T_PVAR_HANDLE_NULL ((MPI_T_pvar_handle) 0)
956999
#define MPI_T_PVAR_SESSION_NULL ((MPI_T_pvar_session) 0)
9571000
#define MPI_T_CVAR_HANDLE_NULL ((MPI_T_cvar_handle) 0)
1001+
#define MPI_T_EVENT_REGISTRATION_NULL ((MPI_T_event_registration) 0)
9581002

9591003
/* MPI-2 specifies that the name "MPI_TYPE_NULL_DELETE_FN" (and all
9601004
related friends) must be accessible in C, C++, and Fortran. This is
@@ -2953,6 +2997,41 @@ OMPI_DECLSPEC int PMPI_T_enum_get_info(MPI_T_enum enumtype, int *num, char *nam
29532997
OMPI_DECLSPEC int PMPI_T_enum_get_item(MPI_T_enum enumtype, int index, int *value, char *name,
29542998
int *name_len);
29552999

3000+
OMPI_DECLSPEC int PMPI_T_event_get_num (int *num_events);
3001+
OMPI_DECLSPEC int PMPI_T_event_get_info (int event_index, char *name, int *name_len,
3002+
int *verbosity, MPI_Datatype *array_of_datatypes,
3003+
MPI_Aint *array_of_displacements, int *num_elements,
3004+
MPI_T_enum *enumtype, MPI_Info *info,
3005+
char *desc, int *desc_len, int *bind);
3006+
OMPI_DECLSPEC int PMPI_T_event_get_index (const char *name, int *event_index);
3007+
OMPI_DECLSPEC int PMPI_T_event_handle_alloc (int event_index, void *obj_handle,
3008+
MPI_Info info, MPI_T_event_registration *event_registration);
3009+
OMPI_DECLSPEC int PMPI_T_event_handle_set_info (MPI_T_event_registration event_registration, MPI_Info info);
3010+
OMPI_DECLSPEC int PMPI_T_event_handle_get_info (MPI_T_event_registration event_registration,
3011+
MPI_Info *info_used);
3012+
OMPI_DECLSPEC int PMPI_T_event_register_callback (MPI_T_event_registration event_registration,
3013+
MPI_T_cb_safety cb_safety, MPI_Info info, void *user_data,
3014+
MPI_T_event_cb_function event_cb_function);
3015+
OMPI_DECLSPEC int PMPI_T_event_callback_set_info (MPI_T_event_registration event_registration,
3016+
MPI_T_cb_safety cb_safety, MPI_Info info);
3017+
OMPI_DECLSPEC int PMPI_T_event_callback_get_info (MPI_T_event_registration event_registration,
3018+
MPI_T_cb_safety cb_safety, MPI_Info *info_used);
3019+
OMPI_DECLSPEC int PMPI_T_event_handle_free (MPI_T_event_registration event_registration,
3020+
void *user_data,
3021+
MPI_T_event_free_cb_function free_cb_function);
3022+
OMPI_DECLSPEC int PMPI_T_event_set_dropped_handler (MPI_T_event_registration handle,
3023+
MPI_T_event_dropped_cb_function dropped_cb_function);
3024+
OMPI_DECLSPEC int PMPI_T_event_read (MPI_T_event_instance event, int element_index, void *buffer);
3025+
OMPI_DECLSPEC int PMPI_T_event_copy (MPI_T_event_instance event, void *buffer);
3026+
OMPI_DECLSPEC int PMPI_T_event_get_timestamp (MPI_T_event_instance event, MPI_Count *event_time);
3027+
OMPI_DECLSPEC int PMPI_T_event_get_source (MPI_T_event_instance event, int *source_index);
3028+
OMPI_DECLSPEC int PMPI_T_source_get_num (int *num_source);
3029+
OMPI_DECLSPEC int PMPI_T_source_get_info (int source_id, char *name, int *name_len,
3030+
char *desc, int *desc_len, MPI_T_source_order *ordering,
3031+
MPI_Count *ticks_per_second, MPI_Count *max_timestamp,
3032+
MPI_Info *info);
3033+
OMPI_DECLSPEC int PMPI_T_source_get_timestamp (int source_id, MPI_Count *timestamp);
3034+
29563035
/*
29573036
* Tool MPI API
29583037
*/
@@ -3032,6 +3111,42 @@ OMPI_DECLSPEC int PMPI_Info_get_valuelen(MPI_Info info, const char *key, int *v
30323111
int *flag)
30333112
__mpi_interface_deprecated_in_mpi40__("PMPI_Info_get_valuelen was deprecated in MPI-4.0; use PMPI_Info_get_string instead");
30343113

3114+
OMPI_DECLSPEC int MPI_T_event_get_num (int *num_events);
3115+
OMPI_DECLSPEC int MPI_T_event_get_info (int event_index, char *name, int *name_len,
3116+
int *verbosity, MPI_Datatype *array_of_datatypes,
3117+
MPI_Aint *array_of_displacements, int *num_elements,
3118+
MPI_T_enum *enumtype, MPI_Info *info,
3119+
char *desc, int *desc_len, int *bind);
3120+
OMPI_DECLSPEC int MPI_T_event_get_index (const char *name, int *event_index);
3121+
OMPI_DECLSPEC int MPI_T_event_handle_alloc (int event_index, void *obj_handle,
3122+
MPI_Info info, MPI_T_event_registration *event_registration);
3123+
OMPI_DECLSPEC int MPI_T_event_handle_set_info (MPI_T_event_registration event_registration, MPI_Info info);
3124+
OMPI_DECLSPEC int MPI_T_event_handle_get_info (MPI_T_event_registration event_registration,
3125+
MPI_Info *info_used);
3126+
OMPI_DECLSPEC int MPI_T_event_handle_free (MPI_T_event_registration event_registration,
3127+
void *user_data,
3128+
MPI_T_event_free_cb_function free_cb_function);
3129+
OMPI_DECLSPEC int MPI_T_event_register_callback (MPI_T_event_registration event_registration,
3130+
MPI_T_cb_safety cb_safety, MPI_Info info, void *user_data,
3131+
MPI_T_event_cb_function event_cb_function);
3132+
OMPI_DECLSPEC int MPI_T_event_callback_set_info (MPI_T_event_registration event_registration,
3133+
MPI_T_cb_safety cb_safety, MPI_Info info);
3134+
OMPI_DECLSPEC int MPI_T_event_callback_get_info (MPI_T_event_registration event_registration,
3135+
MPI_T_cb_safety cb_safety, MPI_Info *info_used);
3136+
OMPI_DECLSPEC int MPI_T_event_set_dropped_handler (MPI_T_event_registration handle,
3137+
MPI_T_event_dropped_cb_function dropped_cb_function);
3138+
OMPI_DECLSPEC int MPI_T_event_read (MPI_T_event_instance event, int element_index, void *buffer);
3139+
OMPI_DECLSPEC int MPI_T_event_copy (MPI_T_event_instance event, void *buffer);
3140+
OMPI_DECLSPEC int MPI_T_event_get_timestamp (MPI_T_event_instance event, MPI_Count *event_time);
3141+
OMPI_DECLSPEC int MPI_T_event_get_source (MPI_T_event_instance event, int *source_index);
3142+
3143+
OMPI_DECLSPEC int MPI_T_source_get_num (int *num_source);
3144+
OMPI_DECLSPEC int MPI_T_source_get_info (int source_id, char *name, int *name_len,
3145+
char *desc, int *desc_len, MPI_T_source_order *ordering,
3146+
MPI_Count *ticks_per_second, MPI_Count *max_timestamp,
3147+
MPI_Info *info);
3148+
OMPI_DECLSPEC int MPI_T_source_get_timestamp (int source_id, MPI_Count *timestamp);
3149+
30353150
/*
30363151
* Even though MPI_Copy_function and MPI_Delete_function are
30373152
* deprecated, we do not use the attributes marking them as such,

ompi/mpi/tool/Makefile.am

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
# reserved.
55
# Copyright (c) 2004-2006 High Performance Computing Center Stuttgart,
66
# University of Stuttgart. All rights reserved.
7-
# Copyright (c) 2012-2014 Los Alamos National Security, LLC. All rights
7+
# Copyright (c) 2012-2018 Los Alamos National Security, LLC. All rights
8+
# reserved.
9+
# Copyright (c) 2018-2025 Triad National Security, LLC. All rightsa
810
# reserved.
911
# Copyright (c) 2021 Amazon.com, Inc. or its affiliates. All Rights
1012
# reserved.
@@ -65,6 +67,21 @@ interface_profile_sources = \
6567
cvar_write.c \
6668
enum_get_info.c \
6769
enum_get_item.c \
70+
event_get_index.c \
71+
event_copy.c \
72+
event_callback_get_info.c \
73+
event_callback_set_info.c \
74+
event_handle_get_info.c \
75+
event_handle_set_info.c \
76+
event_get_info.c \
77+
event_get_num.c \
78+
event_get_source.c \
79+
event_get_timestamp.c \
80+
event_handle_alloc.c \
81+
event_handle_free.c \
82+
event_read.c \
83+
event_register_callback.c \
84+
event_set_dropped_handler.c \
6885
finalize.c \
6986
init_thread.c \
7087
pvar_get_info.c \
@@ -79,7 +96,10 @@ interface_profile_sources = \
7996
pvar_session_free.c \
8097
pvar_start.c \
8198
pvar_stop.c \
82-
pvar_write.c
99+
pvar_write.c \
100+
source_get_num.c \
101+
source_get_info.c \
102+
source_get_timestamp.c
83103

84104
libmpi_mpit_profile_la_SOURCES = $(interface_profile_sources)
85105
libmpi_mpit_profile_la_CPPFLAGS = -DOMPI_BUILD_MPI_PROFILING=1
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
2+
/*
3+
* Copyright (c) 2012-2018 Los Alamos National Security, LLC. All rights
4+
* reserved.
5+
* Copyright (c) 2014 Cisco Systems, Inc. All rights reserved.
6+
* Copyright (c) 2017 IBM Corporation. All rights reserved.
7+
* Copyright (c) 2019 Google, LLC. All rights reserved.
8+
* Copyright (c) 2019-2025 Triad National Security, LLC. All rights
9+
* reserved.
10+
* $COPYRIGHT$
11+
*
12+
* Additional copyrights may follow
13+
*
14+
* $HEADER$
15+
*/
16+
17+
18+
#include "ompi_config.h"
19+
#include "ompi/mpi/tool/mpit-internal.h"
20+
21+
#if OMPI_BUILD_MPI_PROFILING
22+
#if OPAL_HAVE_WEAK_SYMBOLS
23+
#pragma weak MPI_T_event_callback_get_info = PMPI_T_event_callback_get_info
24+
#endif
25+
#define MPI_T_event_callback_get_info PMPI_T_event_callback_get_info
26+
#endif
27+
28+
29+
int MPI_T_event_callback_get_info (MPI_T_event_registration event_registration,
30+
MPI_T_cb_safety cb_safety, MPI_Info *info_used)
31+
{
32+
if (!mpit_is_initialized ()) {
33+
return MPI_T_ERR_NOT_INITIALIZED;
34+
}
35+
36+
return MPI_T_ERR_INVALID_HANDLE;
37+
}
38+
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
2+
/*
3+
* Copyright (c) 2012-2018 Los Alamos National Security, LLC. All rights
4+
* reserved.
5+
* Copyright (c) 2014 Cisco Systems, Inc. All rights reserved.
6+
* Copyright (c) 2017 IBM Corporation. All rights reserved.
7+
* Copyright (c) 2019 Google, LLC. All rights reserved.
8+
* Copyright (c) 2019-2025 Triad National Security, LLC. All rights
9+
* reserved.
10+
* $COPYRIGHT$
11+
*
12+
* Additional copyrights may follow
13+
*
14+
* $HEADER$
15+
*/
16+
17+
#include "ompi_config.h"
18+
19+
#include "ompi/mpi/tool/mpit-internal.h"
20+
21+
#if OMPI_BUILD_MPI_PROFILING
22+
#if OPAL_HAVE_WEAK_SYMBOLS
23+
#pragma weak MPI_T_event_callback_set_info = PMPI_T_event_callback_set_info
24+
#endif
25+
#define MPI_T_event_callback_set_info PMPI_T_event_callback_set_info
26+
#endif
27+
28+
int MPI_T_event_callback_set_info (MPI_T_event_registration event_registration,
29+
MPI_T_cb_safety cb_safety, MPI_Info info)
30+
{
31+
if (!mpit_is_initialized ()) {
32+
return MPI_T_ERR_NOT_INITIALIZED;
33+
}
34+
35+
return MPI_T_ERR_INVALID_HANDLE;
36+
}

ompi/mpi/tool/event_copy.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
2+
/*
3+
* Copyright (c) 2012-2018 Los Alamos National Security, LLC. All rights
4+
* reserved.
5+
* Copyright (c) 2014 Cisco Systems, Inc. All rights reserved.
6+
* Copyright (c) 2017 IBM Corporation. All rights reserved.
7+
* Copyright (c) 2025 Triad National Security, LLC. All rights
8+
* reserved.
9+
* $COPYRIGHT$
10+
*
11+
* Additional copyrights may follow
12+
*
13+
* $HEADER$
14+
*/
15+
16+
#include "ompi_config.h"
17+
18+
#include "ompi/mpi/tool/mpit-internal.h"
19+
20+
#if OMPI_BUILD_MPI_PROFILING
21+
#if OPAL_HAVE_WEAK_SYMBOLS
22+
#pragma weak MPI_T_event_copy = PMPI_T_event_copy
23+
#endif
24+
#define MPI_T_event_copy PMPI_T_event_copy
25+
#endif
26+
27+
28+
int MPI_T_event_copy (MPI_T_event_instance event, void *buffer)
29+
{
30+
if (!mpit_is_initialized ()) {
31+
return MPI_T_ERR_NOT_INITIALIZED;
32+
}
33+
34+
return MPI_T_ERR_INVALID_HANDLE;
35+
}

ompi/mpi/tool/event_get_index.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
2+
/*
3+
* Copyright (c) 2012-2018 Los Alamos National Security, LLC. All rights
4+
* reserved.
5+
* Copyright (c) 2014 Cisco Systems, Inc. All rights reserved.
6+
* Copyright (c) 2025 Triad National Security, LLC. All rights
7+
* reserved.
8+
* $COPYRIGHT$
9+
*
10+
* Additional copyrights may follow
11+
*
12+
* $HEADER$
13+
*/
14+
15+
#include "ompi_config.h"
16+
17+
#include "ompi/mpi/tool/mpit-internal.h"
18+
19+
#if OMPI_BUILD_MPI_PROFILING
20+
#if OPAL_HAVE_WEAK_SYMBOLS
21+
#pragma weak MPI_T_event_get_index = PMPI_T_event_get_index
22+
#endif
23+
#define MPI_T_event_get_index PMPI_T_event_get_index
24+
#endif
25+
26+
int MPI_T_event_get_index (const char *name, int *event_index)
27+
{
28+
if (!mpit_is_initialized ()) {
29+
return MPI_T_ERR_NOT_INITIALIZED;
30+
}
31+
32+
if (MPI_PARAM_CHECK && (NULL == event_index || NULL == name)) {
33+
return MPI_ERR_ARG;
34+
}
35+
36+
return MPI_T_ERR_INVALID_NAME;
37+
}

0 commit comments

Comments
 (0)