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; }