root/orte/mca/rmaps/base/rmaps_base_select.c

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

DEFINITIONS

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

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