Fix cwd and preload-binary options
Signed-off-by: Ralph Castain <rhc@open-mpi.org>
Этот коммит содержится в:
родитель
ad108ba44d
Коммит
321abfc8c6
@ -534,11 +534,8 @@ int orte_odls_base_default_construct_child_list(opal_buffer_t *buffer,
|
||||
|
||||
static int setup_path(orte_app_context_t *app, char **wdir)
|
||||
{
|
||||
int rc;
|
||||
int rc=ORTE_SUCCESS;
|
||||
char dir[MAXPATHLEN];
|
||||
char **argvptr;
|
||||
char *pathenv = NULL, *mpiexec_pathenv = NULL;
|
||||
char *full_search;
|
||||
|
||||
if (!orte_get_attribute(&app->attributes, ORTE_APP_SSNDIR_CWD, NULL, OPAL_BOOL)) {
|
||||
/* Try to change to the app's cwd and check that the app
|
||||
@ -572,40 +569,6 @@ static int setup_path(orte_app_context_t *app, char **wdir)
|
||||
*wdir = NULL;
|
||||
}
|
||||
|
||||
/* Search for the OMPI_exec_path and PATH settings in the environment. */
|
||||
for (argvptr = app->env; *argvptr != NULL; argvptr++) {
|
||||
if (0 == strncmp("OMPI_exec_path=", *argvptr, 15)) {
|
||||
mpiexec_pathenv = *argvptr + 15;
|
||||
}
|
||||
if (0 == strncmp("PATH=", *argvptr, 5)) {
|
||||
pathenv = *argvptr + 5;
|
||||
}
|
||||
}
|
||||
|
||||
/* If OMPI_exec_path is set (meaning --path was used), then create a
|
||||
temporary environment to be used in the search for the executable.
|
||||
The PATH setting in this temporary environment is a combination of
|
||||
the OMPI_exec_path and PATH values. If OMPI_exec_path is not set,
|
||||
then just use existing environment with PATH in it. */
|
||||
if (NULL != mpiexec_pathenv) {
|
||||
argvptr = NULL;
|
||||
if (pathenv != NULL) {
|
||||
asprintf(&full_search, "%s:%s", mpiexec_pathenv, pathenv);
|
||||
} else {
|
||||
asprintf(&full_search, "%s", mpiexec_pathenv);
|
||||
}
|
||||
opal_setenv("PATH", full_search, true, &argvptr);
|
||||
free(full_search);
|
||||
} else {
|
||||
argvptr = app->env;
|
||||
}
|
||||
|
||||
rc = orte_util_check_context_app(app, argvptr);
|
||||
/* do not ERROR_LOG - it will be reported elsewhere */
|
||||
if (NULL != mpiexec_pathenv) {
|
||||
opal_argv_free(argvptr);
|
||||
}
|
||||
|
||||
CLEANUP:
|
||||
return rc;
|
||||
}
|
||||
@ -662,6 +625,9 @@ void orte_odls_base_spawn_proc(int fd, short sd, void *cbdata)
|
||||
int rc, i;
|
||||
bool found;
|
||||
orte_proc_state_t state;
|
||||
char **argvptr;
|
||||
char *pathenv = NULL, *mpiexec_pathenv = NULL;
|
||||
char *full_search;
|
||||
|
||||
/* thread-protect common values */
|
||||
cd->env = opal_argv_copy(app->env);
|
||||
@ -762,6 +728,44 @@ void orte_odls_base_spawn_proc(int fd, short sd, void *cbdata)
|
||||
goto errorout;
|
||||
}
|
||||
|
||||
/* Search for the OMPI_exec_path and PATH settings in the environment. */
|
||||
for (argvptr = app->env; *argvptr != NULL; argvptr++) {
|
||||
if (0 == strncmp("OMPI_exec_path=", *argvptr, 15)) {
|
||||
mpiexec_pathenv = *argvptr + 15;
|
||||
}
|
||||
if (0 == strncmp("PATH=", *argvptr, 5)) {
|
||||
pathenv = *argvptr + 5;
|
||||
}
|
||||
}
|
||||
|
||||
/* If OMPI_exec_path is set (meaning --path was used), then create a
|
||||
temporary environment to be used in the search for the executable.
|
||||
The PATH setting in this temporary environment is a combination of
|
||||
the OMPI_exec_path and PATH values. If OMPI_exec_path is not set,
|
||||
then just use existing environment with PATH in it. */
|
||||
if (NULL != mpiexec_pathenv) {
|
||||
argvptr = NULL;
|
||||
if (pathenv != NULL) {
|
||||
asprintf(&full_search, "%s:%s", mpiexec_pathenv, pathenv);
|
||||
} else {
|
||||
asprintf(&full_search, "%s", mpiexec_pathenv);
|
||||
}
|
||||
opal_setenv("PATH", full_search, true, &argvptr);
|
||||
free(full_search);
|
||||
} else {
|
||||
argvptr = app->env;
|
||||
}
|
||||
|
||||
rc = orte_util_check_context_app(app, argvptr);
|
||||
/* do not ERROR_LOG - it will be reported elsewhere */
|
||||
if (NULL != mpiexec_pathenv) {
|
||||
opal_argv_free(argvptr);
|
||||
}
|
||||
if (ORTE_SUCCESS != rc) {
|
||||
state = ORTE_PROC_STATE_FAILED_TO_LAUNCH;
|
||||
goto errorout;
|
||||
}
|
||||
|
||||
/* if we are indexing the argv by rank, do so now */
|
||||
if (cd->index_argv && !ORTE_FLAG_TEST(jobdat, ORTE_JOB_FLAG_DEBUGGER_DAEMON)) {
|
||||
char *param;
|
||||
|
@ -1207,6 +1207,11 @@ static int setup_child(orte_job_t *jdata,
|
||||
opal_setenv("PWD", param, true, env);
|
||||
/* update the initial wdir value too */
|
||||
opal_setenv("OMPI_MCA_initial_wdir", param, true, env);
|
||||
} else if (NULL != app->cwd) {
|
||||
/* change to it */
|
||||
if (0 != chdir(app->cwd)) {
|
||||
return ORTE_ERROR;
|
||||
}
|
||||
}
|
||||
return ORTE_SUCCESS;
|
||||
}
|
||||
|
@ -1628,22 +1628,17 @@ static int create_app(int argc, char* argv[],
|
||||
app->num_procs = (orte_std_cntr_t)orte_cmd_options.num_procs;
|
||||
total_num_apps++;
|
||||
|
||||
/* Capture any preload flags */
|
||||
if (orte_cmd_options.preload_binaries) {
|
||||
orte_set_attribute(&app->attributes, ORTE_APP_PRELOAD_BIN, ORTE_ATTR_GLOBAL, NULL, OPAL_BOOL);
|
||||
}
|
||||
/* if we were told to cwd to the session dir and the app was given in
|
||||
* relative syntax, then we need to preload the binary to
|
||||
/* see if we need to preload the binary to
|
||||
* find the app - don't do this for java apps, however, as we
|
||||
* can't easily find the class on the cmd line. Java apps have to
|
||||
* preload their binary via the preload_files option
|
||||
*/
|
||||
if (!opal_path_is_absolute(app->argv[0]) &&
|
||||
NULL == strstr(app->argv[0], "java")) {
|
||||
if (NULL == strstr(app->argv[0], "java")) {
|
||||
if (orte_cmd_options.preload_binaries) {
|
||||
orte_set_attribute(&app->attributes, ORTE_APP_SSNDIR_CWD, ORTE_ATTR_GLOBAL, NULL, OPAL_BOOL);
|
||||
} else if (orte_get_attribute(&app->attributes, ORTE_APP_SSNDIR_CWD, NULL, OPAL_BOOL)) {
|
||||
orte_set_attribute(&app->attributes, ORTE_APP_PRELOAD_BIN, ORTE_ATTR_GLOBAL, NULL, OPAL_BOOL);
|
||||
/* no harm in setting this attribute twice as the function will simply ignore it */
|
||||
orte_set_attribute(&app->attributes, ORTE_APP_SSNDIR_CWD, ORTE_ATTR_GLOBAL, NULL, OPAL_BOOL);
|
||||
}
|
||||
}
|
||||
if (NULL != orte_cmd_options.preload_files) {
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user