Skip to content

Commit c3bb38e

Browse files
committed
Populate some additional MPI_INFO_ENV keys with singleton launch.
Specifically, 'command', 'wdir' and 'argv'. Pass down the argv and argc commands to the lower levels from MPI_Init(). In the singleton case, the PMIx calls to get these data will fail, so populate them when they do if provided. Nothing to do for the MPI_Sessions model, as it is not supported. 'wdir' can be populated with a good enough guess of getcwd(). Signed-off-by: Austen Lauria <awlauria@us.ibm.com>
1 parent 1683a46 commit c3bb38e

File tree

5 files changed

+13
-7
lines changed

5 files changed

+13
-7
lines changed

ompi/instance/instance.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ static void evhandler_dereg_callbk(pmix_status_t status,
330330
/**
331331
* @brief Function that starts up the common components needed by all instances
332332
*/
333-
static int ompi_mpi_instance_init_common (void)
333+
static int ompi_mpi_instance_init_common (int argc, char **argv)
334334
{
335335
int ret;
336336
ompi_proc_t **procs;
@@ -384,7 +384,7 @@ static int ompi_mpi_instance_init_common (void)
384384
OMPI_TIMING_NEXT("initialization");
385385

386386
/* Setup RTE */
387-
if (OMPI_SUCCESS != (ret = ompi_rte_init (NULL, NULL))) {
387+
if (OMPI_SUCCESS != (ret = ompi_rte_init (&argc, &argv))) {
388388
return ompi_instance_print_error ("ompi_mpi_init: ompi_rte_init failed", ret);
389389
}
390390

@@ -784,7 +784,7 @@ static int ompi_mpi_instance_init_common (void)
784784
return OMPI_SUCCESS;
785785
}
786786

787-
int ompi_mpi_instance_init (int ts_level, opal_info_t *info, ompi_errhandler_t *errhandler, ompi_instance_t **instance)
787+
int ompi_mpi_instance_init (int ts_level, opal_info_t *info, ompi_errhandler_t *errhandler, ompi_instance_t **instance, int argc, char **argv)
788788
{
789789
ompi_instance_t *new_instance;
790790
int ret;
@@ -799,7 +799,7 @@ int ompi_mpi_instance_init (int ts_level, opal_info_t *info, ompi_errhandler_t
799799

800800
opal_mutex_lock (&instance_lock);
801801
if (0 == opal_atomic_fetch_add_32 (&ompi_instance_count, 1)) {
802-
ret = ompi_mpi_instance_init_common ();
802+
ret = ompi_mpi_instance_init_common (argc, argv);
803803
if (OPAL_UNLIKELY(OPAL_SUCCESS != ret)) {
804804
opal_mutex_unlock (&instance_lock);
805805
return ret;

ompi/instance/instance.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ void ompi_mpi_instance_release (void);
123123
* @param[in] info info object
124124
* @param[in] errhander errhandler to set on the instance
125125
*/
126-
OMPI_DECLSPEC int ompi_mpi_instance_init (int ts_level, opal_info_t *info, ompi_errhandler_t *errhandler, ompi_instance_t **instance);
126+
OMPI_DECLSPEC int ompi_mpi_instance_init (int ts_level, opal_info_t *info, ompi_errhandler_t *errhandler,
127+
ompi_instance_t **instance, int argc, char **argv);
127128

128129
/**
129130
* @brief Destroy an MPI instance and set it to MPI_SESSION_NULL

ompi/mpi/c/session_init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ int MPI_Session_init (MPI_Info info, MPI_Errhandler errhandler, MPI_Session *ses
5454
}
5555
}
5656

57-
rc = ompi_mpi_instance_init (ts_level, &info->super, errhandler, session);
57+
rc = ompi_mpi_instance_init (ts_level, &info->super, errhandler, session, 0, NULL);
5858
/* if an error occurred raise it on the null session */
5959
OMPI_ERRHANDLER_RETURN (rc, MPI_SESSION_NULL, rc, FUNC_NAME);
6060
}

ompi/runtime/ompi_mpi_init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ int ompi_mpi_init(int argc, char **argv, int requested, int *provided,
356356

357357
ompi_mpi_thread_level(requested, provided);
358358

359-
ret = ompi_mpi_instance_init (*provided, &ompi_mpi_info_null.info.super, MPI_ERRORS_ARE_FATAL, &ompi_mpi_instance_default);
359+
ret = ompi_mpi_instance_init (*provided, &ompi_mpi_info_null.info.super, MPI_ERRORS_ARE_FATAL, &ompi_mpi_instance_default, argc, argv);
360360
if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) {
361361
error = "ompi_mpi_init: ompi_mpi_instance_init failed";
362362
goto error;

ompi/runtime/ompi_rte.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,11 @@ int ompi_rte_init(int *pargc, char ***pargv)
818818
opal_process_info.initial_wdir = val;
819819
val = NULL; // protect the string
820820
}
821+
else {
822+
// Probably singleton case. Just assume cwd.
823+
opal_process_info.initial_wdir = calloc(1, OPAL_PATH_MAX + 1);
824+
opal_getcwd(opal_process_info.initial_wdir, OPAL_PATH_MAX);
825+
}
821826

822827
/* identify our location */
823828
val = NULL;

0 commit comments

Comments
 (0)