root/ompi/tools/ompi_info/ompi_info.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. main

   1 /*
   2  * Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana
   3  *                         University Research and Technology
   4  *                         Corporation.  All rights reserved.
   5  * Copyright (c) 2004-2016 The University of Tennessee and The University
   6  *                         of Tennessee Research Foundation.  All rights
   7  *                         reserved.
   8  * Copyright (c) 2004-2007 High Performance Computing Center Stuttgart,
   9  *                         University of Stuttgart.  All rights reserved.
  10  * Copyright (c) 2004-2005 The Regents of the University of California.
  11  *                         All rights reserved.
  12  * Copyright (c) 2007-2012 Cisco Systems, Inc.  All rights reserved.
  13  * Copyright (c) 2011-2012 University of Houston. All rights reserved.
  14  * Copyright (c) 2010-2013 Los Alamos National Security, LLC.
  15  *                         All rights reserved.
  16  * Copyright (c) 2014      Intel, Inc. All rights reserved.
  17  * $COPYRIGHT$
  18  *
  19  * Additional copyrights may follow
  20  *
  21  * $HEADER$
  22  */
  23 
  24 #include "ompi_config.h"
  25 
  26 #include <stdio.h>
  27 #include <string.h>
  28 #include <ctype.h>
  29 #ifdef HAVE_UNISTD_H
  30 #include <unistd.h>
  31 #endif
  32 #ifdef HAVE_NETDB_H
  33 #include <netdb.h>
  34 #endif
  35 #ifdef HAVE_SYS_PARAM_H
  36 #include <sys/param.h>
  37 #endif
  38 #include <errno.h>
  39 #include <signal.h>
  40 
  41 #include "opal/version.h"
  42 #include "opal/mca/installdirs/installdirs.h"
  43 #include "opal/class/opal_object.h"
  44 #include "opal/class/opal_pointer_array.h"
  45 #include "opal/runtime/opal.h"
  46 #if OPAL_ENABLE_FT_CR == 1
  47 #include "opal/runtime/opal_cr.h"
  48 #endif
  49 #include "opal/mca/base/base.h"
  50 #include "opal/runtime/opal_info_support.h"
  51 #include "opal/util/argv.h"
  52 #include "opal/util/show_help.h"
  53 
  54 #if OMPI_RTE_ORTE
  55 #include "orte/runtime/orte_info_support.h"
  56 #endif
  57 
  58 #include "ompi/communicator/communicator.h"
  59 #include "ompi/tools/ompi_info/ompi_info.h"
  60 #include "ompi/runtime/ompi_info_support.h"
  61 
  62 /*
  63  * Public variables
  64  */
  65 
  66 
  67 int main(int argc, char *argv[])
  68 {
  69     int ret = 0;
  70     bool acted = false;
  71     bool want_all = false;
  72     char **app_env = NULL, **global_env = NULL;
  73     int i;
  74     opal_cmd_line_t *ompi_info_cmd_line;
  75     opal_pointer_array_t mca_types;
  76     opal_pointer_array_t component_map;
  77     opal_info_component_map_t *map;
  78 
  79     /* protect against problems if someone passes us thru a pipe
  80      * and then abnormally terminates the pipe early */
  81     signal(SIGPIPE, SIG_IGN);
  82 
  83     /* Initialize the argv parsing handle */
  84     if (OPAL_SUCCESS != opal_init_util(&argc, &argv)) {
  85         opal_show_help("help-opal_info.txt", "lib-call-fail", true,
  86                        "opal_init_util", __FILE__, __LINE__, NULL);
  87         exit(ret);
  88     }
  89 
  90     ompi_info_cmd_line = OBJ_NEW(opal_cmd_line_t);
  91     if (NULL == ompi_info_cmd_line) {
  92         ret = errno;
  93         opal_show_help("help-opal_info.txt", "lib-call-fail", true,
  94                        "opal_cmd_line_create", __FILE__, __LINE__, NULL);
  95         exit(ret);
  96     }
  97 
  98     /* initialize the command line, parse it, and return the directives
  99      * telling us what the user wants output
 100      */
 101     if (OPAL_SUCCESS != (ret = opal_info_init(argc, argv, ompi_info_cmd_line))) {
 102         exit(ret);
 103     }
 104 
 105     if (opal_cmd_line_is_taken(ompi_info_cmd_line, "version")) {
 106         fprintf(stdout, "Open MPI v%s\n\n%s\n",
 107                 OPAL_VERSION, PACKAGE_BUGREPORT);
 108         exit(0);
 109     }
 110 
 111     /* setup the mca_types array */
 112     OBJ_CONSTRUCT(&mca_types, opal_pointer_array_t);
 113     opal_pointer_array_init(&mca_types, 128, INT_MAX, 64);
 114 
 115     /* add in the opal frameworks */
 116     opal_info_register_types(&mca_types);
 117 
 118 #if OMPI_RTE_ORTE
 119     /* add in the orte frameworks */
 120     orte_info_register_types(&mca_types);
 121 #endif
 122 
 123     ompi_info_register_types(&mca_types);
 124 
 125     /* init the component map */
 126     OBJ_CONSTRUCT(&component_map, opal_pointer_array_t);
 127     opal_pointer_array_init(&component_map, 64, INT_MAX, 32);
 128 
 129     /* Register OMPI's params */
 130     if (OMPI_SUCCESS != (ret = ompi_info_register_framework_params(&component_map))) {
 131         if (OMPI_ERR_BAD_PARAM == ret) {
 132             /* output what we got */
 133             opal_info_do_params(true, opal_cmd_line_is_taken(ompi_info_cmd_line, "internal"),
 134                                 &mca_types, &component_map, NULL);
 135         }
 136         exit(1);
 137     }
 138 
 139     /* Execute the desired action(s) */
 140     want_all = opal_cmd_line_is_taken(ompi_info_cmd_line, "all");
 141     if (want_all) {
 142         opal_info_out("Package", "package", OPAL_PACKAGE_STRING);
 143         ompi_info_show_ompi_version(opal_info_ver_full);
 144     }
 145     if (want_all || opal_cmd_line_is_taken(ompi_info_cmd_line, "path")) {
 146         opal_info_do_path(want_all, ompi_info_cmd_line);
 147         acted = true;
 148     }
 149     if (want_all || opal_cmd_line_is_taken(ompi_info_cmd_line, "arch")) {
 150         opal_info_do_arch();
 151         acted = true;
 152     }
 153     if (want_all || opal_cmd_line_is_taken(ompi_info_cmd_line, "hostname")) {
 154         opal_info_do_hostname();
 155         acted = true;
 156     }
 157     if (want_all || opal_cmd_line_is_taken(ompi_info_cmd_line, "config")) {
 158         ompi_info_do_config(true);
 159         acted = true;
 160     }
 161     if (want_all || opal_cmd_line_is_taken(ompi_info_cmd_line, "param") ||
 162         opal_cmd_line_is_taken(ompi_info_cmd_line, "params")) {
 163         opal_info_do_params(want_all, opal_cmd_line_is_taken(ompi_info_cmd_line, "internal"),
 164                             &mca_types, &component_map, ompi_info_cmd_line);
 165         acted = true;
 166     }
 167     if (opal_cmd_line_is_taken(ompi_info_cmd_line, "type")) {
 168         opal_info_do_type(ompi_info_cmd_line);
 169         acted = true;
 170     }
 171 
 172     /* If no command line args are specified, show default set */
 173 
 174     if (!acted) {
 175         opal_info_out("Package", "package", OPAL_PACKAGE_STRING);
 176         ompi_info_show_ompi_version(opal_info_ver_full);
 177         opal_info_show_path(opal_info_path_prefix, opal_install_dirs.prefix);
 178         opal_info_do_arch();
 179         opal_info_do_hostname();
 180         ompi_info_do_config(false);
 181         opal_info_show_component_version(&mca_types, &component_map, opal_info_type_all,
 182                                          opal_info_component_all, opal_info_ver_full,
 183                                          opal_info_ver_all);
 184     }
 185 
 186     /* All done */
 187 
 188     if (NULL != app_env) {
 189         opal_argv_free(app_env);
 190     }
 191     if (NULL != global_env) {
 192         opal_argv_free(global_env);
 193     }
 194     ompi_info_close_components();
 195     OBJ_RELEASE(ompi_info_cmd_line);
 196     OBJ_DESTRUCT(&mca_types);
 197     for (i=0; i < component_map.size; i++) {
 198         if (NULL != (map = (opal_info_component_map_t*)opal_pointer_array_get_item(&component_map, i))) {
 199             OBJ_RELEASE(map);
 200         }
 201     }
 202     OBJ_DESTRUCT(&component_map);
 203 
 204     opal_info_finalize();
 205 
 206     /* Put our own call to opal_finalize_util() here because we called
 207        it up above (and it refcounts) */
 208     opal_finalize_util();
 209 
 210     return 0;
 211 }

/* [<][>][^][v][top][bottom][index][help] */