#include "src/include/pmix_config.h"
#include "pmix_common.h"
#include <string.h>
#include "src/mca/base/pmix_base.h"
#include "src/mca/mca.h"
#include "src/util/pmix_argv.h"
#include "src/util/pmix_error.h"
#include "src/util/pmix_show_help.h"
#include "src/mca/gds/base/base.h"
int pmix_gds_base_select(pmix_info_t info[], size_t ninfo)
{
pmix_mca_base_component_list_item_t *cli = NULL;
pmix_mca_base_component_t *component = NULL;
pmix_mca_base_module_t *module = NULL;
pmix_gds_base_module_t *nmodule;
pmix_gds_base_active_module_t *newmodule, *mod;
int rc, priority;
bool inserted;
char **mods = NULL;
if (pmix_gds_globals.selected) {
return PMIX_SUCCESS;
}
pmix_gds_globals.selected = true;
PMIX_LIST_FOREACH (cli, &pmix_gds_base_framework.framework_components,
pmix_mca_base_component_list_item_t) {
component = (pmix_mca_base_component_t *) cli->cli_component;
pmix_output_verbose(5, pmix_gds_base_framework.framework_output,
"mca:gds:select: checking available component %s",
component->pmix_mca_component_name);
if (NULL == component->pmix_mca_query_component) {
pmix_output_verbose(
5, pmix_gds_base_framework.framework_output,
"mca:gds:select: Skipping component [%s]. It does not implement a query function",
component->pmix_mca_component_name);
continue;
}
pmix_output_verbose(5, pmix_gds_base_framework.framework_output,
"mca:gds:select: Querying component [%s]",
component->pmix_mca_component_name);
rc = component->pmix_mca_query_component(&module, &priority);
if (PMIX_SUCCESS != rc || NULL == module) {
pmix_output_verbose(
5, pmix_gds_base_framework.framework_output,
"mca:gds:select: Skipping component [%s]. Query failed to return a module",
component->pmix_mca_component_name);
continue;
}
nmodule = (pmix_gds_base_module_t *) module;
if (NULL != nmodule->init && PMIX_SUCCESS != nmodule->init(info, ninfo)) {
continue;
}
newmodule = PMIX_NEW(pmix_gds_base_active_module_t);
newmodule->pri = priority;
newmodule->module = nmodule;
newmodule->component = (pmix_gds_base_component_t *) cli->cli_component;
inserted = false;
PMIX_LIST_FOREACH (mod, &pmix_gds_globals.actives, pmix_gds_base_active_module_t) {
if (priority > mod->pri) {
pmix_list_insert_pos(&pmix_gds_globals.actives, (pmix_list_item_t *) mod,
&newmodule->super);
inserted = true;
break;
}
}
if (!inserted) {
pmix_list_append(&pmix_gds_globals.actives, &newmodule->super);
}
}
if (0 == pmix_list_get_size(&pmix_gds_globals.actives)) {
pmix_show_help("help-pmix-runtime.txt", "no-plugins", true, "GDS");
return PMIX_ERR_SILENT;
}
PMIX_LIST_FOREACH (mod, &pmix_gds_globals.actives, pmix_gds_base_active_module_t) {
PMIx_Argv_append_nosize(&mods, mod->module->name);
}
pmix_gds_globals.all_mods = PMIx_Argv_join(mods, ',');
PMIx_Argv_free(mods);
if (4 < pmix_output_get_verbosity(pmix_gds_base_framework.framework_output)) {
pmix_output(0, "Final gds priorities");
PMIX_LIST_FOREACH (mod, &pmix_gds_globals.actives, pmix_gds_base_active_module_t) {
pmix_output(0, "\tgds: %s Priority: %d", mod->component->pmix_mca_component_name,
mod->pri);
}
}
return PMIX_SUCCESS;
;
}