From fd632147df01118b6357c858193ad683fe1d5c55 Mon Sep 17 00:00:00 2001 From: Ralph Castain Date: Sat, 10 Nov 2012 04:11:40 +0000 Subject: [PATCH] Per patch from Nathan, with a few fixes, cleanup the orte-info tool This commit was SVN r27581. --- orte/tools/orte-info/components.c | 474 ++---------------------------- orte/tools/orte-info/orte-info.c | 5 +- orte/tools/orte-info/orte-info.h | 4 +- orte/tools/orte-info/param.c | 4 +- orte/tools/orte-info/version.c | 14 +- 5 files changed, 43 insertions(+), 458 deletions(-) diff --git a/orte/tools/orte-info/components.c b/orte/tools/orte-info/components.c index a09a5ad8fc..a66f9a6ce5 100644 --- a/orte/tools/orte-info/components.c +++ b/orte/tools/orte-info/components.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana * University Research and Technology @@ -10,7 +11,7 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2006-2012 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2010-2011 Los Alamos National Security, LLC. + * Copyright (c) 2010-2012 Los Alamos National Security, LLC. * All rights reserved. * $COPYRIGHT$ * @@ -30,67 +31,8 @@ #include "opal/runtime/opal_info_support.h" #include "opal/mca/event/base/base.h" #include "opal/util/output.h" -#include "opal/mca/base/base.h" -#include "opal/mca/backtrace/backtrace.h" -#include "opal/mca/backtrace/base/base.h" -#include "opal/mca/hwloc/base/base.h" -#include "opal/mca/shmem/shmem.h" -#include "opal/mca/shmem/base/base.h" -#include "opal/mca/memory/memory.h" -#include "opal/mca/memory/base/base.h" -#include "opal/mca/memchecker/memchecker.h" -#include "opal/mca/memchecker/base/base.h" -#include "opal/mca/timer/timer.h" -#include "opal/mca/timer/base/base.h" -#include "opal/mca/installdirs/installdirs.h" -#include "opal/mca/installdirs/base/base.h" -#if OPAL_ENABLE_FT_CR == 1 -#include "opal/mca/crs/crs.h" -#include "opal/mca/crs/base/base.h" -#endif -#include "opal/runtime/opal.h" -#include "opal/dss/dss.h" -#include "opal/mca/if/base/base.h" - -#include "orte/mca/errmgr/errmgr.h" -#include "orte/mca/errmgr/base/base.h" -#include "orte/mca/grpcomm/grpcomm.h" -#include "orte/mca/grpcomm/base/base.h" -#include "orte/mca/db/db.h" -#include "orte/mca/db/base/base.h" -#include "orte/mca/ess/ess.h" -#include "orte/mca/ess/base/base.h" -#include "orte/util/show_help.h" -#include "orte/util/proc_info.h" -#include "orte/mca/state/state.h" -#include "orte/mca/state/base/base.h" -#if !ORTE_DISABLE_FULL_SUPPORT -#include "orte/mca/iof/iof.h" -#include "orte/mca/iof/base/base.h" -#include "orte/mca/oob/oob.h" -#include "orte/mca/oob/base/base.h" -#include "orte/mca/odls/odls.h" -#include "orte/mca/odls/base/base.h" -#include "orte/mca/ras/ras.h" -#include "orte/mca/ras/base/ras_private.h" -#include "orte/mca/rmaps/rmaps.h" -#include "orte/mca/rmaps/base/base.h" -#include "orte/mca/rml/rml.h" -#include "orte/mca/rml/base/base.h" -#include "orte/mca/routed/routed.h" -#include "orte/mca/routed/base/base.h" -#include "orte/mca/plm/plm.h" -#include "orte/mca/plm/base/base.h" -#if OPAL_ENABLE_FT_CR == 1 -#include "orte/mca/snapc/snapc.h" -#include "orte/mca/snapc/base/base.h" -#endif -#include "orte/mca/sensor/sensor.h" -#include "orte/mca/sensor/base/base.h" -#include "orte/mca/filem/filem.h" -#include "orte/mca/filem/base/base.h" -#endif +#include "orte/runtime/orte_info_support.h" #include "orte/tools/orte-info/orte-info.h" /* * Public variables @@ -130,408 +72,44 @@ static bool opened_components = false; * out the environment of all OMPI_MCA_ variables to ensure * that the open algorithms don't try to only open one component. */ -void orte_info_open_components(void) +void orte_info_components_open(void) { - int i; - char *env, *str; - char *target, *save, *type; - char **env_save=NULL; - bool need_close_components = false; - orte_info_component_map_t *map; - if (opened_components) { return; } - + + opened_components = true; + /* init the map */ OBJ_CONSTRUCT(&component_map, opal_pointer_array_t); opal_pointer_array_init(&component_map, 256, INT_MAX, 128); - - /* Clear out the environment. Use strdup() to orphan the resulting - * strings because items are placed in the environment by reference, - * not by value. - */ - - for (i = 0; i < mca_types.size; ++i) { - if (NULL == (type = (char*)opal_pointer_array_get_item(&mca_types, i))) { - continue; - } - asprintf(&env, "OMPI_MCA_%s", type); - if (NULL != (save = getenv(env))) { - /* save this param so it can later be restored */ - asprintf(&str, "%s=%s", env, save); - opal_argv_append_nosize(&env_save, str); - free(str); - /* can't manipulate it directly, so make a copy first */ - asprintf(&target, "%s=", env); - putenv(target); - free(target); - } - } - - /* some components require the event library be active, so activate it */ - if (OPAL_SUCCESS != opal_event_base_open()) { - str = "opal_event_base_open"; - goto error; - } - - /* Open the DSS */ - - if (ORTE_SUCCESS != opal_dss_open()) { - str = "Unable to initialize the DSS"; - goto error; - } - - /* Open up the MCA */ - - if (OPAL_SUCCESS != mca_base_open()) { - str = "mca_base_open failed"; - goto error; - } - - /* Register the OPAL layer's MCA parameters */ - - if (OPAL_SUCCESS != opal_register_params()) { - str = "opal_register_params failed"; - goto error; - } - - /* Register the ORTE layer's MCA parameters */ - - if (ORTE_SUCCESS != orte_register_params()) { - str = "orte_register_params failed"; - goto error; - } - - /* Initialize the opal_output system */ - if (!opal_output_init()) { - str = "opal_output_init failed"; - goto error; - } - - /* Find / open all components */ - map = OBJ_NEW(orte_info_component_map_t); - map->type = strdup("base"); - opal_pointer_array_add(&component_map, map); - - /* set default error message from here forward */ - str = "A component framework failed to open properly."; - - /* OPAL frameworks */ - - if (OPAL_SUCCESS != opal_backtrace_base_open()) { - goto error; - } - map = OBJ_NEW(orte_info_component_map_t); - map->type = strdup("backtrace"); - map->components = &opal_backtrace_base_components_opened; - opal_pointer_array_add(&component_map, map); - - if (OPAL_SUCCESS != opal_memory_base_open()) { - goto error; - } - map = OBJ_NEW(orte_info_component_map_t); - map->type = strdup("memory"); - map->components = &opal_memory_base_components_opened; - opal_pointer_array_add(&component_map, map); - - /* the event framework is already open - just get its components */ - map = OBJ_NEW(orte_info_component_map_t); - map->type = strdup("event"); - map->components = &opal_event_components; - opal_pointer_array_add(&component_map, map); - - if (OPAL_SUCCESS != opal_memchecker_base_open()) { - goto error; - } - map = OBJ_NEW(orte_info_component_map_t); - map->type = strdup("memchecker"); - map->components = &opal_memchecker_base_components_opened; - opal_pointer_array_add(&component_map, map); - - if (OPAL_SUCCESS != opal_shmem_base_open()) { - goto error; - } - map = OBJ_NEW(orte_info_component_map_t); - map->type = strdup("shmem"); - map->components = &opal_shmem_base_components_opened; - opal_pointer_array_add(&component_map, map); - -#if OPAL_HAVE_HWLOC - if (OPAL_SUCCESS != opal_hwloc_base_open()) { - goto error; - } - map = OBJ_NEW(orte_info_component_map_t); - map->type = strdup("hwloc"); - map->components = &opal_hwloc_base_components; - opal_pointer_array_add(&component_map, map); -#endif - if (OPAL_SUCCESS != opal_timer_base_open()) { - goto error; - } - map = OBJ_NEW(orte_info_component_map_t); - map->type = strdup("timer"); - map->components = &opal_timer_base_components_opened; - opal_pointer_array_add(&component_map, map); - -#if OPAL_ENABLE_FT_CR == 1 - if (OPAL_SUCCESS != opal_crs_base_open()) { - goto error; - } - map = OBJ_NEW(orte_info_component_map_t); - map->type = strdup("crs"); - map->components = &opal_crs_base_components_available; - opal_pointer_array_add(&component_map, map); -#endif - - if (OPAL_SUCCESS != opal_if_base_open()) { - goto error; - } - map = OBJ_NEW(orte_info_component_map_t); - map->type = strdup("if"); - map->components = &opal_if_components; - opal_pointer_array_add(&component_map, map); - - - /* OPAL's installdirs base open has already been called as part of - * opal_init_util() back in main(). - */ - map = OBJ_NEW(orte_info_component_map_t); - map->type = strdup("installdirs"); - map->components = &opal_installdirs_components; - opal_pointer_array_add(&component_map, map); - - /* ORTE frameworks - * Set orte_process_info.proc_type to HNP to force all frameworks to - * open components - */ - orte_process_info.proc_type = ORTE_PROC_HNP; - - if (ORTE_SUCCESS != orte_state_base_open()) { - goto error; - } - map = OBJ_NEW(orte_info_component_map_t); - map->type = strdup("state"); - map->components = &orte_state_base_components_available; - opal_pointer_array_add(&component_map, map); - - if (ORTE_SUCCESS != orte_errmgr_base_open()) { - goto error; - } - map = OBJ_NEW(orte_info_component_map_t); - map->type = strdup("errmgr"); - map->components = &orte_errmgr_base_components_available; - opal_pointer_array_add(&component_map, map); - - if (ORTE_SUCCESS != orte_grpcomm_base_open()) { - goto error; - } - map = OBJ_NEW(orte_info_component_map_t); - map->type = strdup("grpcomm"); - map->components = &orte_grpcomm_base.components_available; - opal_pointer_array_add(&component_map, map); - - if (ORTE_SUCCESS != orte_db_base_open()) { - goto error; - } - map = OBJ_NEW(orte_info_component_map_t); - map->type = strdup("db"); - map->components = &orte_db_base.available_components; - opal_pointer_array_add(&component_map, map); - - if (ORTE_SUCCESS != orte_ess_base_open()) { - goto error; - } - map = OBJ_NEW(orte_info_component_map_t); - map->type = strdup("ess"); - map->components = &orte_ess_base_components_available; - opal_pointer_array_add(&component_map, map); - -#if !ORTE_DISABLE_FULL_SUPPORT - if (ORTE_SUCCESS != mca_oob_base_open()) { - goto error; - } - map = OBJ_NEW(orte_info_component_map_t); - map->type = strdup("oob"); - map->components = &mca_oob_base_components; - opal_pointer_array_add(&component_map, map); - - if (ORTE_SUCCESS != orte_odls_base_open()) { - goto error; - } - map = OBJ_NEW(orte_info_component_map_t); - map->type = strdup("odls"); - map->components = &orte_odls_base.available_components; - opal_pointer_array_add(&component_map, map); - - if (ORTE_SUCCESS != orte_iof_base_open()) { - goto error; - } - map = OBJ_NEW(orte_info_component_map_t); - map->type = strdup("iof"); - map->components = &orte_iof_base.iof_components_opened; - opal_pointer_array_add(&component_map, map); - - if (ORTE_SUCCESS != orte_ras_base_open()) { - goto error; - } - map = OBJ_NEW(orte_info_component_map_t); - map->type = strdup("ras"); - map->components = &orte_ras_base.ras_opened; - opal_pointer_array_add(&component_map, map); - - if (ORTE_SUCCESS != orte_rmaps_base_open()) { - goto error; - } - map = OBJ_NEW(orte_info_component_map_t); - map->type = strdup("rmaps"); - map->components = &orte_rmaps_base.available_components; - opal_pointer_array_add(&component_map, map); - - if (ORTE_SUCCESS != orte_rml_base_open()) { - goto error; - } - map = OBJ_NEW(orte_info_component_map_t); - map->type = strdup("rml"); - map->components = &orte_rml_base_components; - opal_pointer_array_add(&component_map, map); - - if (ORTE_SUCCESS != orte_routed_base_open()) { - goto error; - } - map = OBJ_NEW(orte_info_component_map_t); - map->type = strdup("routed"); - map->components = &orte_routed_base_components; - opal_pointer_array_add(&component_map, map); - - if (ORTE_SUCCESS != orte_plm_base_open()) { - goto error; - } - map = OBJ_NEW(orte_info_component_map_t); - map->type = strdup("plm"); - map->components = &orte_plm_base.available_components; - opal_pointer_array_add(&component_map, map); - -#if OPAL_ENABLE_FT_CR == 1 - if (ORTE_SUCCESS != orte_snapc_base_open()) { - goto error; - } - map = OBJ_NEW(orte_info_component_map_t); - map->type = strdup("snapc"); - map->components = &orte_snapc_base_components_available; - opal_pointer_array_add(&component_map, map); -#endif - - if (ORTE_SUCCESS != orte_sensor_base_open()) { - goto error; - } - map = OBJ_NEW(orte_info_component_map_t); - map->type = strdup("sensor"); - map->components = &mca_sensor_base_components_available; - opal_pointer_array_add(&component_map, map); - - if (ORTE_SUCCESS != orte_filem_base_open()) { - goto error; - } - map = OBJ_NEW(orte_info_component_map_t); - map->type = strdup("filem"); - map->components = &orte_filem_base_components_available; - opal_pointer_array_add(&component_map, map); -#endif - - /* flag that we need to close components */ - need_close_components = true; - - /* Restore the environment to what it was before we started so that - * if users setenv OMPI_MCA_ to some value, they'll - * see that value when it is shown via --param output. - */ - - if (NULL != env_save) { - for (i = 0; i < opal_argv_count(env_save); ++i) { - putenv(env_save[i]); - } - } - - /* All done */ - - opened_components = true; - return; - -error: - fprintf(stderr, "%s\n", str); - fprintf(stderr, "orte-info will likely not display all configuration information\n"); - if (need_close_components) { - opened_components = true; - orte_info_close_components(); - } + opal_info_register_components (&mca_types, &component_map); + orte_info_register_components (&mca_types, &component_map); } - -void orte_info_close_components() +/* + * Not to be confused with orte_info_close_components. + */ +void orte_info_components_close(void) { int i; orte_info_component_map_t *map; - - if (opened_components) { - - /* Note that the order of shutdown here doesn't matter because - * we aren't *using* any components -- none were selected, so - * there are no dependencies between the frameworks. We list - * them generally "in order", but it doesn't really matter. - - * We also explicitly ignore the return values from the - * close() functions -- what would we do if there was an - * error? - */ - - (void) orte_grpcomm_base_close(); - (void) orte_db_base_close(); - (void) orte_ess_base_close(); - (void) orte_show_help_finalize(); -#if !ORTE_DISABLE_FULL_SUPPORT -#if OPAL_ENABLE_FT_CR == 1 - (void) orte_snapc_base_close(); -#endif - (void) orte_filem_base_close(); - (void) orte_iof_base_close(); - (void) orte_plm_base_close(); - (void) orte_odls_base_close(); - (void) orte_rmaps_base_close(); - (void) orte_ras_base_close(); - (void) orte_rml_base_close(); - (void) orte_routed_base_close(); - (void) mca_oob_base_close(); -#endif - (void) orte_errmgr_base_close(); - (void) orte_state_base_close(); - (void) opal_backtrace_base_close(); - (void) opal_memory_base_close(); - (void) opal_memchecker_base_close(); - (void) opal_timer_base_close(); -#if OPAL_HAVE_HWLOC - (void) opal_hwloc_base_close(); -#endif -#if OPAL_ENABLE_FT_CR == 1 - (void) opal_crs_base_close(); -#endif - (void) opal_event_base_close(); - - /* Do not call OPAL's installdirs close; it will be handled in - * opal_finalize_util(). - */ - for (i=0; i < component_map.size; i++) { - if (NULL != (map = (orte_info_component_map_t*)opal_pointer_array_get_item(&component_map, i))) { - OBJ_RELEASE(map); - } - } - OBJ_DESTRUCT(&component_map); - - /* close the OPAL components */ - (void) opal_info_close_components(); + if (!opened_components) { + return; } + + orte_info_close_components (); + opal_info_close_components (); + + for (i=0; i < component_map.size; i++) { + if (NULL != (map = (orte_info_component_map_t*)opal_pointer_array_get_item(&component_map, i))) { + OBJ_RELEASE(map); + } + } + + OBJ_DESTRUCT(&component_map); opened_components = false; } diff --git a/orte/tools/orte-info/orte-info.c b/orte/tools/orte-info/orte-info.c index abe71d25dd..bbf56e7c87 100644 --- a/orte/tools/orte-info/orte-info.c +++ b/orte/tools/orte-info/orte-info.c @@ -47,6 +47,7 @@ #include "orte/constants.h" #include "orte/util/show_help.h" +#include "orte/runtime/orte_info_support.h" #include "orte/runtime/orte_locks.h" #include "orte/tools/orte-info/orte-info.h" @@ -283,7 +284,7 @@ int main(int argc, char *argv[]) orte_info_do_arch(); orte_info_do_hostname(); orte_info_do_config(false); - orte_info_open_components(); + orte_info_components_open(); for (i = 0; i < mca_types.size; ++i) { if (NULL == (str = (char*)opal_pointer_array_get_item(&mca_types, i))) { continue; @@ -301,7 +302,7 @@ int main(int argc, char *argv[]) if (NULL != global_env) { opal_argv_free(global_env); } - orte_info_close_components(); + orte_info_components_close (); OBJ_RELEASE(orte_info_cmd_line); OBJ_DESTRUCT(&mca_types); mca_base_close(); diff --git a/orte/tools/orte-info/orte-info.h b/orte/tools/orte-info/orte-info.h index fa64564e95..6172c5ad50 100644 --- a/orte/tools/orte-info/orte-info.h +++ b/orte/tools/orte-info/orte-info.h @@ -120,8 +120,8 @@ ORTE_DECLSPEC OBJ_CLASS_DECLARATION(orte_info_component_map_t); extern opal_pointer_array_t component_map; -void orte_info_open_components(void); -void orte_info_close_components(void); +void orte_info_components_open(void); +void orte_info_components_close(void); END_C_DECLS diff --git a/orte/tools/orte-info/param.c b/orte/tools/orte-info/param.c index 8c100f99d5..d66263fdb4 100644 --- a/orte/tools/orte-info/param.c +++ b/orte/tools/orte-info/param.c @@ -91,7 +91,7 @@ void orte_info_do_params(bool want_all_in, bool want_internal) bool want_all = false; opal_list_t *info; - orte_info_open_components(); + orte_info_components_open(); if (want_all_in) { want_all = true; @@ -565,7 +565,6 @@ void orte_info_do_config(bool want_all) if (want_all) { orte_info_out("Thread support", "option:threads", threads); - free(threads); orte_info_out("Build CFLAGS", "option:build:cflags", OMPI_BUILD_CFLAGS); orte_info_out("Build CXXFLAGS", "option:build:cxxflags", OMPI_BUILD_CXXFLAGS); @@ -581,6 +580,7 @@ void orte_info_do_config(bool want_all) orte_info_out("Wrapper extra LIBS", "option:wrapper:extra_libs", WRAPPER_EXTRA_LIBS); } + free(threads); orte_info_out("Internal debug support", "option:debug", debug); orte_info_out("Memory profiling support", "option:mem-profile", memprofile); diff --git a/orte/tools/orte-info/version.c b/orte/tools/orte-info/version.c index 5f987b8e29..8bb7db9543 100644 --- a/orte/tools/orte-info/version.c +++ b/orte/tools/orte-info/version.c @@ -80,7 +80,7 @@ void orte_info_do_version(bool want_all, opal_cmd_line_t *cmd_line) char *pos; int j; - orte_info_open_components(); + orte_info_components_open(); if (want_all) { orte_info_show_orte_version(orte_info_ver_full); @@ -129,18 +129,19 @@ void orte_info_do_version(bool want_all, opal_cmd_line_t *cmd_line) */ void orte_info_show_orte_version(const char *scope) { - char *tmp; + char *tmp, *tmp2; orte_info_out("Package", "package", OPAL_PACKAGE_STRING); asprintf(&tmp, "%s:version:full", orte_info_type_orte); orte_info_out("Open RTE", tmp, - make_version_str(scope, + tmp2 = make_version_str(scope, ORTE_MAJOR_VERSION, ORTE_MINOR_VERSION, ORTE_RELEASE_VERSION, ORTE_GREEK_VERSION, ORTE_WANT_REPO_REV, ORTE_REPO_REV)); free(tmp); + free(tmp2); asprintf(&tmp, "%s:version:repo", orte_info_type_orte); orte_info_out("Open RTE repo revision", tmp, ORTE_REPO_REV); free(tmp); @@ -150,12 +151,13 @@ void orte_info_show_orte_version(const char *scope) asprintf(&tmp, "%s:version:full", orte_info_type_opal); orte_info_out("OPAL", tmp, - make_version_str(scope, + tmp2 = make_version_str(scope, OPAL_MAJOR_VERSION, OPAL_MINOR_VERSION, OPAL_RELEASE_VERSION, OPAL_GREEK_VERSION, OPAL_WANT_REPO_REV, OPAL_REPO_REV)); free(tmp); + free(tmp2); asprintf(&tmp, "%s:version:repo", orte_info_type_opal); orte_info_out("OPAL repo revision", tmp, OPAL_REPO_REV); free(tmp); @@ -347,6 +349,10 @@ static void show_mca_version(const mca_base_component_t* component, } free(message); } + + free (mca_version); + free (api_version); + free (component_version); }