1
1

Fix mpirun2 and ompi_mpi_init to be fully backward compatible. All required values are now passed via environmental parameters, and the receiving parties know what to do with them.

Added a field to the ompi_rte_node_schedule_t structure to keep track of the number of items on the environ list, thus making it easier to append more things to it. Adjusted the mca_pcm_base_build_base_env function correspondingly to take that field as an additional argument.

Changed mpirun2 to a .c program for convenience since it wasn't using any c++ features anyway.

This commit was SVN r2561.
Этот коммит содержится в:
Ralph Castain 2004-09-09 15:23:41 +00:00
родитель 08dc86af7c
Коммит c1ba40c631
13 изменённых файлов: 109 добавлений и 108 удалений

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

@ -6,7 +6,10 @@
#include "mca/mca.h"
#include "mca/base/base.h"
#include "mca/base/mca_base_param.h"
#include "util/output.h"
#include "util/proc_info.h"
#include "mca/oob/base/base.h"
#include "mca/gpr/base/base.h"
@ -193,6 +196,18 @@ mca_gpr_base_component_t mca_gpr_base_selected_component;
*/
int mca_gpr_base_open(void)
{
int id;
char *replica;
/* check the environment for replica information */
id = mca_base_param_register_string("gpr", "base", "replica", NULL, NULL);
mca_base_param_lookup_string(id, &replica);
if (NULL != replica) {
mca_oob_set_contact_info(replica);
ompi_process_info.gpr_replica = ns_base_create_process_name(0,0,0);
mca_oob_parse_contact_info(replica, ompi_process_info.gpr_replica, NULL);
}
/* Open up all available components */
if (OMPI_SUCCESS !=

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

@ -6,7 +6,10 @@
#include "mca/mca.h"
#include "mca/base/base.h"
#include "mca/base/mca_base_param.h"
#include "util/output.h"
#include "util/proc_info.h"
#include "mca/oob/base/base.h"
#include "mca/ns/base/base.h"
@ -38,6 +41,18 @@ mca_ns_base_component_t mca_ns_base_selected_component;
*/
int mca_ns_base_open(void)
{
int id;
char *replica;
/* check the environment for replica information */
id = mca_base_param_register_string("ns", "base", "replica", NULL, NULL);
mca_base_param_lookup_string(id, &replica);
if (NULL != replica) {
mca_oob_set_contact_info(replica);
ompi_process_info.ns_replica = ns_base_create_process_name(0,0,0);
mca_oob_parse_contact_info(replica, ompi_process_info.ns_replica, NULL);
}
/* Open up all available components */

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

@ -37,7 +37,7 @@ extern "C" {
ompi_rte_node_schedule_t *sched,
int *num_procs);
int mca_pcm_base_build_base_env(char **in_env, char ***out_envp);
int mca_pcm_base_build_base_env(char **in_env, int *envc, char ***out_envp);
int mca_pcm_base_ioexecvp(char **cmdv, int showout, char *outbuff,
int outbuffsize, int stderr_is_err);

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

@ -24,16 +24,15 @@ mca_pcm_base_no_unique_name(void)
int
mca_pcm_base_build_base_env(char **in_env, char ***out_envp)
mca_pcm_base_build_base_env(char **in_env, int *envc, char ***out_envp)
{
char **env = NULL;
int envc = 0;
int i;
int ret;
for (i = 0 ; in_env[i] != NULL ; ++i) {
if (0 == strncmp("OMPI_", in_env[i], strlen("OMPI_"))) {
ret = ompi_argv_append(&envc, &env, in_env[i]);
ret = ompi_argv_append(envc, &env, in_env[i]);
if (OMPI_SUCCESS != ret) {
ompi_argv_free(env);
return ret;

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

@ -63,8 +63,6 @@ int ompi_mpi_init(int argc, char **argv, int requested, int *provided)
bool have_hidden_threads;
ompi_proc_t** procs;
size_t nprocs;
ompi_cmd_line_t *cmd_line=NULL;
char *contact=NULL, **tmp, *nsreplica=NULL, *gprreplica=NULL;
char *error;
/* Become a OMPI process */
@ -89,44 +87,6 @@ int ompi_mpi_init(int argc, char **argv, int requested, int *provided)
return ret;
}
/* setup rte command line arguments */
cmd_line = OBJ_NEW(ompi_cmd_line_t);
ompi_rte_cmd_line_setup(cmd_line);
/* parse the rte command line arguments */
if (OMPI_SUCCESS != ompi_cmd_line_parse(cmd_line, true, argc, argv)) {
exit(ret);
}
if (ompi_cmd_line_is_taken(cmd_line, "initcontact")) {
if (NULL == (contact = ompi_cmd_line_get_param(cmd_line, "initcontact", 0, 0))) {
return OMPI_ERROR;
}
mca_oob_set_contact_info(contact);
}
if (ompi_cmd_line_is_taken(cmd_line, "nsreplica")) {
if (NULL == (nsreplica = ompi_cmd_line_get_param(cmd_line, "nsreplica", 0, 0))) {
return OMPI_ERROR;
}
mca_oob_set_contact_info(nsreplica);
ompi_process_info.ns_replica = ns_base_create_process_name(0,0,0); /* allocate a space */
mca_oob_parse_contact_info(nsreplica, ompi_process_info.ns_replica, NULL);
} else {
ompi_process_info.ns_replica = NULL;
}
if (ompi_cmd_line_is_taken(cmd_line, "gprreplica")) {
if (NULL == (gprreplica = ompi_cmd_line_get_param(cmd_line, "gprreplica", 0, 0))) {
return OMPI_ERROR;
}
mca_oob_set_contact_info(gprreplica);
ompi_process_info.gpr_replica = ns_base_create_process_name(0,0,0); /* allocate a space */
mca_oob_parse_contact_info(gprreplica, ompi_process_info.gpr_replica, NULL);
} else {
ompi_process_info.gpr_replica = NULL;
}
/* start the rest of the rte */
if (OMPI_SUCCESS != (ret = ompi_rte_init_stage2(&allow_multi_user_threads,
&have_hidden_threads))) {

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

@ -57,10 +57,6 @@ void ompi_rte_cmd_line_setup(ompi_cmd_line_t *cmd_line)
'\0', "hostfile", "hostfile", 1,
"Hostfile for this universe");
ompi_cmd_line_make_opt3(cmd_line, /* read in ompi_rte_parse_cmd_line */
'\0', "initcontact", "initcontact", 1,
"Initial oob contact info");
ompi_cmd_line_make_opt3(cmd_line, /* read in ompi_rte_parse_cmd_line */
'\0', "nsreplica", "nsreplica", 1,
"OOB contact info for name server replica assigned to this process");

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

@ -92,7 +92,7 @@
/* globals used by RTE */
int ompi_rte_debug_flag=0;
ompi_universe_t ompi_universe_info = {
/* .name = */ "default-universe",
/* .name = */ NULL,
/* .host = */ "localhost",
/* .uid = */ NULL,
/* .pid = */ 0,
@ -115,6 +115,7 @@ int ompi_rte_init_stage1(bool *allow_multi_user_threads, bool *have_hidden_threa
{
int ret;
bool user_threads, hidden_threads;
char *enviro_val;
*allow_multi_user_threads = true;
*have_hidden_threads = false;
@ -122,6 +123,20 @@ int ompi_rte_init_stage1(bool *allow_multi_user_threads, bool *have_hidden_threa
ret = mca_base_param_register_int("ompi", "rte", "debug", NULL, 0);
mca_base_param_lookup_int(ret, &ompi_rte_debug_flag);
enviro_val = getenv("OMPI_universe_name");
if (NULL != enviro_val) { /* universe name passed in environment */
ompi_universe_info.name = strdup(enviro_val);
ompi_process_info.my_universe = strdup(enviro_val);
} else {
ompi_universe_info.name = strdup("default-universe");
ompi_process_info.my_universe = strdup("default-universe");
}
enviro_val = getenv("OMPI_tmpdir_base");
if (NULL != enviro_val) { /* tmpdir base passed in environment */
ompi_process_info.tmpdir_base = strdup(enviro_val);
}
/*
* Initialize the event library
*/

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

@ -22,9 +22,8 @@
void ompi_rte_parse_cmd_line(ompi_cmd_line_t *cmd_line)
{
char *universe, *initcontact, *nsreplica, *gprreplica, *tmp;
char *universe, *nsreplica, *gprreplica, *tmp;
ompi_output(0, "parsing command line");
/* get universe name and store it, if user specified it */
/* otherwise, stick with default name */
@ -72,16 +71,6 @@ void ompi_rte_parse_cmd_line(ompi_cmd_line_t *cmd_line)
ompi_process_info.tmpdir_base = NULL;
}
/* get initial contact info */
if (ompi_cmd_line_is_taken(cmd_line, "initcontact")) {
if (NULL == ompi_cmd_line_get_param(cmd_line, "initcontact", 0, 0)) {
ompi_output(0, "error retrieving initial contact info - please report error to bugs@open-mpi.org");
return;
}
initcontact = strdup(ompi_cmd_line_get_param(cmd_line, "initcontact", 0, 0));
mca_oob_set_contact_info(initcontact);
}
/* see if name server replica provided */
if (ompi_cmd_line_is_taken(cmd_line, "nsreplica")) {
if (NULL == ompi_cmd_line_get_param(cmd_line, "nsreplica", 0, 0)) {
@ -89,9 +78,6 @@ void ompi_rte_parse_cmd_line(ompi_cmd_line_t *cmd_line)
return;
}
nsreplica = strdup(ompi_cmd_line_get_param(cmd_line, "nsreplica", 0, 0));
if (0 != strcmp(nsreplica, initcontact)) {
mca_oob_set_contact_info(nsreplica);
}
mca_oob_parse_contact_info(nsreplica, ompi_process_info.ns_replica, NULL);
} else {
ompi_process_info.ns_replica = NULL;
@ -104,8 +90,8 @@ void ompi_rte_parse_cmd_line(ompi_cmd_line_t *cmd_line)
return;
}
gprreplica = strdup(ompi_cmd_line_get_param(cmd_line, "gprreplica", 0, 0));
if (0 != strcmp(nsreplica, gprreplica) &&
0 != strcmp(initcontact, gprreplica)) { /* check to see if different */
if (NULL != nsreplica &&
0 != strcmp(nsreplica, gprreplica)) { /* check to see if different */
mca_oob_set_contact_info(gprreplica);
}
mca_oob_parse_contact_info(gprreplica, ompi_process_info.gpr_replica, NULL);

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

@ -46,6 +46,8 @@ struct ompi_rte_node_schedule_t {
int argc;
/** environ array for process to start (NULL terminated array) */
char **env;
/** length of env */
int envc;
/** working directory in which to start the application */
char *cwd;
/** list of nodes to start the process on (list of

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

@ -5,24 +5,35 @@
include $(top_srcdir)/config/Makefile.options
AM_CPPFLAGS = \
-DOMPI_PREFIX="\"$(prefix)\"" \
-DOMPI_BINDIR="\"$(bindir)\"" \
-DOMPI_LIBDIR="\"$(libdir)\"" \
-DOMPI_INCDIR="\"$(includedir)\"" \
-DOMPI_PKGLIBDIR="\"$(pkglibdir)\"" \
-DOMPI_SYSCONFDIR="\"$(sysconfdir)\"" \
-DOMPI_CONFIGURE_USER="\"@OMPI_CONFIGURE_USER@\"" \
-DOMPI_CONFIGURE_HOST="\"@OMPI_CONFIGURE_HOST@\"" \
-DOMPI_CONFIGURE_DATE="\"@OMPI_CONFIGURE_DATE@\""
libs = $(top_builddir)/src/libmpi.la
bin_SCRIPTS = mpirun mpiboot
EXTRA_DIST = $(bin_SCRIPTS)
bin_PROGRAMS = mpirun2
bin_PROGRAMS = \
mpirun2
mpirun2_SOURCES = \
mpirun2.cc
mpirun2_LDADD = \
$(libs) \
$(LIBMPI_EXTRA_LIBS) \
$(LIBOMPI_EXTRA_LIBS)
mpirun2_LDFLAGS = \
$(libs) \
$(LIBMPI_EXTRA_LDFLAGS) \
$(LIBOMPI_EXTRA_LDFLAGS)
mpirun2_DEPENDENCIES = \
$(libs)
mpirun2.h \
mpirun2.c
mpirun2_LDADD = \
$(libs) \
$(LIBMPI_EXTRA_LIBS) \
$(LIBOMPI_EXTRA_LIBS) \
$(top_builddir)/src/libmpi.la
mpirun2_DFLAGS = $(LIBMPI_EXTRA_LDFLAGS) $(LIBOMPI_EXTRA_LDFLAGS)
mpirun2_DEPENDENCIES = $(libs) \
$(mpirun2_LDADD)
clean-local:
test -z "$(OMPI_CXX_TEMPLATE_REPOSITORY)" || $(RM) -rf $(OMPI_CXX_TEMPLATE_REPOSITORY)

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

@ -1,4 +1,4 @@
/* -*- C++ -*-
/* -*- C -*-
*
* $HEADER$
*/
@ -24,14 +24,6 @@ extern char** environ;
static long num_running_procs;
static int
mpirun_monitor(ompi_process_name_t *name, int newstate, int status)
{
/* BWB - do state checks and the like... */
num_running_procs--;
return OMPI_SUCCESS;
}
int
main(int argc, char *argv[])
@ -145,13 +137,24 @@ main(int argc, char *argv[])
ompi_cmd_line_get_tail(cmd_line, &(sched->argc), &(sched->argv));
/* set initial contact info */
my_contact_info = mca_oob_get_contact_info();
ompi_argv_append(&(sched->argc), &(sched->argv), "-initcontact");
ompi_argv_append(&(sched->argc), &(sched->argv), my_contact_info);
ompi_argv_append(&(sched->argc), &(sched->argv), "-nsreplica");
ompi_argv_append(&(sched->argc), &(sched->argv), my_contact_info);
ompi_argv_append(&(sched->argc), &(sched->argv), "-gprreplica");
ompi_argv_append(&(sched->argc), &(sched->argv), my_contact_info);
mca_pcm_base_build_base_env(environ, &(sched->env));
mca_pcm_base_build_base_env(environ, &(sched->envc), &(sched->env));
asprintf(&tmp, "OMPI_MCA_ns_base_replica=%s", my_contact_info);
ompi_argv_append(&(sched->envc), &(sched->env), tmp);
free(tmp);
asprintf(&tmp, "OMPI_MCA_gpr_base_replica=%s", my_contact_info);
ompi_argv_append(&(sched->envc), &(sched->env), tmp);
free(tmp);
if (NULL != ompi_universe_info.name) {
asprintf(&tmp, "OMPI_universe_name=%s", ompi_universe_info.name);
ompi_argv_append(&(sched->envc), &(sched->env), tmp);
free(tmp);
}
if (ompi_cmd_line_is_taken(cmd_line, "tmpdir")) { /* user specified the tmp dir base */
asprintf(&tmp, "OMPI_tmpdir_base=%s", ompi_cmd_line_get_param(cmd_line, "tmpdir", 0, 0));
ompi_argv_append(&(sched->envc), &(sched->env), tmp);
free(tmp);
}
getcwd(cwd, MAXPATHLEN);
sched->cwd = strdup(cwd);
sched->nodelist = nodelist;

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

@ -128,11 +128,6 @@ int main(int argc, char **argv)
ompi_rte_parse_cmd_line(cmd_line);
/** RHC - THIS NEEDS TO BE FIXED **/
ompi_process_info.seed = true;
setenv("OMPI_MCA_oob_base_include", "tcp", 1);
/* start the initial barebones RTE (just OOB) so we can check universe existence */
if (OMPI_SUCCESS != (ret = mca_base_open())) {
/* JMS show_help */
@ -162,6 +157,11 @@ int main(int argc, char **argv)
ompi_process_info.my_universe = strdup(ompi_universe_info.name);
/* startup rest of RTE - needed for handshake with seed */
ompi_process_info.ns_replica = NULL;
ompi_process_info.gpr_replica = NULL;
ompi_rte_init_stage2(&multi_thread, &hidden_thread);
/* parse command line for rest of seed options */
ompi_rte_parse_daemon_cmd_line(cmd_line);
@ -173,7 +173,7 @@ int main(int argc, char **argv)
exit(-1);
} else if (pid == 0) { /* child process does the exec */
/* build the command line options for the seed
/* build the environment for the seed
* including universe name and tmpdir_base
*/
seed_argv = NULL;
@ -196,9 +196,9 @@ int main(int argc, char **argv)
ompi_argv_append(&seed_argc, &seed_argv, "-hostfile");
ompi_argv_append(&seed_argc, &seed_argv, ompi_universe_info.hostfile);
}
/* provide my contact info */
/* provide my contact info as the temporary registry replica*/
contact_info = mca_oob_get_contact_info();
ompi_argv_append(&seed_argc, &seed_argv, "-initcontact");
ompi_argv_append(&seed_argc, &seed_argv, "-gprreplica");
ompi_argv_append(&seed_argc, &seed_argv, contact_info);
/* add options for universe name and tmpdir_base, if provided */
ompi_argv_append(&seed_argc, &seed_argv, "-universe");

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

@ -56,5 +56,4 @@ ompi_pack_SOURCES = ompi_pack.c
ompi_pack_LDADD = \
$(top_builddir)/src/libmpi.la \
$(top_builddir)/test/support/libsupport.la
ompi_pack_DEPENDENCIES = $(ompi_session_dir_LDADD)
ompi_pack_DEPENDENCIES = $(ompi_pack_LDADD)