1
1

Add a new classification to MCA parameters: "internal" MCA

parameters.  These are intended to be used by the system itself for
passing information around, and are not generally intended for the
user to see or modify.  Hence, we flag them as "internal" which causes
them not to show up in the ompi_info output (by default).  This
"security through obscurity" is good enough -- it's really only
intended to keep casual observers away.  The MCA parameters are still
there and are still settable (if a developer wants to set them).

To mark an MCA parameter as internal, simply call
mca_param_set_internal() with its index.  I debated about adding a
flag to mca_param_register_[int|string](), but then would have
involved changing a *lot* of code throughout the base -- and internal
MCA parameters is certainly not the common case.

Note that you can provide the new ompi_info flag --internal in
conjunction with the --param flag to force it to also show all the
internal MCA params.

This commit was SVN r4373.
Этот коммит содержится в:
Jeff Squyres 2005-02-10 04:37:13 +00:00
родитель dd30902bde
Коммит 1676187b3e
6 изменённых файлов: 79 добавлений и 20 удалений

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

@ -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 <len, it must be good),
so save the internal flag */
array = OMPI_VALUE_ARRAY_GET_BASE(&mca_base_params, mca_base_param_t);
array[index].mbp_internal = internal;
/* All done */
return OMPI_SUCCESS;
}
/* /*
* Shut down the MCA parameter system (normally only invoked by the * Shut down the MCA parameter system (normally only invoked by the
* MCA framework itself). * MCA framework itself).
@ -411,6 +440,7 @@ static int param_register(const char *type_name, const char *component_name,
OBJ_CONSTRUCT(&param, mca_base_param_t); OBJ_CONSTRUCT(&param, mca_base_param_t);
param.mbp_type = type; param.mbp_type = type;
param.mbp_keyval = MPI_KEYVAL_INVALID; param.mbp_keyval = MPI_KEYVAL_INVALID;
param.mbp_internal = false;
param.mbp_type_name = strdup(type_name); param.mbp_type_name = strdup(type_name);
if (NULL == param.mbp_type_name) { if (NULL == param.mbp_type_name) {
@ -839,6 +869,7 @@ static bool set(mca_base_param_type_t type,
static void param_constructor(mca_base_param_t *p) static void param_constructor(mca_base_param_t *p)
{ {
p->mbp_type = MCA_BASE_PARAM_TYPE_MAX; p->mbp_type = MCA_BASE_PARAM_TYPE_MAX;
p->mbp_internal = false;
p->mbp_type_name = NULL; p->mbp_type_name = NULL;
p->mbp_component_name = NULL; p->mbp_component_name = NULL;

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

@ -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, OMPI_DECLSPEC int mca_base_param_find(const char *type, const char *component,
const char *param); 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 * Shut down the MCA parameter system (normally only invoked by the
* MCA framework itself). * 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. * is only documented here for completeness.
*/ */
OMPI_DECLSPEC int mca_base_param_finalize(void); OMPI_DECLSPEC int mca_base_param_finalize(void);
#if defined(c_plusplus) || defined(__cplusplus) #if defined(c_plusplus) || defined(__cplusplus)
} }
#endif #endif

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

@ -84,6 +84,10 @@ struct mca_base_param_t {
/** Full parameter name, in case it is not /** Full parameter name, in case it is not
<type>_<component>_<param> */ <type>_<component>_<param> */
char *mbp_full_name; 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 */ /** Keyval value for MPI attribute parameters */
int mbp_keyval; int mbp_keyval;

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

@ -80,26 +80,28 @@ int main(int argc, char *argv[])
exit(ret); exit(ret);
} }
ompi_cmd_line_make_opt(cmd_line, 'v', "version", 2, 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, 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, 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, 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, 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, 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, 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, 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, ompi_cmd_line_make_opt(cmd_line, '\0', "hostname", 0,
"Show the hostname that Open MPI was configured " "Show the hostname that Open MPI was configured "
"and built on"); "and built on");
ompi_cmd_line_make_opt(cmd_line, 'a', "all", 0, 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 // Call some useless functions in order to guarantee to link in some
// global variables. Only check the return value so that the // global variables. Only check the return value so that the
@ -177,7 +179,7 @@ int main(int argc, char *argv[])
acted = true; acted = true;
} }
if (want_all || ompi_cmd_line_is_taken(cmd_line, "param")) { 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; acted = true;
} }

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

@ -73,9 +73,9 @@ namespace ompi_info {
extern std::string path_pkglibdir; extern std::string path_pkglibdir;
extern std::string path_sysconfdir; 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, 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 do_path(bool want_all, ompi_cmd_line_t *cmd_line);
void show_path(const std::string& type, const std::string& value); void show_path(const std::string& type, const std::string& value);

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

@ -59,7 +59,7 @@ string ompi_info::path_sysconfdir = "sysconfdir";
extern ompi_value_array_t mca_base_params; 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; unsigned int count;
string type, component; string type, component;
@ -84,7 +84,7 @@ void ompi_info::do_params(bool want_all)
if (want_all) { if (want_all) {
for (i = 0; i < mca_types.size(); ++i) { 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 { } else {
for (i = 0; i < count; ++i) { for (i = 0; i < count; ++i) {
@ -105,14 +105,14 @@ void ompi_info::do_params(bool want_all)
exit(1); 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, 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; size_t i, size;
char *value_string, empty[] = "\0"; 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) { for (i = 0; i < size; ++i) {
item = &(OMPI_VALUE_ARRAY_GET_ITEM(&mca_base_params, mca_base_param_t, 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 || if (component == component_all ||
NULL == item->mbp_component_name || NULL == item->mbp_component_name ||
(NULL != item->mbp_component_name && (NULL != item->mbp_component_name &&