int MPI_T_cvar_get_info(int cvar_index, char *name, int *name_len, int *verbosity, MPI_Datatype *datatype, MPI_T_enum *enumtype, char *desc, int *desc_len, int *bind, int *scope) { const mca_base_var_t *var; int rc = MPI_SUCCESS; if (!mpit_is_initialized ()) { return MPI_T_ERR_NOT_INITIALIZED; } mpit_lock (); do { rc = mca_base_var_get (cvar_index, &var); if (OPAL_SUCCESS != rc) { rc = (OPAL_ERR_VALUE_OUT_OF_BOUNDS == rc || OPAL_ERR_NOT_FOUND == rc) ? MPI_T_ERR_INVALID_INDEX : MPI_ERR_OTHER; break; } mpit_copy_string (name, name_len, var->mbv_full_name); mpit_copy_string (desc, desc_len, var->mbv_description); /* find the corresponding mpi type for an mca type */ rc = ompit_var_type_to_datatype (var->mbv_type, datatype); if (OMPI_SUCCESS != rc) { break; } if (NULL != enumtype) { *enumtype = var->mbv_enumerator ? (MPI_T_enum) var->mbv_enumerator : MPI_T_ENUM_NULL; } if (NULL != scope) { *scope = var->mbv_scope; } /* XXX -- TODO -- All bindings are currently 0. Add support for variable binding. */ if (NULL != bind) { *bind = var->mbv_bind; } if (NULL != verbosity) { *verbosity = var->mbv_info_lvl; } } while (0); mpit_unlock (); return rc; }
int MPI_T_cvar_handle_alloc (int cvar_index, void *obj_handle, MPI_T_cvar_handle *handle, int *count) { ompi_mpit_cvar_handle_t *new_handle; int rc = MPI_SUCCESS;; if (!mpit_is_initialized ()) { return MPI_T_ERR_NOT_INITIALIZED; } if (MPI_PARAM_CHECK && (NULL == handle || NULL == count)) { return MPI_ERR_ARG; } mpit_lock (); *handle = NULL; do { new_handle = (ompi_mpit_cvar_handle_t *) malloc (sizeof (ompi_mpit_cvar_handle_t)); if (NULL == new_handle) { rc = MPI_T_ERR_MEMORY; break; } rc = mca_base_var_get(cvar_index, &new_handle->var); if (OPAL_SUCCESS != rc) { rc = (OPAL_ERR_VALUE_OUT_OF_BOUNDS == rc) ? MPI_T_ERR_INVALID_INDEX: MPI_ERR_OTHER; free (new_handle); break; } new_handle->bound_object = obj_handle; if (MCA_BASE_VAR_TYPE_STRING == new_handle->var->mbv_type) { /* Arbitrary string limit. Is there a better way to do this? */ *count = 2048; } else { /* MCA only supports a single integer at this time. Change me if this assumption changes. */ *count = 1; } *handle = (MPI_T_cvar_handle) new_handle; } while (0); mpit_unlock (); return rc; }
static void orcm_info_show_mca_group_params(const mca_base_var_group_t *group, bool want_internal) { const mca_base_var_t *var; const int *variables; int ret, i, j, count; const int *groups; char **strings; variables = OPAL_VALUE_ARRAY_GET_BASE(&group->group_vars, const int); count = opal_value_array_get_size((opal_value_array_t *)&group->group_vars); 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) && !want_internal)) { continue; } ret = mca_base_var_dump(variables[i], &strings, !orcm_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 && orcm_info_pretty) { char *message; asprintf (&message, "MCA %s", group->group_framework); orcm_info_out(message, message, strings[j]); free(message); } else { orcm_info_out("", "", strings[j]); } free(strings[j]); } free(strings); } 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; } orcm_info_show_mca_group_params(group, want_internal); } }
int ompi_show_all_mca_params(int32_t rank, int requested, char *nodename) { const mca_base_var_t *var; int var_count, i, ret; FILE *fp = NULL; time_t timestamp; char **var_dump; if (rank != 0) { return OMPI_SUCCESS; } timestamp = time(NULL); /* Open the file if one is specified */ if (0 != strlen(ompi_mpi_show_mca_params_file)) { if ( NULL == (fp = fopen(ompi_mpi_show_mca_params_file, "w")) ) { opal_output(0, "Unable to open file <%s> to write MCA parameters", ompi_mpi_show_mca_params_file); return OMPI_ERR_FILE_OPEN_FAILURE; } fprintf(fp, "#\n"); fprintf(fp, "# This file was automatically generated on %s", ctime(×tamp)); fprintf(fp, "# by MPI_COMM_WORLD rank %d (out of a total of %d) on %s\n", rank, requested, nodename ); fprintf(fp, "#\n"); } var_count = mca_base_var_get_count (); for (i = 0 ; i < var_count ; ++i) { ret = mca_base_var_get (i, &var); if (OPAL_SUCCESS != ret) { continue; } /* If this is an internal param, don't print it */ if (MCA_BASE_VAR_FLAG_INTERNAL & var->mbv_flags) { continue; } /* is this a default value and we are not displaying * defaults, ignore this one */ if (MCA_BASE_VAR_SOURCE_DEFAULT == var->mbv_source && !show_default_mca_params) { continue; } /* is this a file value and we are not displaying files, * ignore it */ if ((MCA_BASE_VAR_SOURCE_FILE == var->mbv_source || MCA_BASE_VAR_SOURCE_OVERRIDE) && !show_file_mca_params) { continue; } /* is this an enviro value and we are not displaying enviros, * ignore it */ if (MCA_BASE_VAR_SOURCE_ENV == var->mbv_source && !show_enviro_mca_params) { continue; } /* is this an API value and we are not displaying APIs, * ignore it */ if (MCA_BASE_VAR_SOURCE_OVERRIDE == var->mbv_source && !show_override_mca_params) { continue; } ret = mca_base_var_dump (i, &var_dump, MCA_BASE_VAR_DUMP_SIMPLE); if (OPAL_SUCCESS != ret) { continue; } /* Print the parameter */ if (0 != strlen(ompi_mpi_show_mca_params_file)) { fprintf(fp, "%s\n", var_dump[0]); } else { opal_output(0, "%s\n", var_dump[0]); } free (var_dump[0]); free (var_dump); } /* Close file, cleanup allocated memory*/ if (0 != strlen(ompi_mpi_show_mca_params_file)) { fclose(fp); } return OMPI_SUCCESS; }