1
1

Cleanup the prefix handling by mpirun. Important note: we do NOT support per-app_context prefixes!!

Don't let app_files trump given prefix values. Assign according to following precedence rules:

1. absolute path to mpirun, if given
2. --prefix value, if given to mpirun
3. default prefix, if configured with --enable-orterun-prefix-default
4. prefix from first app in app_file, if given
5. no prefix

This commit was SVN r26081.
Этот коммит содержится в:
Ralph Castain 2012-03-02 19:48:25 +00:00
родитель 8791ade293
Коммит 6c93dd13b0
3 изменённых файлов: 154 добавлений и 71 удалений

Просмотреть файл

@ -161,6 +161,17 @@ Only one should be specified to avoid potential version
confusion. Operation will continue, but the -prefix option will be
ignored.
#
[orterun:app-prefix-conflict]
Both a prefix or absolute path was given for %s, and a different
prefix provided for the first app_context:
Mpirun prefix: %s
App prefix: %s
Only one should be specified to avoid potential version
confusion. Operation will continue, but the applicaton's prefix
option will be ignored.
#
[orterun:empty-prefix]
A prefix was supplied to %s that only contained slashes.

Просмотреть файл

@ -533,7 +533,8 @@ int orterun(int argc, char *argv[])
{
int rc;
opal_cmd_line_t cmd_line;
char * tmp_env_var = NULL;
char *tmp_env_var = NULL;
char *param;
orte_job_t *daemons;
int32_t ljob;
orte_app_context_t *app, *dapp;
@ -562,6 +563,88 @@ int orterun(int argc, char *argv[])
*/
mca_base_cmd_line_process_args(&cmd_line, &environ, &environ);
/* may look strange, but the way we handle prefix is a little weird
* and probably needs to be addressed more fully at some future point.
* For now, we have a conflict between app_files and cmd line usage.
* Since app_files are used by the C/R system, we will make an
* adjustment here to avoid perturbing that system.
*
* We cannot just have the cmd line parser place any found value
* in the global struct as the app_file parser would replace it.
* So handle this specific cmd line option manually.
*/
orterun_globals.prefix = NULL;
orterun_globals.path_to_mpirun = NULL;
if (opal_cmd_line_is_taken(&cmd_line, "prefix") ||
'/' == argv[0][0] || want_prefix_by_default) {
size_t param_len;
if ('/' == argv[0][0]) {
char* tmp_basename = NULL;
/* If they specified an absolute path, strip off the
/bin/<exec_name>" and leave just the prefix */
orterun_globals.path_to_mpirun = opal_dirname(argv[0]);
/* Quick sanity check to ensure we got
something/bin/<exec_name> and that the installation
tree is at least more or less what we expect it to
be */
tmp_basename = opal_basename(orterun_globals.path_to_mpirun);
if (0 == strcmp("bin", tmp_basename)) {
char* tmp = orterun_globals.path_to_mpirun;
orterun_globals.path_to_mpirun = opal_dirname(tmp);
free(tmp);
} else {
free(orterun_globals.path_to_mpirun);
orterun_globals.path_to_mpirun = NULL;
}
free(tmp_basename);
}
/* if both are given, check to see if they match */
if (opal_cmd_line_is_taken(&cmd_line, "prefix") && NULL != orterun_globals.path_to_mpirun) {
/* if they don't match, then that merits a warning */
param = strdup(opal_cmd_line_get_param(&cmd_line, "prefix", 0, 0));
if (0 != strcmp(param, orterun_globals.path_to_mpirun)) {
orte_show_help("help-orterun.txt", "orterun:double-prefix",
true, orte_basename,
param, orterun_globals.path_to_mpirun);
/* let the path-to-mpirun take precedence since we
* know that one is being used
*/
free(param);
param = orterun_globals.path_to_mpirun;
} else {
/* since they match, just use param */
free(orterun_globals.path_to_mpirun);
}
} else if (NULL != orterun_globals.path_to_mpirun) {
param = orterun_globals.path_to_mpirun;
} else if (opal_cmd_line_is_taken(&cmd_line, "prefix")){
/* must be --prefix alone */
param = strdup(opal_cmd_line_get_param(&cmd_line, "prefix", 0, 0));
} else {
/* --enable-orterun-prefix-default was given to orterun */
param = strdup(opal_install_dirs.prefix);
}
if (NULL != param) {
/* "Parse" the param, aka remove superfluous path_sep. */
param_len = strlen(param);
while (0 == strcmp (OPAL_PATH_SEP, &(param[param_len-1]))) {
param[param_len-1] = '\0';
param_len--;
if (0 == param_len) {
orte_show_help("help-orterun.txt", "orterun:empty-prefix",
true, orte_basename, orte_basename);
return ORTE_ERR_FATAL;
}
}
orterun_globals.prefix = strdup(param);
free(param);
}
want_prefix_by_default = true;
}
/* Ensure that enough of OPAL is setup for us to be able to run */
/*
* NOTE: (JJH)
@ -1571,6 +1654,12 @@ static int create_app(int argc, char* argv[],
app->user_specified_cwd = false;
}
/* if this is the first app_context, check for prefix directions.
* We only do this for the first app_context because the launchers
* only look at the first one when setting the prefix - we do NOT
* support per-app_context prefix settings!
*/
if (0 == total_num_apps) {
/* Check to see if the user explicitly wanted to disable automatic
--prefix behavior */
@ -1578,51 +1667,31 @@ static int create_app(int argc, char* argv[],
want_prefix_by_default = false;
}
/* Did the user specify a specific prefix for this app_context_t
or provide an absolute path name to argv[0]? */
if (opal_cmd_line_is_taken(&cmd_line, "prefix") ||
'/' == argv[0][0] || want_prefix_by_default) {
/* Did the user specify a prefix, or want prefix by default? */
if (opal_cmd_line_is_taken(&cmd_line, "prefix") || want_prefix_by_default) {
size_t param_len;
char *path_to_mpirun=NULL;
if ('/' == argv[0][0]) {
char* tmp_basename = NULL;
/* If they specified an absolute path, strip off the
/bin/<exec_name>" and leave just the prefix */
path_to_mpirun = opal_dirname(argv[0]);
/* Quick sanity check to ensure we got
something/bin/<exec_name> and that the installation
tree is at least more or less what we expect it to
be */
tmp_basename = opal_basename(path_to_mpirun);
if (0 == strcmp("bin", tmp_basename)) {
char* tmp = path_to_mpirun;
path_to_mpirun = opal_dirname(tmp);
free(tmp);
} else {
free(path_to_mpirun);
path_to_mpirun = NULL;
}
free(tmp_basename);
}
/* if both are given, check to see if they match */
if (opal_cmd_line_is_taken(&cmd_line, "prefix") && NULL != path_to_mpirun) {
/* if both the prefix was given and we have a prefix
* given above, check to see if they match
*/
if (opal_cmd_line_is_taken(&cmd_line, "prefix") &&
NULL != orterun_globals.prefix) {
/* if they don't match, then that merits a warning */
param = strdup(opal_cmd_line_get_param(&cmd_line, "prefix", 0, 0));
if (0 != strcmp(param, path_to_mpirun)) {
orte_show_help("help-orterun.txt", "orterun:double-prefix",
true, orte_basename, orte_basename, param, path_to_mpirun);
/* let the path-to-mpirun take precedence since we
if (0 != strcmp(param, orterun_globals.prefix)) {
orte_show_help("help-orterun.txt", "orterun:app-prefix-conflict",
true, orte_basename, orterun_globals.prefix, param);
/* let the global-level prefix take precedence since we
* know that one is being used
*/
free(param);
param = path_to_mpirun;
param = orterun_globals.prefix;
} else {
/* since they match, just use param */
free(path_to_mpirun);
free(orterun_globals.prefix);
orterun_globals.prefix = NULL;
}
} else if (NULL != path_to_mpirun) {
param = path_to_mpirun;
} else if (NULL != orterun_globals.prefix) {
param = orterun_globals.prefix;
} else if (opal_cmd_line_is_taken(&cmd_line, "prefix")){
/* must be --prefix alone */
param = strdup(opal_cmd_line_get_param(&cmd_line, "prefix", 0, 0));
@ -1648,6 +1717,7 @@ static int create_app(int argc, char* argv[],
free(param);
}
}
}
/* Did the user specify a hostfile. Need to check for both
* hostfile and machine file.

Просмотреть файл

@ -54,6 +54,8 @@ struct orterun_globals_t {
bool wait_for_server;
int server_wait_timeout;
char *stdin_target;
char *prefix;
char *path_to_mpirun;
#if OPAL_ENABLE_FT_CR == 1
char *sstore_load;
#endif