diff --git a/src/mca/base/mca_base_param.c b/src/mca/base/mca_base_param.c index a2cc70ebe1..4ad178322c 100644 --- a/src/mca/base/mca_base_param.c +++ b/src/mca/base/mca_base_param.c @@ -326,6 +326,35 @@ int mca_base_param_find(const char *type_name, const char *component_name, } +int mca_base_param_set_internal(size_t index, bool internal) +{ + size_t len; + mca_base_param_t *array; + + /* Check for bozo cases */ + + if (!initialized) { + return OMPI_ERROR; + } + + len = ompi_value_array_get_size(&mca_base_params); + if (index > len) { + return OMPI_ERROR; + } + + /* We have a valid entry (remember that we never delete MCA + parameters, so if the index is >0 and mbp_type = MCA_BASE_PARAM_TYPE_MAX; + p->mbp_internal = false; p->mbp_type_name = NULL; p->mbp_component_name = NULL; diff --git a/src/mca/base/mca_base_param.h b/src/mca/base/mca_base_param.h index a9ca26e6fb..74393d4fe0 100644 --- a/src/mca/base/mca_base_param.h +++ b/src/mca/base/mca_base_param.h @@ -282,6 +282,27 @@ OMPI_DECLSPEC int mca_base_param_kv_lookup_string(int index, OMPI_DECLSPEC int mca_base_param_find(const char *type, const char *component, const char *param); + /** + * Set the "internal" flag on an MCA parameter to true or false. + * + * @param index[in] Index previous returned from + * mca_base_param_register_string() or mca_base_param_register_int(). + * @param internal[in] Boolean indicating whether the MCA + * parameter is internal (private) or public. + * + * @returns OMPI_SUCCESS If it can find the parameter to reset + * @returns OMPI_ERROR Otherwise + * + * "Internal" MCA parameters are ones that are not intentended to + * be seen or modified by users or user applications. These + * include values that are set at run time, such as TCP ports, IP + * addresses, etc. By setting the "internal" flag, internal MCA + * parameters are not displayed during the output of ompi_info and + * MPI_INIT (at least, they're not displayed by default), thus + * keeping them away from prying user eyes. + */ +OMPI_DECLSPEC int mca_base_param_set_internal(size_t index, bool internal); + /** * Shut down the MCA parameter system (normally only invoked by the * MCA framework itself). @@ -297,7 +318,7 @@ OMPI_DECLSPEC int mca_base_param_find(const char *type, const char *component, * is only documented here for completeness. */ OMPI_DECLSPEC int mca_base_param_finalize(void); - + #if defined(c_plusplus) || defined(__cplusplus) } #endif diff --git a/src/mca/base/mca_base_param_internal.h b/src/mca/base/mca_base_param_internal.h index fbd824d1c2..f139a3e92d 100644 --- a/src/mca/base/mca_base_param_internal.h +++ b/src/mca/base/mca_base_param_internal.h @@ -84,6 +84,10 @@ struct mca_base_param_t { /** Full parameter name, in case it is not __ */ char *mbp_full_name; + + /** Whether this is internal (not meant to be seen / modified by + users) or not */ + bool mbp_internal; /** Keyval value for MPI attribute parameters */ int mbp_keyval; diff --git a/src/tools/ompi_info/ompi_info.cc b/src/tools/ompi_info/ompi_info.cc index e6920574fa..d74c39c3e0 100644 --- a/src/tools/ompi_info/ompi_info.cc +++ b/src/tools/ompi_info/ompi_info.cc @@ -80,26 +80,28 @@ int main(int argc, char *argv[]) exit(ret); } ompi_cmd_line_make_opt(cmd_line, 'v', "version", 2, - "Show version of Open MPI or a component"); + "Show version of Open MPI or a component"); ompi_cmd_line_make_opt(cmd_line, '\0', "param", 2, - "Show MCA parameters"); + "Show MCA parameters"); + ompi_cmd_line_make_opt(cmd_line, '\0', "internal", 0, + "Show internal MCA parameters (not meant to be modified by users"); ompi_cmd_line_make_opt(cmd_line, '\0', "path", 1, - "Show paths that Open MPI was configured with"); + "Show paths that Open MPI was configured with"); ompi_cmd_line_make_opt(cmd_line, '\0', "arch", 0, - "Show architecture Open MPI was compiled on"); + "Show architecture Open MPI was compiled on"); ompi_cmd_line_make_opt(cmd_line, 'c', "config", 0, - "Show configuration options"); + "Show configuration options"); ompi_cmd_line_make_opt(cmd_line, 'h', "help", 0, - "Show this help message"); + "Show this help message"); ompi_cmd_line_make_opt(cmd_line, '\0', "pretty", 0, - "Display output in 'prettyprint' format (default)"); + "Display output in 'prettyprint' format (default)"); ompi_cmd_line_make_opt(cmd_line, '\0', "parsable", 0, - "Display output in parsable format"); + "Display output in parsable format"); ompi_cmd_line_make_opt(cmd_line, '\0', "hostname", 0, - "Show the hostname that Open MPI was configured " - "and built on"); + "Show the hostname that Open MPI was configured " + "and built on"); ompi_cmd_line_make_opt(cmd_line, 'a', "all", 0, - "Show all configuration options and MCA parameters"); + "Show all configuration options and MCA parameters"); // Call some useless functions in order to guarantee to link in some // global variables. Only check the return value so that the @@ -177,7 +179,7 @@ int main(int argc, char *argv[]) acted = true; } if (want_all || ompi_cmd_line_is_taken(cmd_line, "param")) { - do_params(want_all); + do_params(want_all, ompi_cmd_line_is_taken(cmd_line, "internal")); acted = true; } diff --git a/src/tools/ompi_info/ompi_info.h b/src/tools/ompi_info/ompi_info.h index eb1489650c..912bbec56d 100644 --- a/src/tools/ompi_info/ompi_info.h +++ b/src/tools/ompi_info/ompi_info.h @@ -73,9 +73,9 @@ namespace ompi_info { extern std::string path_pkglibdir; extern std::string path_sysconfdir; - void do_params(bool want_all); + void do_params(bool want_all, bool want_internal); void show_mca_params(const std::string& type, const std::string& component, - const std::string& param); + const std::string& param, bool want_internal); void do_path(bool want_all, ompi_cmd_line_t *cmd_line); void show_path(const std::string& type, const std::string& value); diff --git a/src/tools/ompi_info/param.cc b/src/tools/ompi_info/param.cc index faf6ccd6c2..5fb64dd55c 100644 --- a/src/tools/ompi_info/param.cc +++ b/src/tools/ompi_info/param.cc @@ -59,7 +59,7 @@ string ompi_info::path_sysconfdir = "sysconfdir"; extern ompi_value_array_t mca_base_params; -void ompi_info::do_params(bool want_all) +void ompi_info::do_params(bool want_all, bool want_internal) { unsigned int count; string type, component; @@ -84,7 +84,7 @@ void ompi_info::do_params(bool want_all) if (want_all) { for (i = 0; i < mca_types.size(); ++i) { - show_mca_params(mca_types[i], component_all, param_all); + show_mca_params(mca_types[i], component_all, param_all, want_internal); } } else { for (i = 0; i < count; ++i) { @@ -105,14 +105,14 @@ void ompi_info::do_params(bool want_all) exit(1); } - show_mca_params(type, component, param_all); + show_mca_params(type, component, param_all, want_internal); } } } void ompi_info::show_mca_params(const string& type, const string& component, - const string& param) + const string& param, bool want_internal) { size_t i, size; char *value_string, empty[] = "\0"; @@ -127,7 +127,8 @@ void ompi_info::show_mca_params(const string& type, const string& component, for (i = 0; i < size; ++i) { item = &(OMPI_VALUE_ARRAY_GET_ITEM(&mca_base_params, mca_base_param_t, i)); - if (type == item->mbp_type_name) { + if (type == item->mbp_type_name && + (!item->mbp_internal || want_internal)) { if (component == component_all || NULL == item->mbp_component_name || (NULL != item->mbp_component_name &&