2013-08-27 23:11:37 +04:00
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
2012-06-28 22:23:34 +04:00
/*
* Copyright ( c ) 2004 - 2010 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation . All rights reserved .
* Copyright ( c ) 2004 - 2011 The University of Tennessee and The University
* of Tennessee Research Foundation . All rights
* reserved .
2015-04-20 17:58:05 +03:00
* Copyright ( c ) 2004 - 2005 High Performance Computing Center Stuttgart ,
2012-06-28 22:23:34 +04:00
* University of Stuttgart . All rights reserved .
* Copyright ( c ) 2004 - 2005 The Regents of the University of California .
* All rights reserved .
2015-02-12 22:54:36 +03:00
* Copyright ( c ) 2006 - 2015 Cisco Systems , Inc . All rights reserved .
2015-04-07 23:42:35 +03:00
* Copyright ( c ) 2010 - 2015 Los Alamos National Security , LLC .
2012-06-28 22:23:34 +04:00
* All rights reserved .
* Copyright ( c ) 2011 - 2012 University of Houston . All rights reserved .
* $ COPYRIGHT $
2015-04-20 17:58:05 +03:00
*
2012-06-28 22:23:34 +04:00
* Additional copyrights may follow
2015-04-20 17:58:05 +03:00
*
2012-06-28 22:23:34 +04:00
* $ HEADER $
*/
# include "opal_config.h"
# include <string.h>
# include <ctype.h>
2013-03-28 01:10:32 +04:00
# ifdef HAVE_UNISTD_H
# include <unistd.h>
# endif
2013-09-06 23:03:19 +04:00
# include <errno.h>
2012-06-28 22:23:34 +04:00
# include "opal/class/opal_list.h"
# include "opal/class/opal_pointer_array.h"
# include "opal/util/output.h"
# include "opal/util/cmd_line.h"
# include "opal/util/error.h"
# include "opal/util/argv.h"
# include "opal/util/show_help.h"
# include "opal/runtime/opal.h"
# include "opal/dss/dss.h"
2013-07-16 20:02:13 +04:00
# include "opal/mca/base/mca_base_pvar.h"
2012-06-28 22:23:34 +04:00
2013-03-28 01:10:32 +04:00
# include "opal/include/opal/frameworks.h"
2012-06-28 22:23:34 +04:00
# include "opal/mca/installdirs/installdirs.h"
# include "opal/runtime/opal_info_support.h"
const char * opal_info_path_prefix = " prefix " ;
const char * opal_info_path_bindir = " bindir " ;
const char * opal_info_path_libdir = " libdir " ;
const char * opal_info_path_incdir = " incdir " ;
const char * opal_info_path_mandir = " mandir " ;
const char * opal_info_path_pkglibdir = " pkglibdir " ;
const char * opal_info_path_sysconfdir = " sysconfdir " ;
const char * opal_info_path_exec_prefix = " exec_prefix " ;
const char * opal_info_path_sbindir = " sbindir " ;
const char * opal_info_path_libexecdir = " libexecdir " ;
const char * opal_info_path_datarootdir = " datarootdir " ;
const char * opal_info_path_datadir = " datadir " ;
const char * opal_info_path_sharedstatedir = " sharedstatedir " ;
const char * opal_info_path_localstatedir = " localstatedir " ;
const char * opal_info_path_infodir = " infodir " ;
const char * opal_info_path_pkgdatadir = " pkgdatadir " ;
const char * opal_info_path_pkgincludedir = " pkgincludedir " ;
bool opal_info_pretty = true ;
2013-08-27 23:11:37 +04:00
mca_base_register_flag_t opal_info_register_flags = MCA_BASE_REGISTER_ALL ;
2012-06-28 22:23:34 +04:00
const char * opal_info_type_all = " all " ;
const char * opal_info_type_opal = " opal " ;
const char * opal_info_component_all = " all " ;
const char * opal_info_param_all = " all " ;
const char * opal_info_ver_full = " full " ;
const char * opal_info_ver_major = " major " ;
const char * opal_info_ver_minor = " minor " ;
const char * opal_info_ver_release = " release " ;
const char * opal_info_ver_greek = " greek " ;
const char * opal_info_ver_repo = " repo " ;
const char * opal_info_ver_all = " all " ;
const char * opal_info_ver_mca = " mca " ;
const char * opal_info_ver_type = " type " ;
const char * opal_info_ver_component = " component " ;
2015-04-07 23:42:35 +03:00
static int opal_info_registered = 0 ;
2012-06-28 22:23:34 +04:00
static void component_map_construct ( opal_info_component_map_t * map )
{
map - > type = NULL ;
}
static void component_map_destruct ( opal_info_component_map_t * map )
{
if ( NULL ! = map - > type ) {
free ( map - > type ) ;
}
/* the type close functions will release the
* list of components
*/
}
OBJ_CLASS_INSTANCE ( opal_info_component_map_t ,
opal_list_item_t ,
component_map_construct ,
component_map_destruct ) ;
int opal_info_init ( int argc , char * * argv ,
opal_cmd_line_t * opal_info_cmd_line )
{
int ret ;
bool want_help = false ;
bool cmd_error = false ;
char * * app_env = NULL , * * global_env = NULL ;
/* Initialize the argv parsing handle */
2012-07-11 16:09:00 +04:00
if ( OPAL_SUCCESS ! = ( ret = opal_init_util ( & argc , & argv ) ) ) {
2015-04-20 17:58:05 +03:00
opal_show_help ( " help-opal_info.txt " , " lib-call-fail " , true ,
2012-06-28 22:23:34 +04:00
" opal_init_util " , __FILE__ , __LINE__ , NULL ) ;
exit ( ret ) ;
}
2015-04-20 17:58:05 +03:00
2012-06-28 22:23:34 +04:00
/* add the cmd line options */
2015-04-20 17:58:05 +03:00
opal_cmd_line_make_opt3 ( opal_info_cmd_line , ' V ' , NULL , " version " , 0 ,
2013-04-24 21:47:18 +04:00
" Show version of Open MPI " ) ;
2015-04-20 17:58:05 +03:00
opal_cmd_line_make_opt3 ( opal_info_cmd_line , ' \0 ' , NULL , " param " , 2 ,
2012-06-28 22:23:34 +04:00
" Show MCA parameters. The first parameter is the framework (or the keyword \" all \" ); the second parameter is the specific component name (or the keyword \" all \" ). " ) ;
2015-04-20 17:58:05 +03:00
opal_cmd_line_make_opt3 ( opal_info_cmd_line , ' \0 ' , NULL , " params " , 2 ,
2012-06-28 22:23:34 +04:00
" Synonym for --param " ) ;
2015-04-20 17:58:05 +03:00
opal_cmd_line_make_opt3 ( opal_info_cmd_line , ' \0 ' , NULL , " internal " , 0 ,
2012-06-28 22:23:34 +04:00
" Show internal MCA parameters (not meant to be modified by users) " ) ;
2015-04-20 17:58:05 +03:00
opal_cmd_line_make_opt3 ( opal_info_cmd_line , ' \0 ' , NULL , " path " , 1 ,
2012-06-28 22:23:34 +04:00
" Show paths that Open MPI was configured with. Accepts the following parameters: prefix, bindir, libdir, incdir, mandir, pkglibdir, sysconfdir, all " ) ;
2015-04-20 17:58:05 +03:00
opal_cmd_line_make_opt3 ( opal_info_cmd_line , ' \0 ' , NULL , " arch " , 0 ,
2012-06-28 22:23:34 +04:00
" Show architecture Open MPI was compiled on " ) ;
2015-04-20 17:58:05 +03:00
opal_cmd_line_make_opt3 ( opal_info_cmd_line , ' c ' , NULL , " config " , 0 ,
2012-06-28 22:23:34 +04:00
" Show configuration options " ) ;
2014-07-09 05:37:23 +04:00
opal_cmd_line_make_opt3 ( opal_info_cmd_line , ' t ' , NULL , " type " , 1 ,
" Show internal MCA parameters with the type specified in parameter. " ) ;
2015-04-20 17:58:05 +03:00
opal_cmd_line_make_opt3 ( opal_info_cmd_line , ' h ' , NULL , " help " , 0 ,
2012-06-28 22:23:34 +04:00
" Show this help message " ) ;
2015-04-20 17:58:05 +03:00
opal_cmd_line_make_opt3 ( opal_info_cmd_line , ' \0 ' , NULL , " pretty-print " , 0 ,
2012-06-28 22:23:34 +04:00
" When used in conjunction with other parameters, the output is displayed in 'pretty-print' format (default) " ) ;
2015-04-20 17:58:05 +03:00
opal_cmd_line_make_opt3 ( opal_info_cmd_line , ' \0 ' , NULL , " parsable " , 0 ,
2012-06-28 22:23:34 +04:00
" When used in conjunction with other parameters, the output is displayed in a machine-parsable format " ) ;
2015-04-20 17:58:05 +03:00
opal_cmd_line_make_opt3 ( opal_info_cmd_line , ' \0 ' , NULL , " parseable " , 0 ,
2012-06-28 22:23:34 +04:00
" Synonym for --parsable " ) ;
2015-04-20 17:58:05 +03:00
opal_cmd_line_make_opt3 ( opal_info_cmd_line , ' \0 ' , NULL , " hostname " , 0 ,
2012-06-28 22:23:34 +04:00
" Show the hostname that Open MPI was configured and built on " ) ;
2015-04-20 17:58:05 +03:00
opal_cmd_line_make_opt3 ( opal_info_cmd_line , ' a ' , NULL , " all " , 0 ,
2012-06-28 22:23:34 +04:00
" Show all configuration options and MCA parameters " ) ;
2013-07-10 22:52:36 +04:00
opal_cmd_line_make_opt3 ( opal_info_cmd_line , ' l ' , NULL , " level " , 1 ,
" Show only variables with at most this level (1-9) " ) ;
2013-08-27 23:11:37 +04:00
opal_cmd_line_make_opt3 ( opal_info_cmd_line , ' s ' , NULL , " selected-only " , 0 ,
" Show only variables from selected components " ) ;
2013-07-10 22:52:36 +04:00
2012-06-28 22:23:34 +04:00
/* set our threading level */
opal_set_using_threads ( false ) ;
2015-04-20 17:58:05 +03:00
2012-06-28 22:23:34 +04:00
/* Get MCA parameters, if any */
if ( OPAL_SUCCESS ! = mca_base_open ( ) ) {
opal_show_help ( " help-opal_info.txt " , " lib-call-fail " , true , " mca_base_open " , __FILE__ , __LINE__ ) ;
opal_finalize_util ( ) ;
return OPAL_ERROR ;
}
mca_base_cmd_line_setup ( opal_info_cmd_line ) ;
2015-04-20 17:58:05 +03:00
2012-06-28 22:23:34 +04:00
/* Initialize the opal_output system */
if ( ! opal_output_init ( ) ) {
return OPAL_ERROR ;
}
2015-04-20 17:58:05 +03:00
2012-06-28 22:23:34 +04:00
/* Do the parsing */
ret = opal_cmd_line_parse ( opal_info_cmd_line , false , argc , argv ) ;
if ( OPAL_SUCCESS ! = ret ) {
cmd_error = true ;
if ( OPAL_ERR_SILENT ! = ret ) {
fprintf ( stderr , " %s: command line error (%s) \n " , argv [ 0 ] ,
opal_strerror ( ret ) ) ;
}
}
2015-04-20 17:58:05 +03:00
if ( ! cmd_error & &
( opal_cmd_line_is_taken ( opal_info_cmd_line , " help " ) | |
2012-06-28 22:23:34 +04:00
opal_cmd_line_is_taken ( opal_info_cmd_line , " h " ) ) ) {
char * str , * usage ;
want_help = true ;
usage = opal_cmd_line_get_usage_msg ( opal_info_cmd_line ) ;
2015-04-20 17:58:05 +03:00
str = opal_show_help_string ( " help-opal_info.txt " , " usage " ,
2012-06-28 22:23:34 +04:00
true , usage ) ;
if ( NULL ! = str ) {
printf ( " %s " , str ) ;
free ( str ) ;
}
free ( usage ) ;
}
/* If we had a cmd line parse error, or we showed the help
message , it ' s time to exit . */
if ( cmd_error | | want_help ) {
mca_base_close ( ) ;
OBJ_RELEASE ( opal_info_cmd_line ) ;
opal_finalize_util ( ) ;
exit ( cmd_error ? 1 : 0 ) ;
}
2015-04-20 17:58:05 +03:00
2012-06-28 22:23:34 +04:00
mca_base_cmd_line_process_args ( opal_info_cmd_line , & app_env , & global_env ) ;
2015-04-20 17:58:05 +03:00
2012-06-28 22:23:34 +04:00
/* set the flags */
if ( opal_cmd_line_is_taken ( opal_info_cmd_line , " pretty-print " ) ) {
opal_info_pretty = true ;
} else if ( opal_cmd_line_is_taken ( opal_info_cmd_line , " parsable " ) | | opal_cmd_line_is_taken ( opal_info_cmd_line , " parseable " ) ) {
opal_info_pretty = false ;
}
2013-08-27 23:11:37 +04:00
if ( opal_cmd_line_is_taken ( opal_info_cmd_line , " selected-only " ) ) {
/* register only selected components */
opal_info_register_flags = MCA_BASE_REGISTER_DEFAULT ;
}
2015-04-20 17:58:05 +03:00
2012-06-28 22:23:34 +04:00
return OPAL_SUCCESS ;
}
void opal_info_finalize ( void )
{
opal_finalize_util ( ) ;
}
2013-04-24 19:59:23 +04:00
static int info_register_framework ( mca_base_framework_t * framework , opal_pointer_array_t * component_map )
{
2013-03-28 01:11:47 +04:00
opal_info_component_map_t * map ;
int rc ;
2013-08-27 23:11:37 +04:00
rc = mca_base_framework_register ( framework , opal_info_register_flags ) ;
2013-03-28 01:17:31 +04:00
if ( OPAL_SUCCESS ! = rc & & OPAL_ERR_BAD_PARAM ! = rc ) {
2013-03-28 01:11:47 +04:00
return rc ;
}
2013-04-24 19:59:23 +04:00
if ( NULL ! = component_map ) {
map = OBJ_NEW ( opal_info_component_map_t ) ;
map - > type = strdup ( framework - > framework_name ) ;
map - > components = & framework - > framework_components ;
opal_pointer_array_add ( component_map , map ) ;
}
return rc ;
}
int opal_info_register_project_frameworks ( const char * project_name , mca_base_framework_t * * frameworks ,
opal_pointer_array_t * component_map )
{
2013-08-17 01:13:40 +04:00
int i , rc = OPAL_SUCCESS ;
2013-04-24 19:59:23 +04:00
for ( i = 0 ; NULL ! = frameworks [ i ] ; i + + ) {
if ( OPAL_SUCCESS ! = ( rc = info_register_framework ( frameworks [ i ] , component_map ) ) ) {
if ( OPAL_ERR_BAD_PARAM = = rc ) {
fprintf ( stderr , " \n A \" bad parameter \" error was encountered when opening the %s %s framework \n " ,
project_name , frameworks [ i ] - > framework_name ) ;
fprintf ( stderr , " The output received from that framework includes the following parameters: \n \n " ) ;
2013-07-16 20:02:33 +04:00
} else if ( OPAL_ERR_NOT_AVAILABLE ! = rc ) {
2013-04-24 19:59:23 +04:00
fprintf ( stderr , " %s_info_register: %s failed \n " , project_name , frameworks [ i ] - > framework_name ) ;
rc = OPAL_ERROR ;
2013-07-16 20:02:33 +04:00
} else {
continue ;
2013-04-24 19:59:23 +04:00
}
break ;
}
}
2013-03-28 01:11:47 +04:00
return rc ;
}
2012-06-28 22:23:34 +04:00
void opal_info_register_types ( opal_pointer_array_t * mca_types )
{
2013-03-28 01:17:31 +04:00
int i ;
/* add the top-level types */
2012-06-28 22:23:34 +04:00
opal_pointer_array_add ( mca_types , " mca " ) ;
opal_pointer_array_add ( mca_types , " opal " ) ;
2013-03-28 01:17:31 +04:00
/* push all the types found by autogen */
for ( i = 0 ; NULL ! = opal_frameworks [ i ] ; i + + ) {
opal_pointer_array_add ( mca_types , opal_frameworks [ i ] - > framework_name ) ;
}
2012-06-28 22:23:34 +04:00
}
2013-03-28 01:17:31 +04:00
int opal_info_register_framework_params ( opal_pointer_array_t * component_map )
2012-06-28 22:23:34 +04:00
{
2013-04-24 19:59:23 +04:00
int rc ;
2013-03-28 01:11:47 +04:00
2015-04-07 23:42:35 +03:00
if ( opal_info_registered + + ) {
2013-04-24 19:59:23 +04:00
return OPAL_SUCCESS ;
2012-06-28 22:23:34 +04:00
}
2013-04-24 19:59:23 +04:00
/* Register mca/base parameters */
if ( OPAL_SUCCESS ! = mca_base_open ( ) ) {
opal_show_help ( " help-opal_info.txt " , " lib-call-fail " , true , " mca_base_open " , __FILE__ , __LINE__ ) ;
return OPAL_ERROR ;
2013-03-28 01:11:47 +04:00
}
2012-06-28 22:23:34 +04:00
2013-04-24 19:59:23 +04:00
/* Register the OPAL layer's MCA parameters */
if ( OPAL_SUCCESS ! = ( rc = opal_register_params ( ) ) ) {
fprintf ( stderr , " opal_info_register: opal_register_params failed \n " ) ;
return rc ;
}
2013-03-28 01:17:31 +04:00
2013-04-24 19:59:23 +04:00
return opal_info_register_project_frameworks ( " opal " , opal_frameworks , component_map ) ;
2012-06-28 22:23:34 +04:00
}
Refs trac:3275.
We ran into a case where the OMPI SVN trunk grew a new acceptable MCA
parameter value, but this new value was not accepted on the v1.6
branch (hwloc_base_mem_bind_failure_action -- on the trunk it accepts
the value "silent", but on the older v1.6 branch, it doesn't). If you
set "hwloc_base_mem_bind_failure_action=silent" in the default MCA
params file and then accidentally ran with the v1.6 branch, every OMPI
executable (including ompi_info) just failed because hwloc_base_open()
would say "hey, 'silent' is not a valid value for
hwloc_base_mem_bind_failure_action!". Kaboom.
The only problem is that it didn't give you any indication of where
this value was being set. Quite maddening, from a user perspective.
So we changed the ompi_info handles this case. If any framework open
function return OMPI_ERR_BAD_PARAM (either because its base MCA params
got a bad value or because one of its component register/open
functions return OMPI_ERR_BAD_PARAM), ompi_info will stop, print out
a warning that it received and error, and then dump out the parameters
that it has received so far in the framework that had a problem.
At a minimum, this will show the user the MCA param that had an error
(it's usually the last one), and ''where it was set from'' (so that
they can go fix it).
We updated ompi_info to check for O???_ERR_BAD_PARAM from each from
the framework opens. Also updated the doxygen docs in mca.h for this
O???_BAD_PARAM behavior. And we noticed that mca.h had MCA_SUCCESS
and MCA_ERR_??? codes. Why? I think we used them in exactly one
place in the code base (mca_base_components_open.c). So we deleted
those and just used the normal OPAL_* codes instead.
While we were doing this, we also cleaned up a little memory
management during ompi_info/orte-info/opal-info finalization.
Valgrind still reports a truckload of memory still in use at ompi_info
termination, but they mostly look to be components not freeing
memory/resources properly (and outside the scope of this fix).
This commit was SVN r27306.
The following Trac tickets were found above:
Ticket 3275 --> https://svn.open-mpi.org/trac/ompi/ticket/3275
2012-09-12 00:47:24 +04:00
2012-06-28 22:23:34 +04:00
void opal_info_close_components ( void )
{
2013-03-28 01:17:31 +04:00
int i ;
2015-04-07 23:42:35 +03:00
assert ( opal_info_registered ) ;
if ( - - opal_info_registered ) {
return ;
}
2013-03-28 01:17:31 +04:00
for ( i = 0 ; NULL ! = opal_frameworks [ i ] ; i + + ) {
( void ) mca_base_framework_close ( opal_frameworks [ i ] ) ;
}
2015-04-07 23:42:35 +03:00
/* release our reference to MCA */
mca_base_close ( ) ;
2012-06-28 22:23:34 +04:00
}
Refs trac:3275.
We ran into a case where the OMPI SVN trunk grew a new acceptable MCA
parameter value, but this new value was not accepted on the v1.6
branch (hwloc_base_mem_bind_failure_action -- on the trunk it accepts
the value "silent", but on the older v1.6 branch, it doesn't). If you
set "hwloc_base_mem_bind_failure_action=silent" in the default MCA
params file and then accidentally ran with the v1.6 branch, every OMPI
executable (including ompi_info) just failed because hwloc_base_open()
would say "hey, 'silent' is not a valid value for
hwloc_base_mem_bind_failure_action!". Kaboom.
The only problem is that it didn't give you any indication of where
this value was being set. Quite maddening, from a user perspective.
So we changed the ompi_info handles this case. If any framework open
function return OMPI_ERR_BAD_PARAM (either because its base MCA params
got a bad value or because one of its component register/open
functions return OMPI_ERR_BAD_PARAM), ompi_info will stop, print out
a warning that it received and error, and then dump out the parameters
that it has received so far in the framework that had a problem.
At a minimum, this will show the user the MCA param that had an error
(it's usually the last one), and ''where it was set from'' (so that
they can go fix it).
We updated ompi_info to check for O???_ERR_BAD_PARAM from each from
the framework opens. Also updated the doxygen docs in mca.h for this
O???_BAD_PARAM behavior. And we noticed that mca.h had MCA_SUCCESS
and MCA_ERR_??? codes. Why? I think we used them in exactly one
place in the code base (mca_base_components_open.c). So we deleted
those and just used the normal OPAL_* codes instead.
While we were doing this, we also cleaned up a little memory
management during ompi_info/orte-info/opal-info finalization.
Valgrind still reports a truckload of memory still in use at ompi_info
termination, but they mostly look to be components not freeing
memory/resources properly (and outside the scope of this fix).
This commit was SVN r27306.
The following Trac tickets were found above:
Ticket 3275 --> https://svn.open-mpi.org/trac/ompi/ticket/3275
2012-09-12 00:47:24 +04:00
2012-06-28 22:23:34 +04:00
void opal_info_show_path ( const char * type , const char * value )
{
char * pretty , * path ;
2015-04-20 17:58:05 +03:00
2012-06-28 22:23:34 +04:00
pretty = strdup ( type ) ;
pretty [ 0 ] = toupper ( pretty [ 0 ] ) ;
2015-04-20 17:58:05 +03:00
2012-06-28 22:23:34 +04:00
asprintf ( & path , " path:%s " , type ) ;
opal_info_out ( pretty , path , value ) ;
free ( pretty ) ;
free ( path ) ;
}
void opal_info_do_path ( bool want_all , opal_cmd_line_t * cmd_line )
{
int i , count ;
char * scope ;
2015-04-20 17:58:05 +03:00
2012-06-28 22:23:34 +04:00
/* Check bozo case */
count = opal_cmd_line_get_ninsts ( cmd_line , " path " ) ;
for ( i = 0 ; i < count ; + + i ) {
scope = opal_cmd_line_get_param ( cmd_line , " path " , i , 0 ) ;
if ( 0 = = strcmp ( " all " , scope ) ) {
want_all = true ;
break ;
}
}
2015-04-20 17:58:05 +03:00
2012-06-28 22:23:34 +04:00
if ( want_all ) {
opal_info_show_path ( opal_info_path_prefix , opal_install_dirs . prefix ) ;
opal_info_show_path ( opal_info_path_exec_prefix , opal_install_dirs . exec_prefix ) ;
opal_info_show_path ( opal_info_path_bindir , opal_install_dirs . bindir ) ;
opal_info_show_path ( opal_info_path_sbindir , opal_install_dirs . sbindir ) ;
opal_info_show_path ( opal_info_path_libdir , opal_install_dirs . libdir ) ;
opal_info_show_path ( opal_info_path_incdir , opal_install_dirs . includedir ) ;
opal_info_show_path ( opal_info_path_mandir , opal_install_dirs . mandir ) ;
2014-05-08 06:01:35 +04:00
opal_info_show_path ( opal_info_path_pkglibdir , opal_install_dirs . opallibdir ) ;
2012-06-28 22:23:34 +04:00
opal_info_show_path ( opal_info_path_libexecdir , opal_install_dirs . libexecdir ) ;
opal_info_show_path ( opal_info_path_datarootdir , opal_install_dirs . datarootdir ) ;
opal_info_show_path ( opal_info_path_datadir , opal_install_dirs . datadir ) ;
opal_info_show_path ( opal_info_path_sysconfdir , opal_install_dirs . sysconfdir ) ;
opal_info_show_path ( opal_info_path_sharedstatedir , opal_install_dirs . sharedstatedir ) ;
opal_info_show_path ( opal_info_path_localstatedir , opal_install_dirs . localstatedir ) ;
opal_info_show_path ( opal_info_path_infodir , opal_install_dirs . infodir ) ;
2014-05-08 06:01:35 +04:00
opal_info_show_path ( opal_info_path_pkgdatadir , opal_install_dirs . opaldatadir ) ;
opal_info_show_path ( opal_info_path_pkglibdir , opal_install_dirs . opallibdir ) ;
opal_info_show_path ( opal_info_path_pkgincludedir , opal_install_dirs . opalincludedir ) ;
2012-06-28 22:23:34 +04:00
} else {
count = opal_cmd_line_get_ninsts ( cmd_line , " path " ) ;
for ( i = 0 ; i < count ; + + i ) {
scope = opal_cmd_line_get_param ( cmd_line , " path " , i , 0 ) ;
2015-04-20 17:58:05 +03:00
2012-06-28 22:23:34 +04:00
if ( 0 = = strcmp ( opal_info_path_prefix , scope ) ) {
opal_info_show_path ( opal_info_path_prefix , opal_install_dirs . prefix ) ;
} else if ( 0 = = strcmp ( opal_info_path_bindir , scope ) ) {
opal_info_show_path ( opal_info_path_bindir , opal_install_dirs . bindir ) ;
} else if ( 0 = = strcmp ( opal_info_path_libdir , scope ) ) {
opal_info_show_path ( opal_info_path_libdir , opal_install_dirs . libdir ) ;
} else if ( 0 = = strcmp ( opal_info_path_incdir , scope ) ) {
opal_info_show_path ( opal_info_path_incdir , opal_install_dirs . includedir ) ;
} else if ( 0 = = strcmp ( opal_info_path_mandir , scope ) ) {
opal_info_show_path ( opal_info_path_mandir , opal_install_dirs . mandir ) ;
} else if ( 0 = = strcmp ( opal_info_path_pkglibdir , scope ) ) {
2014-05-08 06:01:35 +04:00
opal_info_show_path ( opal_info_path_pkglibdir , opal_install_dirs . opallibdir ) ;
2012-06-28 22:23:34 +04:00
} else if ( 0 = = strcmp ( opal_info_path_sysconfdir , scope ) ) {
opal_info_show_path ( opal_info_path_sysconfdir , opal_install_dirs . sysconfdir ) ;
} else if ( 0 = = strcmp ( opal_info_path_exec_prefix , scope ) ) {
opal_info_show_path ( opal_info_path_exec_prefix , opal_install_dirs . exec_prefix ) ;
} else if ( 0 = = strcmp ( opal_info_path_sbindir , scope ) ) {
opal_info_show_path ( opal_info_path_sbindir , opal_install_dirs . sbindir ) ;
} else if ( 0 = = strcmp ( opal_info_path_libexecdir , scope ) ) {
opal_info_show_path ( opal_info_path_libexecdir , opal_install_dirs . libexecdir ) ;
} else if ( 0 = = strcmp ( opal_info_path_datarootdir , scope ) ) {
opal_info_show_path ( opal_info_path_datarootdir , opal_install_dirs . datarootdir ) ;
} else if ( 0 = = strcmp ( opal_info_path_datadir , scope ) ) {
opal_info_show_path ( opal_info_path_datadir , opal_install_dirs . datadir ) ;
} else if ( 0 = = strcmp ( opal_info_path_sharedstatedir , scope ) ) {
opal_info_show_path ( opal_info_path_sharedstatedir , opal_install_dirs . sharedstatedir ) ;
} else if ( 0 = = strcmp ( opal_info_path_localstatedir , scope ) ) {
opal_info_show_path ( opal_info_path_localstatedir , opal_install_dirs . localstatedir ) ;
} else if ( 0 = = strcmp ( opal_info_path_infodir , scope ) ) {
opal_info_show_path ( opal_info_path_infodir , opal_install_dirs . infodir ) ;
} else if ( 0 = = strcmp ( opal_info_path_pkgdatadir , scope ) ) {
2014-05-08 06:01:35 +04:00
opal_info_show_path ( opal_info_path_pkgdatadir , opal_install_dirs . opaldatadir ) ;
2012-06-28 22:23:34 +04:00
} else if ( 0 = = strcmp ( opal_info_path_pkgincludedir , scope ) ) {
2014-05-08 06:01:35 +04:00
opal_info_show_path ( opal_info_path_pkgincludedir , opal_install_dirs . opalincludedir ) ;
2012-06-28 22:23:34 +04:00
} else {
char * usage = opal_cmd_line_get_usage_msg ( cmd_line ) ;
opal_show_help ( " help-opal_info.txt " , " usage " , true , usage ) ;
free ( usage ) ;
exit ( 1 ) ;
}
}
}
}
void opal_info_do_params ( bool want_all_in , bool want_internal ,
opal_pointer_array_t * mca_types ,
opal_cmd_line_t * opal_info_cmd_line )
{
2013-07-10 22:52:36 +04:00
mca_base_var_info_lvl_t max_level = OPAL_INFO_LVL_1 ;
2012-06-28 22:23:34 +04:00
int count ;
char * type , * component , * str ;
bool found ;
int i ;
bool want_all = false ;
char * p ;
if ( opal_cmd_line_is_taken ( opal_info_cmd_line , " param " ) ) {
p = " param " ;
} else if ( opal_cmd_line_is_taken ( opal_info_cmd_line , " params " ) ) {
p = " params " ;
} else {
p = " foo " ; /* should never happen, but protect against segfault */
}
2013-07-10 22:52:36 +04:00
if ( NULL ! = ( str = opal_cmd_line_get_param ( opal_info_cmd_line , " level " , 0 , 0 ) ) ) {
char * tmp ;
errno = 0 ;
max_level = strtol ( str , & tmp , 10 ) + OPAL_INFO_LVL_1 - 1 ;
if ( 0 ! = errno | | ' \0 ' ! = tmp [ 0 ] | | max_level < OPAL_INFO_LVL_1 | | max_level > OPAL_INFO_LVL_9 ) {
char * usage = opal_cmd_line_get_usage_msg ( opal_info_cmd_line ) ;
opal_show_help ( " help-opal_info.txt " , " invalid-level " , true , str ) ;
free ( usage ) ;
exit ( 1 ) ;
}
2013-08-27 23:11:37 +04:00
} else if ( want_all_in ) {
/* if not specified default to level 9 if all components are requested */
max_level = OPAL_INFO_LVL_9 ;
2013-07-10 22:52:36 +04:00
}
2012-06-28 22:23:34 +04:00
if ( want_all_in ) {
want_all = true ;
} else {
Refs trac:3275.
We ran into a case where the OMPI SVN trunk grew a new acceptable MCA
parameter value, but this new value was not accepted on the v1.6
branch (hwloc_base_mem_bind_failure_action -- on the trunk it accepts
the value "silent", but on the older v1.6 branch, it doesn't). If you
set "hwloc_base_mem_bind_failure_action=silent" in the default MCA
params file and then accidentally ran with the v1.6 branch, every OMPI
executable (including ompi_info) just failed because hwloc_base_open()
would say "hey, 'silent' is not a valid value for
hwloc_base_mem_bind_failure_action!". Kaboom.
The only problem is that it didn't give you any indication of where
this value was being set. Quite maddening, from a user perspective.
So we changed the ompi_info handles this case. If any framework open
function return OMPI_ERR_BAD_PARAM (either because its base MCA params
got a bad value or because one of its component register/open
functions return OMPI_ERR_BAD_PARAM), ompi_info will stop, print out
a warning that it received and error, and then dump out the parameters
that it has received so far in the framework that had a problem.
At a minimum, this will show the user the MCA param that had an error
(it's usually the last one), and ''where it was set from'' (so that
they can go fix it).
We updated ompi_info to check for O???_ERR_BAD_PARAM from each from
the framework opens. Also updated the doxygen docs in mca.h for this
O???_BAD_PARAM behavior. And we noticed that mca.h had MCA_SUCCESS
and MCA_ERR_??? codes. Why? I think we used them in exactly one
place in the code base (mca_base_components_open.c). So we deleted
those and just used the normal OPAL_* codes instead.
While we were doing this, we also cleaned up a little memory
management during ompi_info/orte-info/opal-info finalization.
Valgrind still reports a truckload of memory still in use at ompi_info
termination, but they mostly look to be components not freeing
memory/resources properly (and outside the scope of this fix).
This commit was SVN r27306.
The following Trac tickets were found above:
Ticket 3275 --> https://svn.open-mpi.org/trac/ompi/ticket/3275
2012-09-12 00:47:24 +04:00
/* See if the special param "all" was given to --param; that
* supercedes any individual type
2012-06-28 22:23:34 +04:00
*/
count = opal_cmd_line_get_ninsts ( opal_info_cmd_line , p ) ;
for ( i = 0 ; i < count ; + + i ) {
type = opal_cmd_line_get_param ( opal_info_cmd_line , p , ( int ) i , 0 ) ;
if ( 0 = = strcmp ( opal_info_type_all , type ) ) {
want_all = true ;
break ;
}
}
}
2015-04-20 17:58:05 +03:00
2012-06-28 22:23:34 +04:00
/* Show the params */
2015-04-20 17:58:05 +03:00
2012-06-28 22:23:34 +04:00
if ( want_all ) {
for ( i = 0 ; i < mca_types - > size ; + + i ) {
if ( NULL = = ( type = ( char * ) opal_pointer_array_get_item ( mca_types , i ) ) ) {
continue ;
}
2013-07-10 22:52:36 +04:00
opal_info_show_mca_params ( type , opal_info_component_all , max_level , want_internal ) ;
2012-06-28 22:23:34 +04:00
}
} else {
for ( i = 0 ; i < count ; + + i ) {
type = opal_cmd_line_get_param ( opal_info_cmd_line , p , ( int ) i , 0 ) ;
component = opal_cmd_line_get_param ( opal_info_cmd_line , p , ( int ) i , 1 ) ;
2015-04-20 17:58:05 +03:00
2012-06-28 22:23:34 +04:00
for ( found = false , i = 0 ; i < mca_types - > size ; + + i ) {
if ( NULL = = ( str = ( char * ) opal_pointer_array_get_item ( mca_types , i ) ) ) {
continue ;
}
if ( 0 = = strcmp ( str , type ) ) {
found = true ;
break ;
}
}
2015-04-20 17:58:05 +03:00
2012-06-28 22:23:34 +04:00
if ( ! found ) {
char * usage = opal_cmd_line_get_usage_msg ( opal_info_cmd_line ) ;
opal_show_help ( " help-opal_info.txt " , " not-found " , true , type ) ;
free ( usage ) ;
exit ( 1 ) ;
}
2015-04-20 17:58:05 +03:00
2013-07-10 22:52:36 +04:00
opal_info_show_mca_params ( type , component , max_level , want_internal ) ;
2012-06-28 22:23:34 +04:00
}
}
}
Refs trac:3275.
We ran into a case where the OMPI SVN trunk grew a new acceptable MCA
parameter value, but this new value was not accepted on the v1.6
branch (hwloc_base_mem_bind_failure_action -- on the trunk it accepts
the value "silent", but on the older v1.6 branch, it doesn't). If you
set "hwloc_base_mem_bind_failure_action=silent" in the default MCA
params file and then accidentally ran with the v1.6 branch, every OMPI
executable (including ompi_info) just failed because hwloc_base_open()
would say "hey, 'silent' is not a valid value for
hwloc_base_mem_bind_failure_action!". Kaboom.
The only problem is that it didn't give you any indication of where
this value was being set. Quite maddening, from a user perspective.
So we changed the ompi_info handles this case. If any framework open
function return OMPI_ERR_BAD_PARAM (either because its base MCA params
got a bad value or because one of its component register/open
functions return OMPI_ERR_BAD_PARAM), ompi_info will stop, print out
a warning that it received and error, and then dump out the parameters
that it has received so far in the framework that had a problem.
At a minimum, this will show the user the MCA param that had an error
(it's usually the last one), and ''where it was set from'' (so that
they can go fix it).
We updated ompi_info to check for O???_ERR_BAD_PARAM from each from
the framework opens. Also updated the doxygen docs in mca.h for this
O???_BAD_PARAM behavior. And we noticed that mca.h had MCA_SUCCESS
and MCA_ERR_??? codes. Why? I think we used them in exactly one
place in the code base (mca_base_components_open.c). So we deleted
those and just used the normal OPAL_* codes instead.
While we were doing this, we also cleaned up a little memory
management during ompi_info/orte-info/opal-info finalization.
Valgrind still reports a truckload of memory still in use at ompi_info
termination, but they mostly look to be components not freeing
memory/resources properly (and outside the scope of this fix).
This commit was SVN r27306.
The following Trac tickets were found above:
Ticket 3275 --> https://svn.open-mpi.org/trac/ompi/ticket/3275
2012-09-12 00:47:24 +04:00
void opal_info_err_params ( opal_pointer_array_t * component_map )
{
2012-11-12 06:51:05 +04:00
opal_info_component_map_t * map = NULL , * mptr ;
Refs trac:3275.
We ran into a case where the OMPI SVN trunk grew a new acceptable MCA
parameter value, but this new value was not accepted on the v1.6
branch (hwloc_base_mem_bind_failure_action -- on the trunk it accepts
the value "silent", but on the older v1.6 branch, it doesn't). If you
set "hwloc_base_mem_bind_failure_action=silent" in the default MCA
params file and then accidentally ran with the v1.6 branch, every OMPI
executable (including ompi_info) just failed because hwloc_base_open()
would say "hey, 'silent' is not a valid value for
hwloc_base_mem_bind_failure_action!". Kaboom.
The only problem is that it didn't give you any indication of where
this value was being set. Quite maddening, from a user perspective.
So we changed the ompi_info handles this case. If any framework open
function return OMPI_ERR_BAD_PARAM (either because its base MCA params
got a bad value or because one of its component register/open
functions return OMPI_ERR_BAD_PARAM), ompi_info will stop, print out
a warning that it received and error, and then dump out the parameters
that it has received so far in the framework that had a problem.
At a minimum, this will show the user the MCA param that had an error
(it's usually the last one), and ''where it was set from'' (so that
they can go fix it).
We updated ompi_info to check for O???_ERR_BAD_PARAM from each from
the framework opens. Also updated the doxygen docs in mca.h for this
O???_BAD_PARAM behavior. And we noticed that mca.h had MCA_SUCCESS
and MCA_ERR_??? codes. Why? I think we used them in exactly one
place in the code base (mca_base_components_open.c). So we deleted
those and just used the normal OPAL_* codes instead.
While we were doing this, we also cleaned up a little memory
management during ompi_info/orte-info/opal-info finalization.
Valgrind still reports a truckload of memory still in use at ompi_info
termination, but they mostly look to be components not freeing
memory/resources properly (and outside the scope of this fix).
This commit was SVN r27306.
The following Trac tickets were found above:
Ticket 3275 --> https://svn.open-mpi.org/trac/ompi/ticket/3275
2012-09-12 00:47:24 +04:00
int i ;
/* all we want to do is display the LAST entry in the
* component_map array as this is the one that generated the error
*/
for ( i = 0 ; i < component_map - > size ; i + + ) {
if ( NULL = = ( mptr = ( opal_info_component_map_t * ) opal_pointer_array_get_item ( component_map , i ) ) ) {
continue ;
}
map = mptr ;
}
2012-11-12 06:51:05 +04:00
if ( NULL = = map ) {
fprintf ( stderr , " opal_info_err_params: map not found \n " ) ;
return ;
}
2013-07-10 22:52:36 +04:00
opal_info_show_mca_params ( map - > type , opal_info_component_all , OPAL_INFO_LVL_9 , true ) ;
Refs trac:3275.
We ran into a case where the OMPI SVN trunk grew a new acceptable MCA
parameter value, but this new value was not accepted on the v1.6
branch (hwloc_base_mem_bind_failure_action -- on the trunk it accepts
the value "silent", but on the older v1.6 branch, it doesn't). If you
set "hwloc_base_mem_bind_failure_action=silent" in the default MCA
params file and then accidentally ran with the v1.6 branch, every OMPI
executable (including ompi_info) just failed because hwloc_base_open()
would say "hey, 'silent' is not a valid value for
hwloc_base_mem_bind_failure_action!". Kaboom.
The only problem is that it didn't give you any indication of where
this value was being set. Quite maddening, from a user perspective.
So we changed the ompi_info handles this case. If any framework open
function return OMPI_ERR_BAD_PARAM (either because its base MCA params
got a bad value or because one of its component register/open
functions return OMPI_ERR_BAD_PARAM), ompi_info will stop, print out
a warning that it received and error, and then dump out the parameters
that it has received so far in the framework that had a problem.
At a minimum, this will show the user the MCA param that had an error
(it's usually the last one), and ''where it was set from'' (so that
they can go fix it).
We updated ompi_info to check for O???_ERR_BAD_PARAM from each from
the framework opens. Also updated the doxygen docs in mca.h for this
O???_BAD_PARAM behavior. And we noticed that mca.h had MCA_SUCCESS
and MCA_ERR_??? codes. Why? I think we used them in exactly one
place in the code base (mca_base_components_open.c). So we deleted
those and just used the normal OPAL_* codes instead.
While we were doing this, we also cleaned up a little memory
management during ompi_info/orte-info/opal-info finalization.
Valgrind still reports a truckload of memory still in use at ompi_info
termination, but they mostly look to be components not freeing
memory/resources properly (and outside the scope of this fix).
This commit was SVN r27306.
The following Trac tickets were found above:
Ticket 3275 --> https://svn.open-mpi.org/trac/ompi/ticket/3275
2012-09-12 00:47:24 +04:00
fprintf ( stderr , " \n " ) ;
return ;
}
2014-07-09 05:37:23 +04:00
void opal_info_do_type ( opal_cmd_line_t * opal_info_cmd_line )
{
2014-07-11 11:23:20 +04:00
mca_base_var_info_lvl_t max_level = OPAL_INFO_LVL_1 ;
2014-07-09 05:37:23 +04:00
int count ;
2014-07-10 02:37:22 +04:00
char * type , * str ;
2014-07-09 05:37:23 +04:00
int i , j , k , len , ret ;
char * p ;
const mca_base_var_t * var ;
char * * strings , * message ;
const mca_base_var_group_t * group ;
p = " type " ;
if ( NULL ! = ( str = opal_cmd_line_get_param ( opal_info_cmd_line , " level " , 0 , 0 ) ) ) {
char * tmp ;
errno = 0 ;
max_level = strtol ( str , & tmp , 10 ) + OPAL_INFO_LVL_1 - 1 ;
if ( 0 ! = errno | | ' \0 ' ! = tmp [ 0 ] | | max_level < OPAL_INFO_LVL_1 | | max_level > OPAL_INFO_LVL_9 ) {
char * usage = opal_cmd_line_get_usage_msg ( opal_info_cmd_line ) ;
opal_show_help ( " help-opal_info.txt " , " invalid-level " , true , str ) ;
free ( usage ) ;
exit ( 1 ) ;
}
}
count = opal_cmd_line_get_ninsts ( opal_info_cmd_line , p ) ;
len = mca_base_var_get_count ( ) ;
for ( k = 0 ; k < count ; + + k ) {
type = opal_cmd_line_get_param ( opal_info_cmd_line , p , k , 0 ) ;
for ( i = 0 ; i < len ; + + i ) {
ret = mca_base_var_get ( i , & var ) ;
if ( OPAL_SUCCESS ! = ret ) {
continue ;
}
if ( 0 = = strcmp ( type , var_type_names [ var - > mbv_type ] ) & & ( var - > mbv_info_lvl < = max_level ) ) {
ret = mca_base_var_dump ( var - > mbv_index , & strings , ! opal_info_pretty ? MCA_BASE_VAR_DUMP_PARSABLE : MCA_BASE_VAR_DUMP_READABLE ) ;
if ( OPAL_SUCCESS ! = ret ) {
continue ;
}
( void ) mca_base_var_group_get ( var - > mbv_group_index , & group ) ;
for ( j = 0 ; strings [ j ] ; + + j ) {
if ( 0 = = j & & opal_info_pretty ) {
asprintf ( & message , " MCA %s " , group - > group_framework ) ;
opal_info_out ( message , message , strings [ j ] ) ;
free ( message ) ;
} else {
opal_info_out ( " " , " " , strings [ j ] ) ;
}
free ( strings [ j ] ) ;
}
free ( strings ) ;
}
}
}
}
2013-03-28 01:09:41 +04:00
2013-07-10 22:52:36 +04:00
static void opal_info_show_mca_group_params ( const mca_base_var_group_t * group , mca_base_var_info_lvl_t max_level , bool want_internal )
2012-06-28 22:23:34 +04:00
{
2013-08-28 20:03:23 +04:00
const int * variables , * groups ;
const mca_base_pvar_t * pvar ;
const char * group_component ;
2013-03-28 01:09:41 +04:00
const mca_base_var_t * var ;
2013-08-28 20:03:23 +04:00
char * * strings , * message ;
bool requested = true ;
2013-03-28 01:09:41 +04:00
int ret , i , j , count ;
variables = OPAL_VALUE_ARRAY_GET_BASE ( & group - > group_vars , const int ) ;
count = opal_value_array_get_size ( ( opal_value_array_t * ) & group - > group_vars ) ;
2013-08-28 20:03:23 +04:00
/* the default component name is "base". depending on how the
* group was registered the group may or not have this set . */
group_component = group - > group_component ? group - > group_component : " base " ;
/* check if this group may be disabled due to a selection variable */
if ( 0 ! = strcmp ( group_component , " base " ) ) {
int var_id ;
/* read the selection parameter */
var_id = mca_base_var_find ( group - > group_project , group - > group_framework , NULL , NULL ) ;
if ( 0 < = var_id ) {
const mca_base_var_storage_t * value ;
char * * requested_components ;
bool include_mode ;
mca_base_var_get_value ( var_id , & value , NULL , NULL ) ;
if ( NULL ! = value - > stringval & & ' \0 ' ! = value - > stringval [ 0 ] ) {
mca_base_component_parse_requested ( value - > stringval , & include_mode , & requested_components ) ;
for ( i = 0 , requested = ! include_mode ; requested_components [ i ] ; + + i ) {
2015-02-24 20:46:55 +03:00
if ( 0 = = strcmp ( requested_components [ i ] , group_component ) ) {
2013-08-28 20:03:23 +04:00
requested = include_mode ;
break ;
}
}
opal_argv_free ( requested_components ) ;
}
}
}
2013-03-28 01:09:41 +04:00
for ( i = 0 ; i < count ; + + i ) {
ret = mca_base_var_get ( variables [ i ] , & var ) ;
if ( OPAL_SUCCESS ! = ret | | ( ( var - > mbv_flags & MCA_BASE_VAR_FLAG_INTERNAL ) & &
2013-07-10 22:52:36 +04:00
! want_internal ) | |
max_level < var - > mbv_info_lvl ) {
2013-03-28 01:09:41 +04:00
continue ;
}
ret = mca_base_var_dump ( variables [ i ] , & strings , ! opal_info_pretty ? MCA_BASE_VAR_DUMP_PARSABLE : MCA_BASE_VAR_DUMP_READABLE ) ;
if ( OPAL_SUCCESS ! = ret ) {
continue ;
}
for ( j = 0 ; strings [ j ] ; + + j ) {
if ( 0 = = j & & opal_info_pretty ) {
2013-08-28 20:03:23 +04:00
asprintf ( & message , " MCA%s %s " , requested ? " " : " (disabled) " , group - > group_framework ) ;
2013-03-28 01:09:41 +04:00
opal_info_out ( message , message , strings [ j ] ) ;
free ( message ) ;
} else {
opal_info_out ( " " , " " , strings [ j ] ) ;
2012-06-28 22:23:34 +04:00
}
2013-03-28 01:09:41 +04:00
free ( strings [ j ] ) ;
}
2013-08-28 20:03:23 +04:00
if ( ! opal_info_pretty ) {
/* generate an entry indicating whether this variable is disabled or not. if the
* format in mca_base_var / pvar . c changes this needs to be changed as well */
asprintf ( & message , " mca:%s:%s:param:%s:disabled:%s " , group - > group_framework ,
group_component , var - > mbv_full_name , requested ? " false " : " true " ) ;
opal_info_out ( " " , " " , message ) ;
free ( message ) ;
}
2013-03-28 01:09:41 +04:00
free ( strings ) ;
}
2013-07-16 20:02:13 +04:00
variables = OPAL_VALUE_ARRAY_GET_BASE ( & group - > group_pvars , const int ) ;
count = opal_value_array_get_size ( ( opal_value_array_t * ) & group - > group_pvars ) ;
for ( i = 0 ; i < count ; + + i ) {
2013-08-28 20:03:23 +04:00
ret = mca_base_pvar_get ( variables [ i ] , & pvar ) ;
if ( OPAL_SUCCESS ! = ret | | max_level < pvar - > verbosity ) {
continue ;
}
2013-07-16 20:02:33 +04:00
ret = mca_base_pvar_dump ( variables [ i ] , & strings , ! opal_info_pretty ? MCA_BASE_VAR_DUMP_PARSABLE : MCA_BASE_VAR_DUMP_READABLE ) ;
if ( OPAL_SUCCESS ! = ret ) {
continue ;
}
2013-07-16 20:02:13 +04:00
for ( j = 0 ; strings [ j ] ; + + j ) {
if ( 0 = = j & & opal_info_pretty ) {
2013-08-28 20:03:23 +04:00
asprintf ( & message , " MCA%s %s " , requested ? " " : " (disabled) " , group - > group_framework ) ;
2013-07-16 20:02:13 +04:00
opal_info_out ( message , message , strings [ j ] ) ;
free ( message ) ;
} else {
opal_info_out ( " " , " " , strings [ j ] ) ;
}
free ( strings [ j ] ) ;
}
2013-08-28 20:03:23 +04:00
if ( ! opal_info_pretty ) {
/* generate an entry indicating whether this variable is disabled or not. if the
* format in mca_base_var / pvar . c changes this needs to be changed as well */
asprintf ( & message , " mca:%s:%s:pvar:%s:disabled:%s " , group - > group_framework ,
group_component , pvar - > name , requested ? " false " : " true " ) ;
opal_info_out ( " " , " " , message ) ;
free ( message ) ;
}
2015-04-20 17:58:05 +03:00
free ( strings ) ;
2013-07-16 20:02:13 +04:00
}
2013-03-28 01:09:41 +04:00
groups = OPAL_VALUE_ARRAY_GET_BASE ( & group - > group_subgroups , const int ) ;
count = opal_value_array_get_size ( ( opal_value_array_t * ) & group - > group_subgroups ) ;
for ( i = 0 ; i < count ; + + i ) {
ret = mca_base_var_group_get ( groups [ i ] , & group ) ;
if ( OPAL_SUCCESS ! = ret ) {
continue ;
2012-06-28 22:23:34 +04:00
}
2013-07-10 22:52:36 +04:00
opal_info_show_mca_group_params ( group , max_level , want_internal ) ;
2013-03-28 01:09:41 +04:00
}
}
2015-04-20 17:58:05 +03:00
void opal_info_show_mca_params ( const char * type , const char * component ,
2013-07-10 22:52:36 +04:00
mca_base_var_info_lvl_t max_level , bool want_internal )
2013-03-28 01:09:41 +04:00
{
const mca_base_var_group_t * group ;
int ret ;
if ( 0 = = strcmp ( component , " all " ) ) {
ret = mca_base_var_group_find ( " * " , type , NULL ) ;
if ( 0 > ret ) {
return ;
}
( void ) mca_base_var_group_get ( ret , & group ) ;
2013-07-10 22:52:36 +04:00
opal_info_show_mca_group_params ( group , max_level , want_internal ) ;
2013-03-28 01:09:41 +04:00
} else {
ret = mca_base_var_group_find ( " * " , type , component ) ;
if ( 0 > ret ) {
return ;
}
( void ) mca_base_var_group_get ( ret , & group ) ;
2013-07-10 22:52:36 +04:00
opal_info_show_mca_group_params ( group , max_level , want_internal ) ;
2012-06-28 22:23:34 +04:00
}
}
void opal_info_do_arch ( )
{
opal_info_out ( " Configured architecture " , " config:arch " , OPAL_ARCH ) ;
}
void opal_info_do_hostname ( )
{
opal_info_out ( " Configure host " , " config:host " , OPAL_CONFIGURE_HOST ) ;
}
2015-04-14 20:41:25 +03:00
static char * escape_quotes ( const char * value )
{
const char * src ;
int num_quotes = 0 ;
for ( src = value ; src ! = NULL & & * src ! = ' \0 ' ; + + src ) {
if ( ' " ' = = * src ) {
+ + num_quotes ;
}
}
// If there are no quotes in the string, there's nothing to do
if ( 0 = = num_quotes ) {
return NULL ;
}
// If we have quotes, make a new string. Copy over the old
// string, escaping the quotes along the way. This is simple and
// clear to read; it's not particularly efficient (performance is
// definitely not important here).
char * quoted_value ;
quoted_value = calloc ( 1 , strlen ( value ) + num_quotes + 1 ) ;
if ( NULL = = quoted_value ) {
return NULL ;
}
char * dest ;
for ( src = value , dest = quoted_value ; * src ! = ' \0 ' ; + + src , + + dest ) {
if ( ' " ' = = * src ) {
* dest + + = ' \\ ' ;
}
* dest = * src ;
}
return quoted_value ;
}
2012-06-28 22:23:34 +04:00
/*
* Private variables - set some reasonable screen size defaults
*/
static int centerpoint = 24 ;
static int screen_width = 78 ;
2015-04-20 17:58:05 +03:00
/*
2012-06-28 22:23:34 +04:00
* Prints the passed integer in a pretty or parsable format .
*/
void opal_info_out ( const char * pretty_message , const char * plain_message , const char * value )
{
2013-03-28 01:09:41 +04:00
size_t len , max_value_width , value_offset ;
2012-06-28 22:23:34 +04:00
char * spaces = NULL ;
char * filler = NULL ;
char * pos , * v , savev , * v_to_free ;
2015-04-20 17:58:05 +03:00
2012-06-28 22:23:34 +04:00
# ifdef HAVE_ISATTY
/* If we have isatty(), if this is not a tty, then disable
* wrapping for grep - friendly behavior
*/
if ( 0 = = isatty ( STDOUT_FILENO ) ) {
screen_width = INT_MAX ;
}
# endif
2015-04-20 17:58:05 +03:00
2012-06-28 22:23:34 +04:00
# ifdef TIOCGWINSZ
if ( screen_width < INT_MAX ) {
struct winsize size ;
if ( ioctl ( STDOUT_FILENO , TIOCGWINSZ , ( char * ) & size ) > = 0 ) {
screen_width = size . ws_col ;
}
}
# endif
2015-02-12 22:54:36 +03:00
/* Sanity check (allow NULL to mean "") */
if ( NULL = = value ) {
value = " " ;
}
2012-06-28 22:23:34 +04:00
/* Strip leading and trailing whitespace from the string value */
2013-03-28 01:09:41 +04:00
value_offset = strspn ( value , " " ) ;
v = v_to_free = strdup ( value + value_offset ) ;
2012-06-28 22:23:34 +04:00
len = strlen ( v ) ;
2013-03-28 01:09:41 +04:00
if ( len > 0 ) {
while ( len > 0 & & isspace ( v [ len - 1 ] ) ) len - - ;
v [ len ] = ' \0 ' ;
2012-06-28 22:23:34 +04:00
}
if ( opal_info_pretty & & NULL ! = pretty_message ) {
if ( centerpoint > ( int ) strlen ( pretty_message ) ) {
2015-04-20 17:58:05 +03:00
asprintf ( & spaces , " %*s " , centerpoint -
2012-06-28 22:23:34 +04:00
( int ) strlen ( pretty_message ) , " " ) ;
} else {
spaces = strdup ( " " ) ;
# if OPAL_ENABLE_DEBUG
if ( centerpoint < ( int ) strlen ( pretty_message ) ) {
2015-04-20 17:58:05 +03:00
opal_show_help ( " help-opal_info.txt " ,
2012-06-28 22:23:34 +04:00
" developer warning: field too long " , false ,
pretty_message , centerpoint ) ;
}
# endif
}
max_value_width = screen_width - strlen ( spaces ) - strlen ( pretty_message ) - 2 ;
if ( 0 < strlen ( pretty_message ) ) {
asprintf ( & filler , " %s%s: " , spaces , pretty_message ) ;
} else {
asprintf ( & filler , " %s " , spaces ) ;
}
free ( spaces ) ;
spaces = NULL ;
2015-04-20 17:58:05 +03:00
2012-06-28 22:23:34 +04:00
while ( true ) {
if ( strlen ( v ) < max_value_width ) {
printf ( " %s%s \n " , filler , v ) ;
break ;
} else {
asprintf ( & spaces , " %*s " , centerpoint + 2 , " " ) ;
2015-04-20 17:58:05 +03:00
2012-06-28 22:23:34 +04:00
/* Work backwards to find the first space before
* max_value_width
*/
savev = v [ max_value_width ] ;
v [ max_value_width ] = ' \0 ' ;
pos = ( char * ) strrchr ( v , ( int ) ' ' ) ;
v [ max_value_width ] = savev ;
if ( NULL = = pos ) {
/* No space found < max_value_width. Look for the first
* space after max_value_width .
*/
pos = strchr ( & v [ max_value_width ] , ' ' ) ;
2015-04-20 17:58:05 +03:00
2012-06-28 22:23:34 +04:00
if ( NULL = = pos ) {
2015-04-20 17:58:05 +03:00
2012-06-28 22:23:34 +04:00
/* There's just no spaces. So just print it and be done. */
2015-04-20 17:58:05 +03:00
2012-06-28 22:23:34 +04:00
printf ( " %s%s \n " , filler , v ) ;
break ;
} else {
* pos = ' \0 ' ;
printf ( " %s%s \n " , filler , v ) ;
v = pos + 1 ;
}
} else {
* pos = ' \0 ' ;
printf ( " %s%s \n " , filler , v ) ;
v = pos + 1 ;
}
2015-04-20 17:58:05 +03:00
2012-06-28 22:23:34 +04:00
/* Reset for the next iteration */
free ( filler ) ;
filler = strdup ( spaces ) ;
free ( spaces ) ;
spaces = NULL ;
}
}
if ( NULL ! = filler ) {
free ( filler ) ;
}
if ( NULL ! = spaces ) {
free ( spaces ) ;
}
} else {
if ( NULL ! = plain_message & & 0 < strlen ( plain_message ) ) {
2015-04-14 20:41:25 +03:00
// Escape any double quotes in the value.
char * quoted_value ;
quoted_value = escape_quotes ( value ) ;
if ( NULL ! = quoted_value ) {
value = quoted_value ;
}
char * colon = strchr ( value , ' : ' ) ;
if ( NULL ! = colon ) {
printf ( " %s: \" %s \" \n " , plain_message , value ) ;
} else {
printf ( " %s:%s \n " , plain_message , value ) ;
}
if ( NULL ! = quoted_value ) {
free ( quoted_value ) ;
}
2012-06-28 22:23:34 +04:00
} else {
2013-03-28 01:09:41 +04:00
printf ( " %s \n " , value ) ;
2012-06-28 22:23:34 +04:00
}
}
if ( NULL ! = v_to_free ) {
free ( v_to_free ) ;
}
}
2015-04-20 17:58:05 +03:00
void opal_info_out_int ( const char * pretty_message ,
const char * plain_message ,
2012-06-28 22:23:34 +04:00
int value )
{
char * valstr ;
2015-04-20 17:58:05 +03:00
2012-06-28 22:23:34 +04:00
asprintf ( & valstr , " %d " , ( int ) value ) ;
opal_info_out ( pretty_message , plain_message , valstr ) ;
free ( valstr ) ;
}
/*
* Show all the components of a specific type / component combo ( component may be
* a wildcard )
*/
void opal_info_show_component_version ( opal_pointer_array_t * mca_types ,
opal_pointer_array_t * component_map ,
2015-04-20 17:58:05 +03:00
const char * type_name ,
2012-06-28 22:23:34 +04:00
const char * component_name ,
const char * scope , const char * ver_type )
{
bool want_all_components = false ;
2013-04-25 01:37:24 +04:00
bool want_all_types = false ;
2012-06-28 22:23:34 +04:00
bool found ;
mca_base_component_list_item_t * cli ;
int j ;
char * pos ;
opal_info_component_map_t * map ;
2015-04-20 17:58:05 +03:00
2012-06-28 22:23:34 +04:00
/* see if all components wanted */
2013-04-25 01:37:24 +04:00
if ( 0 = = strcmp ( opal_info_component_all , component_name ) ) {
2012-06-28 22:23:34 +04:00
want_all_components = true ;
}
2013-04-25 01:37:24 +04:00
/* see if all types wanted */
if ( 0 ! = strcmp ( opal_info_type_all , type_name ) ) {
/* Check to see if the type is valid */
2015-04-20 17:58:05 +03:00
2013-04-25 01:37:24 +04:00
for ( found = false , j = 0 ; j < mca_types - > size ; + + j ) {
if ( NULL = = ( pos = ( char * ) opal_pointer_array_get_item ( mca_types , j ) ) ) {
continue ;
}
if ( 0 = = strcmp ( pos , type_name ) ) {
found = true ;
break ;
}
2012-06-28 22:23:34 +04:00
}
2015-04-20 17:58:05 +03:00
2013-04-25 01:37:24 +04:00
if ( ! found ) {
return ;
}
} else {
2013-04-25 02:07:06 +04:00
want_all_types = true ;
2012-06-28 22:23:34 +04:00
}
2015-04-20 17:58:05 +03:00
2013-04-25 01:37:24 +04:00
/* Now that we have a valid type, find the right components */
2012-06-28 22:23:34 +04:00
for ( j = 0 ; j < component_map - > size ; j + + ) {
if ( NULL = = ( map = ( opal_info_component_map_t * ) opal_pointer_array_get_item ( component_map , j ) ) ) {
continue ;
}
2013-04-25 01:37:24 +04:00
if ( ( want_all_types | | 0 = = strcmp ( type_name , map - > type ) ) & & map - > components ) {
2012-06-28 22:23:34 +04:00
/* found it! */
2013-04-25 01:37:24 +04:00
OPAL_LIST_FOREACH ( cli , map - > components , mca_base_component_list_item_t ) {
const mca_base_component_t * component = cli - > cli_component ;
2015-04-20 17:58:05 +03:00
if ( want_all_components | |
2012-06-28 22:23:34 +04:00
0 = = strcmp ( component - > mca_component_name , component_name ) ) {
opal_info_show_mca_version ( component , scope , ver_type ) ;
}
}
2013-04-25 01:37:24 +04:00
if ( ! want_all_types ) {
break ;
}
2012-06-28 22:23:34 +04:00
}
}
}
/*
* Given a component , display its relevant version ( s )
*/
void opal_info_show_mca_version ( const mca_base_component_t * component ,
const char * scope , const char * ver_type )
{
bool printed ;
bool want_mca = false ;
bool want_type = false ;
bool want_component = false ;
char * message , * content ;
char * mca_version ;
char * api_version ;
char * component_version ;
char * tmp ;
2015-04-20 17:58:05 +03:00
2012-06-28 22:23:34 +04:00
if ( 0 = = strcmp ( ver_type , opal_info_ver_all ) | |
0 = = strcmp ( ver_type , opal_info_ver_mca ) ) {
want_mca = true ;
}
2015-04-20 17:58:05 +03:00
2012-06-28 22:23:34 +04:00
if ( 0 = = strcmp ( ver_type , opal_info_ver_all ) | |
0 = = strcmp ( ver_type , opal_info_ver_type ) ) {
want_type = true ;
}
2015-04-20 17:58:05 +03:00
2012-06-28 22:23:34 +04:00
if ( 0 = = strcmp ( ver_type , opal_info_ver_all ) | |
0 = = strcmp ( ver_type , opal_info_ver_component ) ) {
want_component = true ;
}
2015-04-20 17:58:05 +03:00
2012-06-28 22:23:34 +04:00
mca_version = opal_info_make_version_str ( scope , component - > mca_major_version ,
component - > mca_minor_version ,
component - > mca_release_version , " " ,
2014-10-02 18:31:47 +04:00
" " ) ;
2012-06-28 22:23:34 +04:00
api_version = opal_info_make_version_str ( scope , component - > mca_type_major_version ,
component - > mca_type_minor_version ,
component - > mca_type_release_version , " " ,
2014-10-02 18:31:47 +04:00
" " ) ;
2012-06-28 22:23:34 +04:00
component_version = opal_info_make_version_str ( scope , component - > mca_component_major_version ,
component - > mca_component_minor_version ,
2015-04-20 17:58:05 +03:00
component - > mca_component_release_version ,
2014-10-02 18:31:47 +04:00
" " , " " ) ;
2012-06-28 22:23:34 +04:00
if ( opal_info_pretty ) {
asprintf ( & message , " MCA %s " , component - > mca_type_name ) ;
printed = false ;
asprintf ( & content , " %s ( " , component - > mca_component_name ) ;
2015-04-20 17:58:05 +03:00
2012-06-28 22:23:34 +04:00
if ( want_mca ) {
asprintf ( & tmp , " %sMCA v%s " , content , mca_version ) ;
free ( content ) ;
content = tmp ;
printed = true ;
}
if ( want_type ) {
if ( printed ) {
asprintf ( & tmp , " %s, " , content ) ;
free ( content ) ;
content = tmp ;
}
asprintf ( & tmp , " %sAPI v%s " , content , api_version ) ;
free ( content ) ;
content = tmp ;
printed = true ;
}
if ( want_component ) {
if ( printed ) {
asprintf ( & tmp , " %s, " , content ) ;
free ( content ) ;
content = tmp ;
}
asprintf ( & tmp , " %sComponent v%s " , content , component_version ) ;
free ( content ) ;
content = tmp ;
printed = true ;
}
if ( NULL ! = content ) {
asprintf ( & tmp , " %s) " , content ) ;
free ( content ) ;
} else {
tmp = NULL ;
}
2015-04-20 17:58:05 +03:00
2012-06-28 22:23:34 +04:00
opal_info_out ( message , NULL , tmp ) ;
free ( message ) ;
if ( NULL ! = tmp ) {
free ( tmp ) ;
}
2015-04-20 17:58:05 +03:00
2012-06-28 22:23:34 +04:00
} else {
asprintf ( & message , " mca:%s:%s:version " , component - > mca_type_name , component - > mca_component_name ) ;
if ( want_mca ) {
asprintf ( & tmp , " mca:%s " , mca_version ) ;
opal_info_out ( NULL , message , tmp ) ;
free ( tmp ) ;
}
if ( want_type ) {
asprintf ( & tmp , " api:%s " , api_version ) ;
opal_info_out ( NULL , message , tmp ) ;
free ( tmp ) ;
}
if ( want_component ) {
asprintf ( & tmp , " component:%s " , component_version ) ;
opal_info_out ( NULL , message , tmp ) ;
free ( tmp ) ;
}
free ( message ) ;
}
if ( NULL ! = mca_version ) {
free ( mca_version ) ;
}
if ( NULL ! = api_version ) {
free ( api_version ) ;
}
if ( NULL ! = component_version ) {
free ( component_version ) ;
}
}
char * opal_info_make_version_str ( const char * scope ,
int major , int minor , int release ,
2014-10-02 18:31:47 +04:00
const char * greek ,
const char * repo )
2012-06-28 22:23:34 +04:00
{
char * str = NULL , * tmp ;
char temp [ BUFSIZ ] ;
2015-04-20 17:58:05 +03:00
2012-06-28 22:23:34 +04:00
temp [ BUFSIZ - 1 ] = ' \0 ' ;
if ( 0 = = strcmp ( scope , opal_info_ver_full ) | |
0 = = strcmp ( scope , opal_info_ver_all ) ) {
2014-09-30 19:54:18 +04:00
snprintf ( temp , BUFSIZ - 1 , " %d.%d.%d " , major , minor , release ) ;
2012-06-28 22:23:34 +04:00
str = strdup ( temp ) ;
if ( NULL ! = greek ) {
asprintf ( & tmp , " %s%s " , str , greek ) ;
free ( str ) ;
str = tmp ;
}
} else if ( 0 = = strcmp ( scope , opal_info_ver_major ) ) {
snprintf ( temp , BUFSIZ - 1 , " %d " , major ) ;
} else if ( 0 = = strcmp ( scope , opal_info_ver_minor ) ) {
snprintf ( temp , BUFSIZ - 1 , " %d " , minor ) ;
} else if ( 0 = = strcmp ( scope , opal_info_ver_release ) ) {
snprintf ( temp , BUFSIZ - 1 , " %d " , release ) ;
} else if ( 0 = = strcmp ( scope , opal_info_ver_greek ) ) {
str = strdup ( greek ) ;
} else if ( 0 = = strcmp ( scope , opal_info_ver_repo ) ) {
str = strdup ( repo ) ;
}
2015-04-20 17:58:05 +03:00
2012-06-28 22:23:34 +04:00
if ( NULL = = str ) {
str = strdup ( temp ) ;
}
2015-04-20 17:58:05 +03:00
2012-06-28 22:23:34 +04:00
return str ;
}
void opal_info_show_opal_version ( const char * scope )
{
char * tmp , * tmp2 ;
asprintf ( & tmp , " %s:version:full " , opal_info_type_opal ) ;
2015-04-20 17:58:05 +03:00
tmp2 = opal_info_make_version_str ( scope ,
OPAL_MAJOR_VERSION , OPAL_MINOR_VERSION ,
OPAL_RELEASE_VERSION ,
2012-06-28 22:23:34 +04:00
OPAL_GREEK_VERSION ,
2014-10-02 18:31:47 +04:00
OPAL_REPO_REV ) ;
2012-06-28 22:23:34 +04:00
opal_info_out ( " OPAL " , tmp , tmp2 ) ;
free ( tmp ) ;
free ( tmp2 ) ;
asprintf ( & tmp , " %s:version:repo " , opal_info_type_opal ) ;
opal_info_out ( " OPAL repo revision " , tmp , OPAL_REPO_REV ) ;
free ( tmp ) ;
asprintf ( & tmp , " %s:version:release_date " , opal_info_type_opal ) ;
opal_info_out ( " OPAL release date " , tmp , OPAL_RELEASE_DATE ) ;
free ( tmp ) ;
}