Skip to content

Commit 5df7f98

Browse files
committed
Update hook component to use enum MCA parameter
* `--mca ompi_comm_method` - `1` / `init` / `mpi_init` : Display during `MPI_Init` - `2` / `finalize` / `mpi_finalize` : Display during `MPI_Finalize` - `3` / `all` : Show both of the above Signed-off-by: Joshua Hursey <[email protected]>
1 parent d489030 commit 5df7f98

File tree

1 file changed

+33
-13
lines changed

1 file changed

+33
-13
lines changed

ompi/mca/hook/comm_method/hook_comm_method_component.c

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,16 @@ int mca_hook_comm_method_max = 12;
7474
int mca_hook_comm_method_brief = 0;
7575
char *mca_hook_comm_method_fakefile = NULL;
7676

77+
mca_base_var_enum_value_t mca_hook_comm_method_modes[] = {
78+
{1, "init"},
79+
{1, "mpi_init"},
80+
{2, "finalize"},
81+
{2, "mpi_finalize"},
82+
{3, "all"},
83+
{0, NULL}
84+
};
85+
86+
7787
static int ompi_hook_comm_method_component_open(void)
7888
{
7989
// Nothing to do
@@ -88,6 +98,9 @@ static int ompi_hook_comm_method_component_close(void)
8898

8999
static int ompi_hook_comm_method_component_register(void)
90100
{
101+
int ret;
102+
int mca_hook_comm_method_enabled = -1;
103+
mca_base_var_enum_t *new_enum = NULL;
91104

92105
/*
93106
* Component verbosity level
@@ -115,7 +128,7 @@ static int ompi_hook_comm_method_component_register(void)
115128
*/
116129
mca_hook_comm_method_enable_mpi_init = false;
117130
(void) mca_base_component_var_register(&mca_hook_comm_method_component.hookm_version, "enable_mpi_init",
118-
"Enable comm_method behavior on mpi_init",
131+
"Enable the communication protocol report when MPI_INIT is invoked",
119132
MCA_BASE_VAR_TYPE_BOOL, NULL,
120133
0, 0,
121134
OPAL_INFO_LVL_3,
@@ -124,27 +137,34 @@ static int ompi_hook_comm_method_component_register(void)
124137

125138
mca_hook_comm_method_enable_mpi_finalize = false;
126139
(void) mca_base_component_var_register(&mca_hook_comm_method_component.hookm_version, "enable_mpi_finalize",
127-
"Enable comm_method behavior on mpi_finalize",
140+
"Enable the communication protocol report when MPI_FINALIZE is invoked",
128141
MCA_BASE_VAR_TYPE_BOOL, NULL,
129142
0, 0,
130143
OPAL_INFO_LVL_3,
131144
MCA_BASE_VAR_SCOPE_READONLY,
132145
&mca_hook_comm_method_enable_mpi_finalize);
133146

134147
// User can set the comm_method mca variable too
135-
int hook_comm_method = -1;
136-
(void) mca_base_var_register("ompi", NULL, NULL, "comm_method",
137-
"Enable comm_method behavior (1) mpi_init or (2) mpi_finalize",
138-
MCA_BASE_VAR_TYPE_INT, NULL,
139-
0, 0,
140-
OPAL_INFO_LVL_3,
141-
MCA_BASE_VAR_SCOPE_READONLY,
142-
&hook_comm_method);
143-
144-
if( 1 == hook_comm_method ) {
148+
mca_base_var_enum_create("ompi_comm_method", mca_hook_comm_method_modes, &new_enum);
149+
ret = mca_base_var_register("ompi", NULL, NULL, "comm_method",
150+
"Enable the communication protocol report: when MPI_INIT is invoked (using the '1', 'init', or 'mpi_init' values), when MPI_FINALIZE is inboked (using the '2', 'finalize', or 'mpi_finalize' values), or when both are invoked (using the '3', or 'all' values)",
151+
MCA_BASE_VAR_TYPE_INT, new_enum,
152+
0, 0,
153+
OPAL_INFO_LVL_3,
154+
MCA_BASE_VAR_SCOPE_READONLY,
155+
&mca_hook_comm_method_enabled);
156+
OBJ_RELEASE(new_enum);
157+
if(OPAL_ERR_VALUE_OUT_OF_BOUNDS == ret) {
158+
opal_output(0, "hook:comm_method: Warning invalid prot mode specified: %d", mca_hook_comm_method_enabled);
159+
}
160+
else if( 1 == mca_hook_comm_method_enabled ) {
145161
mca_hook_comm_method_enable_mpi_init = true;
146162
}
147-
else if( 2 == hook_comm_method ) {
163+
else if( 2 == mca_hook_comm_method_enabled ) {
164+
mca_hook_comm_method_enable_mpi_finalize = true;
165+
}
166+
else if( 3 == mca_hook_comm_method_enabled ) {
167+
mca_hook_comm_method_enable_mpi_init = true;
148168
mca_hook_comm_method_enable_mpi_finalize = true;
149169
}
150170

0 commit comments

Comments
 (0)