root/orte/mca/oob/base/oob_base_select.c

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

DEFINITIONS

This source file includes following definitions.
  1. orte_oob_base_select

   1 /*
   2  * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
   3  *                         University Research and Technology
   4  *                         Corporation.  All rights reserved.
   5  * Copyright (c) 2004-2006 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) 2007      Cisco Systems, Inc.  All rights reserved.
  13  * Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights
  14  *                         reserved.
  15  * Copyright (c) 2014-2015 Intel, Inc. All rights reserved.
  16  * $COPYRIGHT$
  17  *
  18  * Additional copyrights may follow
  19  *
  20  * $HEADER$
  21  */
  22 
  23 #include "orte_config.h"
  24 #include "orte/constants.h"
  25 
  26 #include <stdio.h>
  27 #include <string.h>
  28 
  29 #include "orte/mca/mca.h"
  30 #include "opal/util/output.h"
  31 #include "opal/mca/base/base.h"
  32 
  33 #include "orte/util/show_help.h"
  34 
  35 #include "orte/runtime/orte_globals.h"
  36 #include "orte/mca/oob/oob.h"
  37 #include "orte/mca/oob/base/base.h"
  38 
  39 
  40 /**
  41  * Function for selecting all runnable modules from those that are
  42  * available.
  43  *
  44  * Call the init function on all available modules.
  45  */
  46 int orte_oob_base_select(void)
  47 {
  48     mca_base_component_list_item_t *cli, *cmp, *c2;
  49     mca_oob_base_component_t *component, *c3;
  50     bool added;
  51     int i, rc;
  52 
  53     /* Query all available components and ask if their transport is available */
  54     OPAL_LIST_FOREACH(cli, &orte_oob_base_framework.framework_components, mca_base_component_list_item_t) {
  55         component = (mca_oob_base_component_t *) cli->cli_component;
  56 
  57         opal_output_verbose(5, orte_oob_base_framework.framework_output,
  58                             "mca:oob:select: checking available component %s",
  59                             component->oob_base.mca_component_name);
  60 
  61         /* If there's no query function, skip it */
  62         if (NULL == component->available) {
  63             opal_output_verbose(5, orte_oob_base_framework.framework_output,
  64                                 "mca:oob:select: Skipping component [%s]. It does not implement a query function",
  65                                 component->oob_base.mca_component_name );
  66             continue;
  67         }
  68 
  69         /* Query the component */
  70         opal_output_verbose(5, orte_oob_base_framework.framework_output,
  71                             "mca:oob:select: Querying component [%s]",
  72                             component->oob_base.mca_component_name);
  73 
  74         rc = component->available();
  75 
  76         /* If the component is not available, then skip it as
  77          * it has no available interfaces
  78          */
  79         if (ORTE_SUCCESS != rc && ORTE_ERR_FORCE_SELECT != rc) {
  80             opal_output_verbose(5, orte_oob_base_framework.framework_output,
  81                                 "mca:oob:select: Skipping component [%s] - no available interfaces",
  82                                 component->oob_base.mca_component_name );
  83             continue;
  84         }
  85 
  86         /* if it fails to startup, then skip it */
  87         if (ORTE_SUCCESS != component->startup()) {
  88             opal_output_verbose(5, orte_oob_base_framework.framework_output,
  89                                 "mca:oob:select: Skipping component [%s] - failed to startup",
  90                                 component->oob_base.mca_component_name );
  91             continue;
  92         }
  93 
  94         if (ORTE_ERR_FORCE_SELECT == rc) {
  95             /* this component shall be the *only* component allowed
  96              * for use, so shutdown and remove any prior ones */
  97             while (NULL != (cmp = (mca_base_component_list_item_t*)opal_list_remove_first(&orte_oob_base.actives))) {
  98                 c3 = (mca_oob_base_component_t *) cmp->cli_component;
  99                 if (NULL != c3->shutdown) {
 100                     c3->shutdown();
 101                 }
 102                 OBJ_RELEASE(cmp);
 103             }
 104             c2 = OBJ_NEW(mca_base_component_list_item_t);
 105             c2->cli_component = (mca_base_component_t*)component;
 106             opal_list_append(&orte_oob_base.actives, &c2->super);
 107             break;
 108         }
 109 
 110         /* record it, but maintain priority order */
 111         added = false;
 112         OPAL_LIST_FOREACH(cmp, &orte_oob_base.actives, mca_base_component_list_item_t) {
 113             c3 = (mca_oob_base_component_t *) cmp->cli_component;
 114             if (c3->priority > component->priority) {
 115                 continue;
 116             }
 117             opal_output_verbose(5, orte_oob_base_framework.framework_output,
 118                                 "mca:oob:select: Inserting component");
 119             c2 = OBJ_NEW(mca_base_component_list_item_t);
 120             c2->cli_component = (mca_base_component_t*)component;
 121             opal_list_insert_pos(&orte_oob_base.actives,
 122                                  &cmp->super, &c2->super);
 123             added = true;
 124             break;
 125         }
 126         if (!added) {
 127             /* add to end */
 128             opal_output_verbose(5, orte_oob_base_framework.framework_output,
 129                                 "mca:oob:select: Adding component to end");
 130             c2 = OBJ_NEW(mca_base_component_list_item_t);
 131             c2->cli_component = (mca_base_component_t*)component;
 132             opal_list_append(&orte_oob_base.actives, &c2->super);
 133         }
 134     }
 135 
 136     if (0 == opal_list_get_size(&orte_oob_base.actives) &&
 137         !orte_standalone_operation) {
 138         /* no support available means we really cannot run unless
 139          * we are a singleton */
 140         opal_output_verbose(5, orte_oob_base_framework.framework_output,
 141                             "mca:oob:select: Init failed to return any available transports");
 142         orte_show_help("help-oob-base.txt", "no-interfaces-avail", true);
 143         return ORTE_ERR_SILENT;
 144     }
 145 
 146     /* provide them an index so we can track their usability in a bitmap */
 147     i=0;
 148     OPAL_LIST_FOREACH(cmp, &orte_oob_base.actives, mca_base_component_list_item_t) {
 149         c3 = (mca_oob_base_component_t *) cmp->cli_component;
 150         c3->idx = i++;
 151     }
 152 
 153     opal_output_verbose(5, orte_oob_base_framework.framework_output,
 154                         "mca:oob:select: Found %d active transports",
 155                         (int)opal_list_get_size(&orte_oob_base.actives));
 156     return ORTE_SUCCESS;
 157 }

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