1
1

Now it's time to update ORTE. Cleanup most of the ORTE tools. Force them

to use opal_basename and opal_dirname. Don't create the path manually. Use
the specialized opal functions instead.

This commit was SVN r11345.
Этот коммит содержится в:
George Bosilca 2006-08-23 02:35:00 +00:00
родитель b621313653
Коммит b4732f557a
7 изменённых файлов: 62 добавлений и 53 удалений

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

@ -66,8 +66,6 @@
#include "opal/runtime/opal.h" #include "opal/runtime/opal.h"
#include "orte/runtime/runtime.h" #include "orte/runtime/runtime.h"
extern char **environ;
/****************** /******************
* Local Functions * Local Functions
******************/ ******************/
@ -148,6 +146,13 @@ main(int argc, char *argv[])
orte_universe_t *search_result; orte_universe_t *search_result;
search_result = (orte_universe_t *) item; search_result = (orte_universe_t *) item;
/*
* Avoid cleaning our own universe.
*/
if( (0 == strcmp(search_result->name, orte_universe_info.name)) &&
(strlen(search_result->name) == strlen(orte_universe_info.name)) ) {
continue;
}
/* /*
* Try to connect to the universe * Try to connect to the universe
*/ */
@ -182,6 +187,9 @@ main(int argc, char *argv[])
OBJ_RELEASE(item); OBJ_RELEASE(item);
} }
orte_finalize();
opal_finalize();
return exit_status; return exit_status;
} }
@ -217,8 +225,7 @@ static int parse_args(int argc, char *argv[]) {
} }
opal_setenv(mca_base_param_env_var("crs_base_is_tool"), opal_setenv(mca_base_param_env_var("crs_base_is_tool"),
"1", "1", true, NULL);
true, &environ);
/** /**
* Now start parsing our specific arguments * Now start parsing our specific arguments
@ -244,8 +251,7 @@ static int orte_clean_init(void) {
* attach no matter if it is identified as private or not. * attach no matter if it is identified as private or not.
*/ */
opal_setenv(mca_base_param_env_var("universe_console"), opal_setenv(mca_base_param_env_var("universe_console"),
"1", "1", true, NULL);
true, &environ);
/*************************** /***************************
* We need all of OPAL * We need all of OPAL
@ -316,7 +322,7 @@ static int orte_clean_universe(orte_universe_t *universe) {
/******************** /********************
* If the session directory is empty, then remove that too * If the session directory is empty, then remove that too
********************/ ********************/
asprintf(&session_dir, "%s/%s", prefix, frontend); session_dir = opal_os_path( false, prefix, frontend, NULL );
opal_os_dirpath_destroy(session_dir, false, NULL ); opal_os_dirpath_destroy(session_dir, false, NULL );
/******************** /********************
@ -339,7 +345,8 @@ static int orte_clean_universe(orte_universe_t *universe) {
return exit_status; return exit_status;
} }
static int orte_clean_check_universe(orte_universe_t *universe) { static int orte_clean_check_universe(orte_universe_t *universe)
{
int ret, exit_status = ORTE_SUCCESS; int ret, exit_status = ORTE_SUCCESS;
struct timeval ping_wait = {2, 0}; struct timeval ping_wait = {2, 0};

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

@ -71,9 +71,6 @@
#include "opal/runtime/opal.h" #include "opal/runtime/opal.h"
#include "orte/runtime/runtime.h" #include "orte/runtime/runtime.h"
extern char **environ;
/******************* /*******************
* Universe/job/vpid information Objects * Universe/job/vpid information Objects
*******************/ *******************/
@ -93,8 +90,6 @@ struct orte_ps_vpid_info_t {
}; };
typedef struct orte_ps_vpid_info_t orte_ps_vpid_info_t; typedef struct orte_ps_vpid_info_t orte_ps_vpid_info_t;
OBJ_CLASS_DECLARATION(orte_ps_vpid_info_t);
void orte_ps_vpid_info_construct(orte_ps_vpid_info_t *obj); void orte_ps_vpid_info_construct(orte_ps_vpid_info_t *obj);
void orte_ps_vpid_info_destruct( orte_ps_vpid_info_t *obj); void orte_ps_vpid_info_destruct( orte_ps_vpid_info_t *obj);
@ -129,8 +124,6 @@ struct orte_ps_job_info_t {
}; };
typedef struct orte_ps_job_info_t orte_ps_job_info_t; typedef struct orte_ps_job_info_t orte_ps_job_info_t;
OBJ_CLASS_DECLARATION(orte_ps_job_info_t);
void orte_ps_job_info_construct(orte_ps_job_info_t *obj); void orte_ps_job_info_construct(orte_ps_job_info_t *obj);
void orte_ps_job_info_destruct( orte_ps_job_info_t *obj); void orte_ps_job_info_destruct( orte_ps_job_info_t *obj);
@ -155,8 +148,6 @@ struct orte_ps_universe_info_t {
}; };
typedef struct orte_ps_universe_info_t orte_ps_universe_info_t; typedef struct orte_ps_universe_info_t orte_ps_universe_info_t;
OBJ_CLASS_DECLARATION(orte_ps_universe_info_t);
void orte_ps_universe_info_construct(orte_ps_universe_info_t *obj); void orte_ps_universe_info_construct(orte_ps_universe_info_t *obj);
void orte_ps_universe_info_destruct( orte_ps_universe_info_t *obj); void orte_ps_universe_info_destruct( orte_ps_universe_info_t *obj);
@ -404,6 +395,7 @@ main(int argc, char *argv[])
return ret; return ret;
} }
} }
opal_finalize();
return exit_status; return exit_status;
} }
@ -481,8 +473,7 @@ static int orte_ps_init(void) {
* attach no matter if it is identified as private or not. * attach no matter if it is identified as private or not.
*/ */
opal_setenv(mca_base_param_env_var("universe_console"), opal_setenv(mca_base_param_env_var("universe_console"),
"1", "1", true, NULL);
true, &environ);
/*************************** /***************************
* We need all of OPAL * We need all of OPAL
@ -805,8 +796,8 @@ static int pretty_print_vpids(orte_ps_job_info_t *job) {
/* /*
* Caculate segment lengths * Caculate segment lengths
*/ */
len_o_proc_name = strlen("ORTE Name"); len_o_proc_name = (int)strlen("ORTE Name");
len_proc_name = strlen("Process Name"); len_proc_name = (int)strlen("Process Name");
len_rank = 6; len_rank = 6;
len_pid = 6; len_pid = 6;
len_state = 0; len_state = 0;
@ -940,8 +931,7 @@ static int connect_to_universe(orte_universe_t universe_info) {
* Set the environment universe information * Set the environment universe information
*/ */
opal_setenv(mca_base_param_env_var("universe"), opal_setenv(mca_base_param_env_var("universe"),
univ_mca_param, univ_mca_param, true, NULL);
true, &environ);
/* /*
* Restart ORTE in the requested universe * Restart ORTE in the requested universe

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

@ -68,8 +68,6 @@
#include "orte/tools/orted/orted.h" #include "orte/tools/orted/orted.h"
extern char **environ;
orted_globals_t orted_globals; orted_globals_t orted_globals;
static struct opal_event term_handler; static struct opal_event term_handler;
@ -171,9 +169,6 @@ opal_cmd_line_init_t orte_cmd_line_opts[] = {
NULL, OPAL_CMD_LINE_TYPE_NULL, NULL } NULL, OPAL_CMD_LINE_TYPE_NULL, NULL }
}; };
extern char **environ;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int ret = 0; int ret = 0;
@ -220,13 +215,13 @@ int main(int argc, char *argv[])
*/ */
if (orted_globals.name) { if (orted_globals.name) {
if (ORTE_SUCCESS != (ret = opal_setenv("OMPI_MCA_ns_nds", if (ORTE_SUCCESS != (ret = opal_setenv("OMPI_MCA_ns_nds",
"env", true, &environ))) { "env", true, NULL))) {
opal_show_help("help-orted.txt", "orted:environ", false, opal_show_help("help-orted.txt", "orted:environ", false,
"OMPI_MCA_ns_nds", "env", ret); "OMPI_MCA_ns_nds", "env", ret);
return ret; return ret;
} }
if (ORTE_SUCCESS != (ret = opal_setenv("OMPI_MCA_ns_nds_name", if (ORTE_SUCCESS != (ret = opal_setenv("OMPI_MCA_ns_nds_name",
orted_globals.name, true, &environ))) { orted_globals.name, true, NULL))) {
opal_show_help("help-orted.txt", "orted:environ", false, opal_show_help("help-orted.txt", "orted:environ", false,
"OMPI_MCA_ns_nds_name", orted_globals.name, ret); "OMPI_MCA_ns_nds_name", orted_globals.name, ret);
return ret; return ret;
@ -236,13 +231,13 @@ int main(int argc, char *argv[])
* requires that they be set * requires that they be set
*/ */
if (ORTE_SUCCESS != (ret = opal_setenv("OMPI_MCA_ns_nds_vpid_start", if (ORTE_SUCCESS != (ret = opal_setenv("OMPI_MCA_ns_nds_vpid_start",
orted_globals.vpid_start, true, &environ))) { orted_globals.vpid_start, true, NULL))) {
opal_show_help("help-orted.txt", "orted:environ", false, opal_show_help("help-orted.txt", "orted:environ", false,
"OMPI_MCA_ns_nds_vpid_start", orted_globals.vpid_start, ret); "OMPI_MCA_ns_nds_vpid_start", orted_globals.vpid_start, ret);
return ret; return ret;
} }
if (ORTE_SUCCESS != (ret = opal_setenv("OMPI_MCA_ns_nds_num_procs", if (ORTE_SUCCESS != (ret = opal_setenv("OMPI_MCA_ns_nds_num_procs",
orted_globals.num_procs, true, &environ))) { orted_globals.num_procs, true, NULL))) {
opal_show_help("help-orted.txt", "orted:environ", false, opal_show_help("help-orted.txt", "orted:environ", false,
"OMPI_MCA_ns_nds_num_procs", orted_globals.num_procs, ret); "OMPI_MCA_ns_nds_num_procs", orted_globals.num_procs, ret);
return ret; return ret;
@ -250,8 +245,7 @@ int main(int argc, char *argv[])
} }
if (orted_globals.ns_nds) { if (orted_globals.ns_nds) {
if (ORTE_SUCCESS != (ret = opal_setenv("OMPI_MCA_ns_nds", if (ORTE_SUCCESS != (ret = opal_setenv("OMPI_MCA_ns_nds",
orted_globals.ns_nds, true, orted_globals.ns_nds, true, NULL))) {
&environ))) {
opal_show_help("help-orted.txt", "orted:environ", false, opal_show_help("help-orted.txt", "orted:environ", false,
"OMPI_MCA_ns_nds", "env", ret); "OMPI_MCA_ns_nds", "env", ret);
return ret; return ret;
@ -347,7 +341,7 @@ int main(int argc, char *argv[])
if (orted_globals.mpi_call_yield > 0) { if (orted_globals.mpi_call_yield > 0) {
char *var; char *var;
var = mca_base_param_environ_variable("mpi", NULL, "yield_when_idle"); var = mca_base_param_environ_variable("mpi", NULL, "yield_when_idle");
opal_setenv(var, "1", true, &environ); opal_setenv(var, "1", true, NULL);
} }
/* setup callback on jobid */ /* setup callback on jobid */

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

@ -30,6 +30,10 @@
#include "opal/util/cmd_line.h" #include "opal/util/cmd_line.h"
#include "opal/mca/mca.h" #include "opal/mca/mca.h"
#if defined(c_plusplus) || defined(__cplusplus)
extern "C" {
#endif
/* /*
* Definitions needed for communication * Definitions needed for communication
*/ */
@ -93,5 +97,8 @@ extern orted_globals_t orted_globals;
/* extern char *path_pkglibdir; */ /* extern char *path_pkglibdir; */
/* extern char *path_sysconfdir; */ /* extern char *path_sysconfdir; */
#if defined(c_plusplus) || defined(__cplusplus)
}
#endif
#endif /* ORTED_H */ #endif /* ORTED_H */

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

@ -31,6 +31,10 @@
#include "opal/mca/mca.h" #include "opal/mca/mca.h"
#include "orte/tools/orted/orted.h" #include "orte/tools/orted/orted.h"
#if defined(c_plusplus) || defined(__cplusplus)
extern "C" {
#endif
/* /*
* Globals * Globals
*/ */
@ -48,4 +52,8 @@ typedef struct {
extern orteprobe_globals_t orteprobe_globals; extern orteprobe_globals_t orteprobe_globals;
#if defined(c_plusplus) || defined(__cplusplus)
}
#endif
#endif /* ORTEPROBE_H */ #endif /* ORTEPROBE_H */

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

@ -71,11 +71,6 @@
#include "orterun.h" #include "orterun.h"
#include "totalview.h" #include "totalview.h"
/*
* The environment
*/
extern char** environ;
/* /*
* Globals * Globals
*/ */
@ -263,7 +258,9 @@ opal_cmd_line_init_t cmd_line_init[] = {
NULL, OPAL_CMD_LINE_TYPE_NULL, NULL } NULL, OPAL_CMD_LINE_TYPE_NULL, NULL }
}; };
#if !defined(__WINDOWS__)
extern char** environ;
#endif /* !defined(__WINDOWS__) */
/* /*
* Local functions * Local functions
*/ */
@ -306,7 +303,7 @@ int orterun(int argc, char *argv[])
/* Convert the list of apps to an array of orte_app_context_t /* Convert the list of apps to an array of orte_app_context_t
pointers */ pointers */
array_size = orte_pointer_array_get_size(apps_pa); array_size = orte_pointer_array_get_size(apps_pa);
apps = malloc(sizeof(orte_app_context_t *) * array_size); apps = (orte_app_context_t**)malloc(sizeof(orte_app_context_t *) * array_size);
if (NULL == apps) { if (NULL == apps) {
opal_show_help("help-orterun.txt", "orterun:call-failed", opal_show_help("help-orterun.txt", "orterun:call-failed",
true, orterun_basename, "system", "malloc returned NULL", errno); true, orterun_basename, "system", "malloc returned NULL", errno);
@ -328,7 +325,7 @@ int orterun(int argc, char *argv[])
true, orterun_basename); true, orterun_basename);
exit(1); exit(1);
} }
proc_infos = malloc(sizeof(struct proc_info_t) * j); proc_infos = (struct proc_info_t*)malloc(sizeof(struct proc_info_t) * j);
if (NULL == proc_infos) { if (NULL == proc_infos) {
opal_show_help("help-orterun.txt", "orterun:call-failed", opal_show_help("help-orterun.txt", "orterun:call-failed",
true, orterun_basename, "system", "malloc returned NULL", errno); true, orterun_basename, "system", "malloc returned NULL", errno);
@ -359,7 +356,7 @@ int orterun(int argc, char *argv[])
false, false, (int)false, &iparam); false, false, (int)false, &iparam);
if (iparam) { if (iparam) {
char *tmp = mca_base_param_environ_variable("orte", "debug", "daemons"); char *tmp = mca_base_param_environ_variable("orte", "debug", "daemons");
if (ORTE_SUCCESS != (rc = opal_setenv(tmp, "1", true, &environ))) { if (ORTE_SUCCESS != (rc = opal_setenv(tmp, "1", true, NULL))) {
opal_show_help("help-orterun.txt", "orterun:environ", false, opal_show_help("help-orterun.txt", "orterun:environ", false,
orterun_basename, tmp, "1", rc); orterun_basename, tmp, "1", rc);
free(tmp); free(tmp);
@ -372,7 +369,7 @@ int orterun(int argc, char *argv[])
false, false, 0, &iparam); false, false, 0, &iparam);
if (iparam) { if (iparam) {
char *tmp = mca_base_param_environ_variable("orte", NULL, "debug"); char *tmp = mca_base_param_environ_variable("orte", NULL, "debug");
if (ORTE_SUCCESS != (rc = opal_setenv(tmp, "1", true, &environ))) { if (ORTE_SUCCESS != (rc = opal_setenv(tmp, "1", true, NULL))) {
opal_show_help("help-orterun.txt", "orterun:environ", false, opal_show_help("help-orterun.txt", "orterun:environ", false,
orterun_basename, tmp, "1", rc); orterun_basename, tmp, "1", rc);
free(tmp); free(tmp);
@ -386,7 +383,7 @@ int orterun(int argc, char *argv[])
if (iparam) { if (iparam) {
char *tmp = mca_base_param_environ_variable("orte", "debug", char *tmp = mca_base_param_environ_variable("orte", "debug",
"daemons_file"); "daemons_file");
if (ORTE_SUCCESS != (rc = opal_setenv(tmp, "1", true, &environ))) { if (ORTE_SUCCESS != (rc = opal_setenv(tmp, "1", true, NULL))) {
opal_show_help("help-orterun.txt", "orterun:environ", false, opal_show_help("help-orterun.txt", "orterun:environ", false,
orterun_basename, tmp, "1", rc); orterun_basename, tmp, "1", rc);
free(tmp); free(tmp);
@ -400,7 +397,7 @@ int orterun(int argc, char *argv[])
if (iparam) { if (iparam) {
char *tmp = mca_base_param_environ_variable("orte", NULL, char *tmp = mca_base_param_environ_variable("orte", NULL,
"no_daemonize"); "no_daemonize");
if (ORTE_SUCCESS != (rc = opal_setenv(tmp, "1", true, &environ))) { if (ORTE_SUCCESS != (rc = opal_setenv(tmp, "1", true, NULL))) {
opal_show_help("help-orterun.txt", "orterun:environ", false, opal_show_help("help-orterun.txt", "orterun:environ", false,
orterun_basename, tmp, "1", rc); orterun_basename, tmp, "1", rc);
free(tmp); free(tmp);
@ -751,7 +748,7 @@ static void abort_signal_callback(int fd, short flags, void *arg)
*/ */
static void signal_forward_callback(int fd, short event, void *arg) static void signal_forward_callback(int fd, short event, void *arg)
{ {
struct opal_event *signal = arg; struct opal_event *signal = (struct opal_event*)arg;
int signum, ret; int signum, ret;
OPAL_TRACE(1); OPAL_TRACE(1);
@ -1103,7 +1100,6 @@ static int create_app(int argc, char* argv[], orte_app_context_t **app_ptr,
int i, j, count, rc; int i, j, count, rc;
char *param, *value, *value2; char *param, *value, *value2;
orte_app_context_t *app = NULL; orte_app_context_t *app = NULL;
extern char **environ;
#if 0 /* Used only in the C/N notion case, remove to silence compiler warnings */ #if 0 /* Used only in the C/N notion case, remove to silence compiler warnings */
orte_std_cntr_t l, len; orte_std_cntr_t l, len;
#endif #endif
@ -1307,19 +1303,24 @@ static int create_app(int argc, char* argv[], orte_app_context_t **app_ptr,
if (opal_cmd_line_is_taken(&cmd_line, "prefix")) { if (opal_cmd_line_is_taken(&cmd_line, "prefix")) {
param = opal_cmd_line_get_param(&cmd_line, "prefix", 0, 0); param = opal_cmd_line_get_param(&cmd_line, "prefix", 0, 0);
} else { } else {
char* tmp_basename = NULL;
/* If they specified an absolute path, strip off the /* If they specified an absolute path, strip off the
/bin/<exec_name>" and leave just the prefix */ /bin/<exec_name>" and leave just the prefix */
param = strdup(dirname(argv[0])); param = opal_dirname(argv[0]);
/* Quick sanity check to ensure we got /* Quick sanity check to ensure we got
something/bin/<exec_name> and that the installation something/bin/<exec_name> and that the installation
tree is at least more or less what we expect it to tree is at least more or less what we expect it to
be */ be */
if (0 == strcmp("bin", basename(param))) { tmp_basename = opal_basename(param);
param = dirname(param); if (0 == strcmp("bin", tmp_basename)) {
char* tmp = param;
param = opal_dirname(tmp);
free(tmp);
} else { } else {
free(param); free(param);
param = NULL; param = NULL;
} }
free(tmp_basename);
} }
if (NULL != param) { if (NULL != param) {
@ -1344,7 +1345,7 @@ static int create_app(int argc, char* argv[], orte_app_context_t **app_ptr,
if (opal_cmd_line_is_taken(&cmd_line, "rawmap")) { if (opal_cmd_line_is_taken(&cmd_line, "rawmap")) {
j = opal_cmd_line_get_ninsts(&cmd_line, "rawmap"); j = opal_cmd_line_get_ninsts(&cmd_line, "rawmap");
app->map_data = malloc(sizeof(orte_app_context_map_t*) * j); app->map_data = (orte_app_context_map_t**)malloc(sizeof(orte_app_context_map_t*) * j);
if (NULL == app->map_data) { if (NULL == app->map_data) {
rc = ORTE_ERR_OUT_OF_RESOURCE; rc = ORTE_ERR_OUT_OF_RESOURCE;
goto cleanup; goto cleanup;

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

@ -52,7 +52,9 @@
/* /*
* The environment * The environment
*/ */
#if !defined(__WINDOWS__)
extern char **environ; extern char **environ;
#endif /* !defined(__WINDOWS__) */
#include "opal/util/opal_environ.h" #include "opal/util/opal_environ.h"
#include "opal/util/output.h" #include "opal/util/output.h"