1
1
This commit was SVN r5814.
Этот коммит содержится в:
Ralph Castain 2005-05-23 14:22:35 +00:00
родитель 131d49152f
Коммит 93eb0d4b40
7 изменённых файлов: 185 добавлений и 8 удалений

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

@ -32,7 +32,6 @@ static int orte_rds_resfile_parse_site(char *site, FILE *fp);
static int orte_rds_resfile_parse_resource(orte_rds_cell_desc_t *cell, FILE *fp); static int orte_rds_resfile_parse_resource(orte_rds_cell_desc_t *cell, FILE *fp);
static int orte_rds_resfile_parse_resource(orte_rds_cell_desc_t *cell, FILE *fp) static int orte_rds_resfile_parse_resource(orte_rds_cell_desc_t *cell, FILE *fp)
{ {
char *line; char *line;
@ -191,6 +190,12 @@ int orte_rds_resfile_query(void)
OMPI_LOCK(&mca_rds_resfile_component.lock); OMPI_LOCK(&mca_rds_resfile_component.lock);
if (orte_rds_resfile_queried) {
OMPI_UNLOCK(&mca_rds_resfile_component.lock);
return ORTE_SUCCESS;
}
orte_rds_resfile_queried = true;
/* get the resource filename */ /* get the resource filename */
fileid = mca_base_param_register_string("rds", "resfile", "name", NULL, NULL); fileid = mca_base_param_register_string("rds", "resfile", "name", NULL, NULL);
mca_base_param_lookup_string(fileid, &resfile); mca_base_param_lookup_string(fileid, &resfile);

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

@ -73,6 +73,7 @@ typedef struct orte_rds_resfile_component_t orte_rds_resfile_component_t;
OMPI_COMP_EXPORT extern orte_rds_resfile_component_t mca_rds_resfile_component; OMPI_COMP_EXPORT extern orte_rds_resfile_component_t mca_rds_resfile_component;
OMPI_COMP_EXPORT extern orte_rds_base_module_t orte_rds_resfile_module; OMPI_COMP_EXPORT extern orte_rds_base_module_t orte_rds_resfile_module;
extern bool orte_rds_resfile_queried;
#if defined(c_plusplus) || defined(__cplusplus) #if defined(c_plusplus) || defined(__cplusplus)
} }

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

@ -66,6 +66,11 @@ orte_rds_base_module_t orte_rds_resfile_module = {
orte_rds_resfile_finalize orte_rds_resfile_finalize
}; };
/*
* Instantiate component variables
*/
bool orte_rds_resfile_queried;
/** /**
* Convience functions to lookup MCA parameter values. * Convience functions to lookup MCA parameter values.
*/ */
@ -99,6 +104,7 @@ static int orte_rds_resfile_open(void)
OBJ_CONSTRUCT(&mca_rds_resfile_component.lock, ompi_mutex_t); OBJ_CONSTRUCT(&mca_rds_resfile_component.lock, ompi_mutex_t);
mca_rds_resfile_component.debug = orte_rds_resfile_param_register_int("debug",1); mca_rds_resfile_component.debug = orte_rds_resfile_param_register_int("debug",1);
mca_rds_resfile_component.filename = orte_rds_resfile_param_register_string("file", NULL); mca_rds_resfile_component.filename = orte_rds_resfile_param_register_string("file", NULL);
orte_rds_resfile_queried = false;
return ORTE_SUCCESS; return ORTE_SUCCESS;
} }

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

@ -195,7 +195,7 @@ int orte_init_stage1(void)
free(orte_universe_info.name); free(orte_universe_info.name);
orte_universe_info.name = NULL; orte_universe_info.name = NULL;
pid = getpid(); pid = getpid();
if (0 > asprintf(&orte_universe_info.name, "%s-%d", universe, pid)) { if (0 > asprintf(&orte_universe_info.name, "%s-%d", universe, (int)pid)) {
ompi_output(0, "orte_init: failed to create unique universe name"); ompi_output(0, "orte_init: failed to create unique universe name");
return ret; return ret;
} }

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

@ -44,6 +44,7 @@
#include "threads/condition.h" #include "threads/condition.h"
#include "runtime/orte_wait.h" #include "runtime/orte_wait.h"
#include "util/argv.h" #include "util/argv.h"
#include "util/ompi_environ.h"
#include "util/output.h" #include "util/output.h"
#include "util/path.h" #include "util/path.h"
#include "util/univ_info.h" #include "util/univ_info.h"
@ -79,6 +80,10 @@ typedef struct {
*/ */
static ompi_mutex_t orte_setup_hnp_mutex; static ompi_mutex_t orte_setup_hnp_mutex;
static ompi_condition_t orte_setup_hnp_condition; static ompi_condition_t orte_setup_hnp_condition;
/* Local return code */
static int orte_setup_hnp_rc;
/* Local uri storage */
static char *orte_setup_hnp_orted_uri;
static orte_setup_hnp_cb_data_t orte_setup_hnp_cbdata = {NULL, NULL, NULL, 0}; static orte_setup_hnp_cb_data_t orte_setup_hnp_cbdata = {NULL, NULL, NULL, 0};
@ -421,6 +426,7 @@ MOVEON:
} }
/* fork a child to exec the rsh/ssh session */ /* fork a child to exec the rsh/ssh session */
orte_setup_hnp_rc = ORTE_SUCCESS;
pid = fork(); pid = fork();
if (pid < 0) { if (pid < 0) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
@ -446,7 +452,44 @@ MOVEON:
OMPI_THREAD_LOCK(&orte_setup_hnp_mutex); OMPI_THREAD_LOCK(&orte_setup_hnp_mutex);
ompi_condition_timedwait(&orte_setup_hnp_condition, &orte_setup_hnp_mutex, &ts); ompi_condition_timedwait(&orte_setup_hnp_condition, &orte_setup_hnp_mutex, &ts);
OMPI_THREAD_UNLOCK(&orte_setup_hnp_mutex); OMPI_THREAD_UNLOCK(&orte_setup_hnp_mutex);
return ORTE_SUCCESS;
if (ORTE_SUCCESS == orte_setup_hnp_rc) {
/* need to restart the local system so it can connect to the remote daemon.
* we only want to clear the run-time itself - we cannot close the OPAL
* utilities, though, or we will lose all of our MCA parameters
*/
orte_system_finalize();
/*
* now set the relevant MCA parameters to point us at the remote daemon...
*/
if (ORTE_SUCCESS != (rc = ompi_setenv("OMPI_MCA_gpr_replica_uri",
orte_setup_hnp_orted_uri, true, &environ))) {
fprintf(stderr, "orte_setup_hnp: could not set gpr_replica_uri in environ\n");
return rc;
}
if (ORTE_SUCCESS != (rc = ompi_setenv("OMPI_MCA_ns_replica_uri",
orte_setup_hnp_orted_uri, true, &environ))) {
fprintf(stderr, "orte_setup_hnp: could not set ns_replica_uri in environ\n");
return rc;
}
ompi_unsetenv("OMPI_MCA_seed", &environ);
/*
* ...re-init ourselves...
*/
if (ORTE_SUCCESS != (rc = orte_system_init())) {
ORTE_ERROR_LOG(rc);
return rc;
}
/*
* ...and we are now ready to go!
*/
return ORTE_SUCCESS;
}
return orte_setup_hnp_rc;
} }
CLEANUP: CLEANUP:
@ -463,15 +506,19 @@ static void orte_setup_hnp_recv(int status, orte_process_name_t* sender,
orte_buffer_t* buffer, orte_rml_tag_t tag, orte_buffer_t* buffer, orte_rml_tag_t tag,
void* cbdata) void* cbdata)
{ {
char *orted_uri;
size_t n=1; size_t n=1;
int rc; int rc;
OMPI_THREAD_LOCK(&orte_setup_hnp_mutex); OMPI_THREAD_LOCK(&orte_setup_hnp_mutex);
if (ORTE_SUCCESS != (rc = orte_dps.unpack(buffer, &orted_uri, &n, ORTE_STRING))) { if (ORTE_SUCCESS != (rc = orte_dps.unpack(buffer, &orte_setup_hnp_orted_uri, &n, ORTE_STRING))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
orte_setup_hnp_rc = rc;
ompi_condition_signal(&orte_setup_hnp_condition);
OMPI_THREAD_UNLOCK(&orte_setup_hnp_mutex);
return;
} }
ompi_output(0, "orteprobe: received uri %s", orted_uri); ompi_output(0, "orteprobe: received uri %s", orte_setup_hnp_orted_uri);
orte_setup_hnp_rc = ORTE_SUCCESS;
ompi_condition_signal(&orte_setup_hnp_condition); ompi_condition_signal(&orte_setup_hnp_condition);
OMPI_THREAD_UNLOCK(&orte_setup_hnp_mutex); OMPI_THREAD_UNLOCK(&orte_setup_hnp_mutex);
} }

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

@ -23,9 +23,10 @@ check_PROGRAMS = \
orte_os_path \ orte_os_path \
orte_sys_info \ orte_sys_info \
orte_os_create_dirpath \ orte_os_create_dirpath \
orte_session_dir \ orte_session_dir \
ompi_argv \ ompi_argv \
ompi_basename ompi_basename \
orte_universe_setup_file_io
TESTS = \ TESTS = \
$(check_PROGRAMS) $(check_PROGRAMS)
@ -79,3 +80,9 @@ orte_session_dir_LDADD = \
$(top_builddir)/test/support/libsupport.a $(top_builddir)/test/support/libsupport.a
orte_session_dir_DEPENDENCIES = $(orte_session_dir_LDADD) orte_session_dir_DEPENDENCIES = $(orte_session_dir_LDADD)
orte_universe_setup_file_io_SOURCES = orte_universe_setup_file_io.c
orte_universe_setup_file_io_LDADD = \
$(top_builddir)/src/libmpi.la \
$(top_builddir)/test/support/libsupport.a
orte_universe_setup_file_io_DEPENDENCIES = $(orte_universe_setup_file_io_LDADD)

111
test/util/orte_universe_setup_file_io.c Обычный файл
Просмотреть файл

@ -0,0 +1,111 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "orte_config.h"
#include "include/orte_constants.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#include "util/univ_info.h"
#include "util/universe_setup_file_io.h"
#include "support.h"
static bool test1(void); /* verify it returns info */
static bool test2(void); /* test second time through */
orte_universe_t orte_universe_info;
int main(int argc, char* argv[])
{
test_init("universe_setup_file_io");
/* initialize the univ_info structure */
orte_universe_info.name = strdup("default-universe");
orte_universe_info.host = strdup("test-host.domain.org");
orte_universe_info.uid = strdup("this-is-me");
orte_universe_info.persistence = true;
orte_universe_info.scope = strdup("private");
orte_universe_info.console = false;
orte_universe_info.seed_uri = strdup("0.0.0;tcp://128.165.148.81:52424");
orte_universe_info.console_connected = false;
orte_universe_info.scriptfile = NULL;
if (test1()) {
test_success();
}
else {
test_failure("universe_setup_file_io write failed");
}
if (test2()) {
test_success();
}
else {
test_failure("universe_setup_file_io read failed");
}
test_finalize();
return 0;
}
static bool test1(void)
{
int rc;
/* Test write */
if (ORTE_SUCCESS != (rc = orte_write_universe_setup_file("test-file", &orte_universe_info))) {
fprintf(stderr, "universe_setup_file_io: failed write with code %d\n", rc);
return false;
}
return true;
}
static bool test2(void)
{
int rc;
orte_universe_t univ;
/* Test read */
if (ORTE_SUCCESS != (rc = orte_read_universe_setup_file("test-file", &univ))) {
fprintf(stderr, "universe_setup_file_io: failed read with code %d\n", rc);
return false;
}
if (0 != strcmp(orte_universe_info.name, univ.name) ||
0 != strcmp(orte_universe_info.host, univ.host) ||
0 != strcmp(orte_universe_info.uid, univ.uid) ||
orte_universe_info.persistence != univ.persistence ||
0 != strcmp(orte_universe_info.scope, univ.scope) ||
orte_universe_info.console != univ.console ||
0 != strcmp(orte_universe_info.seed_uri, univ.seed_uri) ||
orte_universe_info.console_connected != univ.console_connected ||
orte_universe_info.scriptfile != univ.scriptfile) {
fprintf(stderr, "universe_setup_file_io: read mismatch\n");
return false;
}
return true;
}