Skip to content

Commit 9ffb024

Browse files
committed
hook/comm_method: Use enum flags to select protocols
Signed-off-by: Joshua Hursey <[email protected]>
1 parent 5df7f98 commit 9ffb024

File tree

1 file changed

+32
-24
lines changed

1 file changed

+32
-24
lines changed

ompi/mca/hook/comm_method/hook_comm_method_component.c

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,21 @@ 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}
77+
enum mca_hook_comm_method_mode_flags_t {
78+
/* Default: Display nothing */
79+
OMPI_HOOK_COMM_METHOD_NONE = 0x01,
80+
/* Display on MPI_INIT */
81+
OMPI_HOOK_COMM_METHOD_INIT = 0x02,
82+
/* Display on MPI_FINALIZE */
83+
OMPI_HOOK_COMM_METHOD_FINALIZE = 0x04,
84+
};
85+
86+
static mca_base_var_enum_value_flag_t mca_hook_comm_method_modes[] = {
87+
{.flag = OMPI_HOOK_COMM_METHOD_NONE, .string = "none",
88+
.conflicting_flag = OMPI_HOOK_COMM_METHOD_INIT | OMPI_HOOK_COMM_METHOD_FINALIZE},
89+
{.flag = OMPI_HOOK_COMM_METHOD_INIT, .string = "mpi_init"},
90+
{.flag = OMPI_HOOK_COMM_METHOD_FINALIZE, .string = "mpi_finalize"},
91+
{0, NULL, 0}
8492
};
8593

8694

@@ -99,8 +107,8 @@ static int ompi_hook_comm_method_component_close(void)
99107
static int ompi_hook_comm_method_component_register(void)
100108
{
101109
int ret;
102-
int mca_hook_comm_method_enabled = -1;
103-
mca_base_var_enum_t *new_enum = NULL;
110+
mca_base_var_enum_flag_t *mca_hook_comm_method_flags = NULL;
111+
uint32_t mca_hook_comm_method_enabled_flags = OMPI_HOOK_COMM_METHOD_NONE;
104112

105113
/*
106114
* Component verbosity level
@@ -145,27 +153,27 @@ static int ompi_hook_comm_method_component_register(void)
145153
&mca_hook_comm_method_enable_mpi_finalize);
146154

147155
// User can set the comm_method mca variable too
148-
mca_base_var_enum_create("ompi_comm_method", mca_hook_comm_method_modes, &new_enum);
156+
mca_base_var_enum_create_flag("ompi_comm_method", mca_hook_comm_method_modes, &mca_hook_comm_method_flags);
157+
149158
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,
159+
"Enable the communication protocol report: when MPI_INIT is invoked (using the 'mpi_init' value) and/or when MPI_FINALIZE is invoked (using the 'mpi_finalize' value).",
160+
MCA_BASE_VAR_TYPE_UNSIGNED_INT,
161+
&mca_hook_comm_method_flags->super,
152162
0, 0,
153163
OPAL_INFO_LVL_3,
154164
MCA_BASE_VAR_SCOPE_READONLY,
155-
&mca_hook_comm_method_enabled);
156-
OBJ_RELEASE(new_enum);
165+
&mca_hook_comm_method_enabled_flags);
166+
OBJ_RELEASE(mca_hook_comm_method_flags);
157167
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 ) {
161-
mca_hook_comm_method_enable_mpi_init = true;
168+
opal_output(0, "hook:comm_method: Warning invalid comm_method specified.");
162169
}
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;
168-
mca_hook_comm_method_enable_mpi_finalize = true;
170+
else {
171+
if( mca_hook_comm_method_enabled_flags & OMPI_HOOK_COMM_METHOD_INIT ) {
172+
mca_hook_comm_method_enable_mpi_init = true;
173+
}
174+
if( mca_hook_comm_method_enabled_flags & OMPI_HOOK_COMM_METHOD_FINALIZE ) {
175+
mca_hook_comm_method_enable_mpi_finalize = true;
176+
}
169177
}
170178

171179
// comm_method_max

0 commit comments

Comments
 (0)