Skip to content

Commit

Permalink
Merge pull request #112 from minsii/pr/disable-mpit
Browse files Browse the repository at this point in the history
mpit: optionally disable MPI_T usage in OSHMPI

Approved-by: Min Si <[email protected]>
  • Loading branch information
minsii authored May 11, 2021
2 parents e336a4f + 0f53b3b commit 41ad4c1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
3 changes: 3 additions & 0 deletions src/include/oshmpi_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,9 @@ typedef struct {
* Invalid when OSHMPI_DISABLE_AM_ASYNC_THREAD is set.
* Default value is 1 if either AMO or RMA is AM based;
* otherwise 0.*/
unsigned int enable_mpit; /* OSHMPI_ENABLE_MPI_T: Control mpi_t utilization at shmem_init.
* Value: 0 or 1. Default is 1, enables MPI_T setting.
* Set OSHMPI_ENABLE_MPI_T=0 to disable. */
uint32_t mpi_gpu_features; /* OSHMPI_MPI_GPU_FEATURES: Arbitrary combination with bit shift defined in
* OSHMPI_mpi_gpu_feature_shift_t. none and all are two special values. */
#ifndef OSHMPI_DISABLE_DEBUG
Expand Down
27 changes: 20 additions & 7 deletions src/internal/setup_impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -576,14 +576,16 @@ static void print_env(void)
" OSHMPI_AMO_OPS %s\n"
" OSHMPI_ENABLE_ASYNC_THREAD %d\n"
" OSHMPI_MPI_GPU_FEATURES %s\n"
" OSHMPI_ENABLE_MPI_T %d\n"
#ifndef OSHMPI_DISABLE_DEBUG
" (Invalid options if OSHMPI is built with --enable-fast=ndebug)\n"
" OSHMPI_AMO_DBG_MODE %s\n"
" OSHMPI_RMA_DBG_MODE %s\n"
#endif
,OSHMPI_env.verbose, amo_ops_str,
OSHMPI_env.enable_async_thread,
mpi_gpu_features_str
mpi_gpu_features_str,
OSHMPI_env.enable_mpit
#ifndef OSHMPI_DISABLE_DEBUG
,getstr_env_dbg_mode(OSHMPI_env.amo_dbg_mode)
,getstr_env_dbg_mode(OSHMPI_env.rma_dbg_mode)
Expand Down Expand Up @@ -682,40 +684,51 @@ static void initialize_env(void)
if (OSHMPI_env.enable_async_thread != 0)
OSHMPI_env.enable_async_thread = 1;
#endif

OSHMPI_env.enable_mpit = 1;
val = getenv("OSHMPI_ENABLE_MPI_T");
if (val && strlen(val) && atoi(val) == 0)
OSHMPI_env.enable_mpit = 0;
}

static void set_mpit_cvar(const char *cvar_name, const void *val)
static int set_mpit_cvar(const char *cvar_name, const void *val)
{
int mpi_errno = MPI_SUCCESS;

/* Do not overwrite user's setting */
char *env_var = NULL;
env_var = getenv(cvar_name);
if (env_var && strlen(env_var))
return;
return 0;

int cvar_index;
OSHMPI_CALLMPI_RET(mpi_errno, MPI_T_cvar_get_index(cvar_name, &cvar_index));
if (mpi_errno == MPI_T_ERR_INVALID_NAME)
return; /* Support of a CVAR is implementation specific */
return 0; /* Support of a CVAR is implementation specific */

MPI_T_cvar_handle handle;
int count;
OSHMPI_CALLMPI(MPI_T_cvar_handle_alloc(cvar_index, NULL, &handle, &count));

/* TODO: Add other data types when needed. */
int val_read = 0;
OSHMPI_CALLMPI(PMPI_T_cvar_write(handle, val));
OSHMPI_CALLMPI(MPI_T_cvar_write(handle, val));
OSHMPI_CALLMPI(MPI_T_cvar_read(handle, &val_read));
OSHMPI_DBGMSG("MPI_T setup: %s = %d\n", cvar_name, val_read);

MPI_T_cvar_handle_free(&handle);
return 1;
}

static void initialize_mpit(void)
{
int val = 1;
set_mpit_cvar("MPIR_CVAR_CH4_RMA_ENABLE_DYNAMIC_AM_PROGRESS", &val);
if (!OSHMPI_env.enable_mpit)
return;

int val = 1, cnt = 0;
cnt += set_mpit_cvar("MPIR_CVAR_CH4_RMA_ENABLE_DYNAMIC_AM_PROGRESS", &val);

OSHMPI_DBGMSG("Initialized %d MPI_T CVAR variables\n", cnt);
}

void OSHMPI_initialize_thread(int required, int *provided)
Expand Down

0 comments on commit 41ad4c1

Please sign in to comment.