diff --git a/ompi/mca/dpm/orte/dpm_orte.c b/ompi/mca/dpm/orte/dpm_orte.c index 1eb1a42b9a..e6ba6c3aa2 100644 --- a/ompi/mca/dpm/orte/dpm_orte.c +++ b/ompi/mca/dpm/orte/dpm_orte.c @@ -497,6 +497,7 @@ static int spawn(int count, char **array_of_commands, char host[OMPI_PATH_MAX]; /*** should define OMPI_HOST_MAX ***/ char prefix[OMPI_PATH_MAX]; char stdin_target[OMPI_PATH_MAX]; + char params[OMPI_PATH_MAX]; orte_job_t *jdata; orte_app_context_t *app; @@ -686,6 +687,12 @@ static int spawn(int count, char **array_of_commands, jdata->controls |= ORTE_JOB_CONTROL_NON_ORTE_JOB; } + /* see if this is an MCA param that the user wants applied to the child job */ + ompi_info_get (array_of_info[i], "ompi_param", valuelen, params, &flag); + if ( flag ) { + opal_argv_append_unique_nosize(&app->env, params, true); + } + /* see if user specified what to do with stdin - defaults to * not forwarding stdin to child processes */ diff --git a/ompi/mpi/man/man3/MPI_Comm_spawn.3in b/ompi/mpi/man/man3/MPI_Comm_spawn.3in index 1c0d32dbee..1098e76b4c 100644 --- a/ompi/mpi/man/man3/MPI_Comm_spawn.3in +++ b/ompi/mpi/man/man3/MPI_Comm_spawn.3in @@ -140,6 +140,10 @@ ompi_non_mpi bool If set to true, launching a non-MPI this flag when launching a non-MPI application will cause both the child and parent jobs to "hang". +ompi_param char * Pass an OMPI MCA parameter to the child job. + If that parameter already exists in the + environment, the value will be overwritten + by the provided value. .fi \fIbool\fP info keys are actually strings but are evaluated as diff --git a/ompi/mpi/man/man3/MPI_Comm_spawn_multiple.3in b/ompi/mpi/man/man3/MPI_Comm_spawn_multiple.3in index 31036b0702..e1fe1d7c94 100644 --- a/ompi/mpi/man/man3/MPI_Comm_spawn_multiple.3in +++ b/ompi/mpi/man/man3/MPI_Comm_spawn_multiple.3in @@ -151,6 +151,10 @@ ompi_non_mpi bool If set to true, launching a non-MPI this flag when launching a non-MPI application will cause both the child and parent jobs to "hang". +ompi_param char * Pass an OMPI MCA parameter to the child job. + If that parameter already exists in the + environment, the value will be overwritten + by the provided value. .fi .sp diff --git a/opal/util/argv.c b/opal/util/argv.c index cca66b8275..7433b943c8 100644 --- a/opal/util/argv.c +++ b/opal/util/argv.c @@ -90,7 +90,7 @@ int opal_argv_append_nosize(char ***argv, const char *arg) return OPAL_SUCCESS; } -int opal_argv_append_unique_nosize(char ***argv, const char *arg) +int opal_argv_append_unique_nosize(char ***argv, const char *arg, bool overwrite) { int i; @@ -104,7 +104,11 @@ int opal_argv_append_unique_nosize(char ***argv, const char *arg) /* see if this arg is already present in the array */ for (i=0; NULL != (*argv)[i]; i++) { if (0 == strcmp(arg, (*argv)[i])) { - /* already exists - nothing to do */ + /* already exists - are we authorized to overwrite? */ + if (overwrite) { + free((*argv)[i]); + (*argv)[i] = strdup(arg); + } return OPAL_SUCCESS; } } diff --git a/opal/util/argv.h b/opal/util/argv.h index 6f69bf0c96..e6ea7e84be 100644 --- a/opal/util/argv.h +++ b/opal/util/argv.h @@ -91,15 +91,16 @@ OPAL_DECLSPEC int opal_argv_append_nosize(char ***argv, const char *arg); * * @param argv Pointer to an argv array. * @param str Pointer to the string to append. + * @param bool Whether or not to overwrite a matching value if found * * @retval OPAL_SUCCESS On success * @retval OPAL_ERROR On failure * * This function is identical to the opal_argv_append_nosize() function * except that it only appends the provided argument if it does not already - * exist in the provided array. + * exist in the provided array, or overwrites it if it is. */ -OPAL_DECLSPEC int opal_argv_append_unique_nosize(char ***argv, const char *arg); +OPAL_DECLSPEC int opal_argv_append_unique_nosize(char ***argv, const char *arg, bool overwrite); /** * Free a NULL-terminated argv array. diff --git a/orte/mca/ras/base/ras_base_node.c b/orte/mca/ras/base/ras_base_node.c index f4d59ed84b..cdf830a1f3 100644 --- a/orte/mca/ras/base/ras_base_node.c +++ b/orte/mca/ras/base/ras_base_node.c @@ -123,12 +123,12 @@ int orte_ras_base_node_insert(opal_list_t* nodes, orte_job_t *jdata) /* if the node name is different, store it as an alias */ if (0 != strcmp(node->name, hnp_node->name)) { /* add to list of aliases for this node - only add if unique */ - opal_argv_append_unique_nosize(&hnp_node->alias, node->name); + opal_argv_append_unique_nosize(&hnp_node->alias, node->name, false); } if (NULL != node->alias) { /* now copy over any aliases that are unique */ for (i=0; NULL != node->alias[i]; i++) { - opal_argv_append_unique_nosize(&hnp_node->alias, node->alias[i]); + opal_argv_append_unique_nosize(&hnp_node->alias, node->alias[i], false); } } } diff --git a/orte/util/dash_host/dash_host.c b/orte/util/dash_host/dash_host.c index aebaaed6c6..cbccaf1ed1 100644 --- a/orte/util/dash_host/dash_host.c +++ b/orte/util/dash_host/dash_host.c @@ -117,7 +117,7 @@ int orte_util_add_dash_host_nodes(opal_list_t *nodes, if (orte_show_resolved_nodenames && 0 != strcmp(mapped_nodes[i], orte_process_info.nodename)) { /* add to list of aliases for this node - only add if unique */ - opal_argv_append_unique_nosize(&node->alias, mapped_nodes[i]); + opal_argv_append_unique_nosize(&node->alias, mapped_nodes[i], false); } node->name = strdup(orte_process_info.nodename); } else { diff --git a/orte/util/hostfile/hostfile.c b/orte/util/hostfile/hostfile.c index 29b2d670e8..7750c78f61 100644 --- a/orte/util/hostfile/hostfile.c +++ b/orte/util/hostfile/hostfile.c @@ -236,7 +236,7 @@ static int hostfile_parse_line(int token, opal_list_t* updates, opal_list_t* exc /* do we need to record an alias for this node? */ if (NULL != node_alias) { /* add to list of aliases for this node - only add if unique */ - opal_argv_append_unique_nosize(&node->alias, node_alias); + opal_argv_append_unique_nosize(&node->alias, node_alias, false); free(node_alias); } } else if (ORTE_HOSTFILE_RELATIVE == token) {