root/orte/mca/schizo/base/schizo_base_select.c

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

DEFINITIONS

This source file includes following definitions.
  1. orte_schizo_base_select

   1 /*
   2  * Copyright (c) 2015      Intel, Inc. All rights reserved.
   3  * $COPYRIGHT$
   4  *
   5  * Additional copyrights may follow
   6  *
   7  * $HEADER$
   8  */
   9 
  10 #include "orte_config.h"
  11 #include "orte/constants.h"
  12 
  13 #include <stdio.h>
  14 #include <string.h>
  15 
  16 #include "orte/mca/mca.h"
  17 #include "opal/util/output.h"
  18 #include "opal/mca/base/base.h"
  19 
  20 #include "orte/util/show_help.h"
  21 
  22 #include "orte/runtime/orte_globals.h"
  23 #include "orte/mca/schizo/schizo.h"
  24 #include "orte/mca/schizo/base/base.h"
  25 
  26 /**
  27  * Function for selecting all runnable modules from those that are
  28  * available.
  29  */
  30 
  31 int orte_schizo_base_select(void)
  32 {
  33     mca_base_component_list_item_t *cli = NULL;
  34     mca_base_component_t *component = NULL;
  35     mca_base_module_t *module = NULL;
  36     orte_schizo_base_module_t *nmodule;
  37     orte_schizo_base_active_module_t *newmodule, *mod;
  38     int rc, priority;
  39     bool inserted;
  40 
  41     if (0 < opal_list_get_size(&orte_schizo_base.active_modules)) {
  42         /* ensure we don't do this twice */
  43         return ORTE_SUCCESS;
  44     }
  45 
  46     /* Query all available components and ask if they have a module */
  47     OPAL_LIST_FOREACH(cli, &orte_schizo_base_framework.framework_components, mca_base_component_list_item_t) {
  48         component = (mca_base_component_t *) cli->cli_component;
  49 
  50         opal_output_verbose(5, orte_schizo_base_framework.framework_output,
  51                             "mca:schizo:select: checking available component %s", component->mca_component_name);
  52 
  53         /* If there's no query function, skip it */
  54         if (NULL == component->mca_query_component) {
  55             opal_output_verbose(5, orte_schizo_base_framework.framework_output,
  56                                 "mca:schizo:select: Skipping component [%s]. It does not implement a query function",
  57                                 component->mca_component_name );
  58             continue;
  59         }
  60 
  61         /* Query the component */
  62         opal_output_verbose(5, orte_schizo_base_framework.framework_output,
  63                             "mca:schizo:select: Querying component [%s]",
  64                             component->mca_component_name);
  65         rc = component->mca_query_component(&module, &priority);
  66 
  67         /* If no module was returned, then skip component */
  68         if (ORTE_SUCCESS != rc || NULL == module) {
  69             opal_output_verbose(5, orte_schizo_base_framework.framework_output,
  70                                 "mca:schizo:select: Skipping component [%s]. Query failed to return a module",
  71                                 component->mca_component_name );
  72             continue;
  73         }
  74 
  75         /* If we got a module, keep it */
  76         nmodule = (orte_schizo_base_module_t*) module;
  77         /* add to the list of active modules */
  78         newmodule = OBJ_NEW(orte_schizo_base_active_module_t);
  79         newmodule->pri = priority;
  80         newmodule->module = nmodule;
  81         newmodule->component = component;
  82 
  83         /* maintain priority order */
  84         inserted = false;
  85         OPAL_LIST_FOREACH(mod, &orte_schizo_base.active_modules, orte_schizo_base_active_module_t) {
  86             if (priority > mod->pri) {
  87                 opal_list_insert_pos(&orte_schizo_base.active_modules,
  88                                      (opal_list_item_t*)mod, &newmodule->super);
  89                 inserted = true;
  90                 break;
  91             }
  92         }
  93         if (!inserted) {
  94             /* must be lowest priority - add to end */
  95             opal_list_append(&orte_schizo_base.active_modules, &newmodule->super);
  96         }
  97     }
  98 
  99     if (4 < opal_output_get_verbosity(orte_schizo_base_framework.framework_output)) {
 100         opal_output(0, "Final schizo priorities");
 101         /* show the prioritized list */
 102         OPAL_LIST_FOREACH(mod, &orte_schizo_base.active_modules, orte_schizo_base_active_module_t) {
 103             opal_output(0, "\tSchizo: %s Priority: %d", mod->component->mca_component_name, mod->pri);
 104         }
 105     }
 106 
 107     return ORTE_SUCCESS;;
 108 }

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