root/opal/mca/pmix/pmix4x/pmix/src/mca/psec/base/psec_base_select.c

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

DEFINITIONS

This source file includes following definitions.
  1. pmix_psec_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/mca/mca.h"
  26 #include "src/mca/base/base.h"
  27 #include "src/util/error.h"
  28 #include "src/util/show_help.h"
  29 
  30 #include "src/mca/psec/base/base.h"
  31 
  32 static bool selected = false;
  33 
  34 /* Function for selecting a prioritized list of components
  35  * from all those that are available. */
  36 int pmix_psec_base_select(void)
  37 {
  38     pmix_mca_base_component_list_item_t *cli = NULL;
  39     pmix_mca_base_component_t *component = NULL;
  40     pmix_mca_base_module_t *module = NULL;
  41     pmix_psec_module_t *nmodule;
  42     pmix_psec_base_active_module_t *newmodule, *mod;
  43     int rc, priority;
  44     bool inserted;
  45 
  46     if (selected) {
  47         /* ensure we don't do this twice */
  48         return PMIX_SUCCESS;
  49     }
  50     selected = true;
  51 
  52     /* Query all available components and ask if they have a module */
  53     PMIX_LIST_FOREACH(cli, &pmix_psec_base_framework.framework_components, pmix_mca_base_component_list_item_t) {
  54         component = (pmix_mca_base_component_t *) cli->cli_component;
  55 
  56         pmix_output_verbose(5, pmix_psec_base_framework.framework_output,
  57                             "mca:psec:select: checking available component %s", component->pmix_mca_component_name);
  58 
  59         /* If there's no query function, skip it */
  60         if (NULL == component->pmix_mca_query_component) {
  61             pmix_output_verbose(5, pmix_psec_base_framework.framework_output,
  62                                 "mca:psec:select: Skipping component [%s]. It does not implement a query function",
  63                                 component->pmix_mca_component_name );
  64             continue;
  65         }
  66 
  67         /* Query the component */
  68         pmix_output_verbose(5, pmix_psec_base_framework.framework_output,
  69                             "mca:psec:select: Querying component [%s]",
  70                             component->pmix_mca_component_name);
  71         rc = component->pmix_mca_query_component(&module, &priority);
  72 
  73         /* If no module was returned, then skip component */
  74         if (PMIX_SUCCESS != rc || NULL == module) {
  75             pmix_output_verbose(5, pmix_psec_base_framework.framework_output,
  76                                 "mca:psec:select: Skipping component [%s]. Query failed to return a module",
  77                                 component->pmix_mca_component_name);
  78             continue;
  79         }
  80         nmodule = (pmix_psec_module_t*) module;
  81 
  82         /* give the module a chance to init */
  83         if (NULL != nmodule->init && PMIX_SUCCESS != nmodule->init()) {
  84             /* failed to init, so skip it */
  85             pmix_output_verbose(5, pmix_psec_base_framework.framework_output,
  86                                 "mca:psec:select: Skipping component [%s]. Failed to init",
  87                                 component->pmix_mca_component_name);
  88             continue;
  89         }
  90 
  91         /* If we got a module, keep it */
  92         /* add to the list of selected modules */
  93         newmodule = PMIX_NEW(pmix_psec_base_active_module_t);
  94         newmodule->pri = priority;
  95         newmodule->module = nmodule;
  96         newmodule->component = (pmix_psec_base_component_t*)cli->cli_component;
  97 
  98         /* maintain priority order */
  99         inserted = false;
 100         PMIX_LIST_FOREACH(mod, &pmix_psec_globals.actives, pmix_psec_base_active_module_t) {
 101             if (priority > mod->pri) {
 102                 pmix_list_insert_pos(&pmix_psec_globals.actives,
 103                                      (pmix_list_item_t*)mod, &newmodule->super);
 104                 inserted = true;
 105                 break;
 106             }
 107         }
 108         if (!inserted) {
 109             /* must be lowest priority - add to end */
 110             pmix_list_append(&pmix_psec_globals.actives, &newmodule->super);
 111         }
 112     }
 113 
 114     /* if no modules were found, then that's an error as we require at least one */
 115     if (0 == pmix_list_get_size(&pmix_psec_globals.actives)) {
 116         pmix_show_help("help-pmix-runtime.txt", "no-plugins", true, "PSEC");
 117         return PMIX_ERR_SILENT;
 118     }
 119 
 120     if (4 < pmix_output_get_verbosity(pmix_psec_base_framework.framework_output)) {
 121         pmix_output(0, "Final psec priorities");
 122         /* show the prioritized list */
 123         PMIX_LIST_FOREACH(mod, &pmix_psec_globals.actives, pmix_psec_base_active_module_t) {
 124             pmix_output(0, "\tpsec: %s Priority: %d", mod->component->base.pmix_mca_component_name, mod->pri);
 125         }
 126     }
 127 
 128     return PMIX_SUCCESS;;
 129 }

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