root/orte/mca/grpcomm/base/grpcomm_base_select.c

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

DEFINITIONS

This source file includes following definitions.
  1. orte_grpcomm_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) 2013      Los Alamos National Security, LLC.
  13  *                         All rights reserved.
  14  * Copyright (c) 2014      Intel, Inc. All rights reserved
  15  * $COPYRIGHT$
  16  *
  17  * Additional copyrights may follow
  18  *
  19  * $HEADER$
  20  */
  21 
  22 
  23 #include "orte_config.h"
  24 
  25 #include "orte/mca/mca.h"
  26 #include "opal/mca/base/base.h"
  27 
  28 #include "orte/util/name_fns.h"
  29 #include "orte/runtime/orte_globals.h"
  30 
  31 #include "orte/mca/grpcomm/base/base.h"
  32 
  33 
  34 static bool selected = false;
  35 
  36 /**
  37  * Function for selecting one component from all those that are
  38  * available.
  39  */
  40 int orte_grpcomm_base_select(void)
  41 {
  42     mca_base_component_list_item_t *cli = NULL;
  43     mca_base_component_t *component = NULL;
  44     mca_base_module_t *module = NULL;
  45     orte_grpcomm_base_module_t *nmodule;
  46     orte_grpcomm_base_active_t *newmodule, *mod;
  47     int rc, priority;
  48     bool inserted;
  49 
  50     if (selected) {
  51         /* ensure we don't do this twice */
  52         return ORTE_SUCCESS;
  53     }
  54     selected = true;
  55 
  56     /* Query all available components and ask if they have a module */
  57     OPAL_LIST_FOREACH(cli, &orte_grpcomm_base_framework.framework_components, mca_base_component_list_item_t) {
  58         component = (mca_base_component_t *) cli->cli_component;
  59 
  60         opal_output_verbose(5, orte_grpcomm_base_framework.framework_output,
  61                             "mca:grpcomm:select: checking available component %s", component->mca_component_name);
  62 
  63         /* If there's no query function, skip it */
  64         if (NULL == component->mca_query_component) {
  65             opal_output_verbose(5, orte_grpcomm_base_framework.framework_output,
  66                                 "mca:grpcomm:select: Skipping component [%s]. It does not implement a query function",
  67                                 component->mca_component_name );
  68             continue;
  69         }
  70 
  71         /* Query the component */
  72         opal_output_verbose(5, orte_grpcomm_base_framework.framework_output,
  73                             "mca:grpcomm:select: Querying component [%s]",
  74                             component->mca_component_name);
  75         rc = component->mca_query_component(&module, &priority);
  76 
  77         /* If no module was returned, then skip component */
  78         if (ORTE_SUCCESS != rc || NULL == module) {
  79             opal_output_verbose(5, orte_grpcomm_base_framework.framework_output,
  80                                 "mca:grpcomm:select: Skipping component [%s]. Query failed to return a module",
  81                                 component->mca_component_name );
  82             continue;
  83         }
  84         nmodule = (orte_grpcomm_base_module_t*) module;
  85 
  86         /* if the module fails to init, skip it */
  87         if (NULL == nmodule->init || ORTE_SUCCESS != nmodule->init()) {
  88             continue;
  89         }
  90 
  91         /* add to the list of selected modules */
  92         newmodule = OBJ_NEW(orte_grpcomm_base_active_t);
  93         newmodule->pri = priority;
  94         newmodule->module = nmodule;
  95         newmodule->component = component;
  96 
  97         /* maintain priority order */
  98         inserted = false;
  99         OPAL_LIST_FOREACH(mod, &orte_grpcomm_base.actives, orte_grpcomm_base_active_t) {
 100             if (priority > mod->pri) {
 101                 opal_list_insert_pos(&orte_grpcomm_base.actives,
 102                                      (opal_list_item_t*)mod, &newmodule->super);
 103                 inserted = true;
 104                 break;
 105             }
 106         }
 107         if (!inserted) {
 108             /* must be lowest priority - add to end */
 109             opal_list_append(&orte_grpcomm_base.actives, &newmodule->super);
 110         }
 111     }
 112 
 113     if (4 < opal_output_get_verbosity(orte_grpcomm_base_framework.framework_output)) {
 114         opal_output(0, "%s: Final grpcomm priorities", ORTE_NAME_PRINT(ORTE_PROC_MY_NAME));
 115         /* show the prioritized list */
 116         OPAL_LIST_FOREACH(mod, &orte_grpcomm_base.actives, orte_grpcomm_base_active_t) {
 117             opal_output(0, "\tComponent: %s Priority: %d", mod->component->mca_component_name, mod->pri);
 118         }
 119     }
 120     return ORTE_SUCCESS;
 121 }

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