root/opal/mca/pmix/pmix4x/pmix/src/mca/gds/base/gds_base_select.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. pmix_gds_base_select

   1 /*
   2  * Copyright (c) 2004-2008 The Trustees of Indiana University and Indiana
   3  *                         University Research and Technology
   4  *                         Corporation.  All rights reserved.
   5  * Copyright (c) 2004-2005 The University of Tennessee and The University
   6  *                         of Tennessee Research Foundation.  All rights
   7  *                         reserved.
   8  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
   9  *                         University of Stuttgart.  All rights reserved.
  10  * Copyright (c) 2004-2005 The Regents of the University of California.
  11  *                         All rights reserved.
  12  * Copyright (c) 2016-2017 Intel, Inc. All rights reserved.
  13  * $COPYRIGHT$
  14  *
  15  * Additional copyrights may follow
  16  *
  17  * $HEADER$
  18  */
  19 
  20 #include <src/include/pmix_config.h>
  21 #include <pmix_common.h>
  22 
  23 #include <string.h>
  24 
  25 #include "src/util/argv.h"
  26 #include "src/util/error.h"
  27 #include "src/util/show_help.h"
  28 #include "src/mca/mca.h"
  29 #include "src/mca/base/base.h"
  30 
  31 #include "src/mca/gds/base/base.h"
  32 
  33 static bool selected = false;
  34 
  35 /* Function for selecting a prioritized list of components
  36  * from all those that are available. */
  37 int pmix_gds_base_select(pmix_info_t info[], size_t ninfo)
  38 {
  39     pmix_mca_base_component_list_item_t *cli = NULL;
  40     pmix_mca_base_component_t *component = NULL;
  41     pmix_mca_base_module_t *module = NULL;
  42     pmix_gds_base_module_t *nmodule;
  43     pmix_gds_base_active_module_t *newmodule, *mod;
  44     int rc, priority;
  45     bool inserted;
  46     char **mods = NULL;
  47 
  48     if (selected) {
  49         /* ensure we don't do this twice */
  50         return PMIX_SUCCESS;
  51     }
  52     selected = true;
  53 
  54     /* Query all available components and ask if they have a module */
  55     PMIX_LIST_FOREACH(cli, &pmix_gds_base_framework.framework_components, pmix_mca_base_component_list_item_t) {
  56         component = (pmix_mca_base_component_t *) cli->cli_component;
  57 
  58         pmix_output_verbose(5, pmix_gds_base_framework.framework_output,
  59                             "mca:gds:select: checking available component %s", component->pmix_mca_component_name);
  60 
  61         /* If there's no query function, skip it */
  62         if (NULL == component->pmix_mca_query_component) {
  63             pmix_output_verbose(5, pmix_gds_base_framework.framework_output,
  64                                 "mca:gds:select: Skipping component [%s]. It does not implement a query function",
  65                                 component->pmix_mca_component_name );
  66             continue;
  67         }
  68 
  69         /* Query the component */
  70         pmix_output_verbose(5, pmix_gds_base_framework.framework_output,
  71                             "mca:gds:select: Querying component [%s]",
  72                             component->pmix_mca_component_name);
  73         rc = component->pmix_mca_query_component(&module, &priority);
  74 
  75         /* If no module was returned, then skip component */
  76         if (PMIX_SUCCESS != rc || NULL == module) {
  77             pmix_output_verbose(5, pmix_gds_base_framework.framework_output,
  78                                 "mca:gds:select: Skipping component [%s]. Query failed to return a module",
  79                                 component->pmix_mca_component_name );
  80             continue;
  81         }
  82 
  83         /* If we got a module, keep it */
  84         nmodule = (pmix_gds_base_module_t*) module;
  85         /* let it initialize */
  86         if (NULL != nmodule->init && PMIX_SUCCESS != nmodule->init(info, ninfo)) {
  87             continue;
  88         }
  89         /* add to the list of selected modules */
  90         newmodule = PMIX_NEW(pmix_gds_base_active_module_t);
  91         newmodule->pri = priority;
  92         newmodule->module = nmodule;
  93         newmodule->component = (pmix_gds_base_component_t*)cli->cli_component;
  94 
  95         /* maintain priority order */
  96         inserted = false;
  97         PMIX_LIST_FOREACH(mod, &pmix_gds_globals.actives, pmix_gds_base_active_module_t) {
  98             if (priority > mod->pri) {
  99                 pmix_list_insert_pos(&pmix_gds_globals.actives,
 100                                      (pmix_list_item_t*)mod, &newmodule->super);
 101                 inserted = true;
 102                 break;
 103             }
 104         }
 105         if (!inserted) {
 106             /* must be lowest priority - add to end */
 107             pmix_list_append(&pmix_gds_globals.actives, &newmodule->super);
 108         }
 109     }
 110 
 111     /* if no modules were found, then that's an error as we require at least one */
 112     if (0 == pmix_list_get_size(&pmix_gds_globals.actives)) {
 113         pmix_show_help("help-pmix-runtime.txt", "no-plugins", true, "GDS");
 114         return PMIX_ERR_SILENT;
 115     }
 116 
 117     /* setup the list of all module names */
 118     PMIX_LIST_FOREACH(mod, &pmix_gds_globals.actives, pmix_gds_base_active_module_t) {
 119         pmix_argv_append_nosize(&mods, mod->module->name);
 120     }
 121     pmix_gds_globals.all_mods = pmix_argv_join(mods, ',');
 122     pmix_argv_free(mods);
 123 
 124     if (4 < pmix_output_get_verbosity(pmix_gds_base_framework.framework_output)) {
 125         pmix_output(0, "Final gds priorities");
 126         /* show the prioritized list */
 127         PMIX_LIST_FOREACH(mod, &pmix_gds_globals.actives, pmix_gds_base_active_module_t) {
 128             pmix_output(0, "\tgds: %s Priority: %d", mod->component->base.pmix_mca_component_name, mod->pri);
 129         }
 130     }
 131 
 132     return PMIX_SUCCESS;;
 133 }

/* [<][>][^][v][top][bottom][index][help] */