Skip to content

Commit

Permalink
Update hook component to use enum MCA parameter
Browse files Browse the repository at this point in the history
 * `--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 <jhursey@us.ibm.com>
  • Loading branch information
jjhursey committed Jan 4, 2021
1 parent d489030 commit 5df7f98
Showing 1 changed file with 33 additions and 13 deletions.
46 changes: 33 additions & 13 deletions ompi/mca/hook/comm_method/hook_comm_method_component.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ int mca_hook_comm_method_max = 12;
int mca_hook_comm_method_brief = 0;
char *mca_hook_comm_method_fakefile = NULL;

mca_base_var_enum_value_t mca_hook_comm_method_modes[] = {
{1, "init"},
{1, "mpi_init"},
{2, "finalize"},
{2, "mpi_finalize"},
{3, "all"},
{0, NULL}
};


static int ompi_hook_comm_method_component_open(void)
{
// Nothing to do
Expand All @@ -88,6 +98,9 @@ static int ompi_hook_comm_method_component_close(void)

static int ompi_hook_comm_method_component_register(void)
{
int ret;
int mca_hook_comm_method_enabled = -1;
mca_base_var_enum_t *new_enum = NULL;

/*
* Component verbosity level
Expand Down Expand Up @@ -115,7 +128,7 @@ static int ompi_hook_comm_method_component_register(void)
*/
mca_hook_comm_method_enable_mpi_init = false;
(void) mca_base_component_var_register(&mca_hook_comm_method_component.hookm_version, "enable_mpi_init",
"Enable comm_method behavior on mpi_init",
"Enable the communication protocol report when MPI_INIT is invoked",
MCA_BASE_VAR_TYPE_BOOL, NULL,
0, 0,
OPAL_INFO_LVL_3,
Expand All @@ -124,27 +137,34 @@ static int ompi_hook_comm_method_component_register(void)

mca_hook_comm_method_enable_mpi_finalize = false;
(void) mca_base_component_var_register(&mca_hook_comm_method_component.hookm_version, "enable_mpi_finalize",
"Enable comm_method behavior on mpi_finalize",
"Enable the communication protocol report when MPI_FINALIZE is invoked",
MCA_BASE_VAR_TYPE_BOOL, NULL,
0, 0,
OPAL_INFO_LVL_3,
MCA_BASE_VAR_SCOPE_READONLY,
&mca_hook_comm_method_enable_mpi_finalize);

// User can set the comm_method mca variable too
int hook_comm_method = -1;
(void) mca_base_var_register("ompi", NULL, NULL, "comm_method",
"Enable comm_method behavior (1) mpi_init or (2) mpi_finalize",
MCA_BASE_VAR_TYPE_INT, NULL,
0, 0,
OPAL_INFO_LVL_3,
MCA_BASE_VAR_SCOPE_READONLY,
&hook_comm_method);

if( 1 == hook_comm_method ) {
mca_base_var_enum_create("ompi_comm_method", mca_hook_comm_method_modes, &new_enum);
ret = mca_base_var_register("ompi", NULL, NULL, "comm_method",
"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)",
MCA_BASE_VAR_TYPE_INT, new_enum,
0, 0,
OPAL_INFO_LVL_3,
MCA_BASE_VAR_SCOPE_READONLY,
&mca_hook_comm_method_enabled);
OBJ_RELEASE(new_enum);
if(OPAL_ERR_VALUE_OUT_OF_BOUNDS == ret) {
opal_output(0, "hook:comm_method: Warning invalid prot mode specified: %d", mca_hook_comm_method_enabled);
}
else if( 1 == mca_hook_comm_method_enabled ) {
mca_hook_comm_method_enable_mpi_init = true;
}
else if( 2 == hook_comm_method ) {
else if( 2 == mca_hook_comm_method_enabled ) {
mca_hook_comm_method_enable_mpi_finalize = true;
}
else if( 3 == mca_hook_comm_method_enabled ) {
mca_hook_comm_method_enable_mpi_init = true;
mca_hook_comm_method_enable_mpi_finalize = true;
}

Expand Down

0 comments on commit 5df7f98

Please sign in to comment.