root/opal/mca/pmix/pmix4x/pmix/src/mca/pnet/base/pnet_base_select.c

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

DEFINITIONS

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

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