This source file includes following definitions.
- mca_base_select
   1 
   2 
   3 
   4 
   5 
   6 
   7 
   8 
   9 
  10 
  11 
  12 
  13 
  14 
  15 
  16 #include "opal_config.h"
  17 
  18 #include <stdio.h>
  19 #include <string.h>
  20 #include <stdlib.h>
  21 #ifdef HAVE_SYS_TYPES_H
  22 #include <sys/types.h>
  23 #endif
  24 
  25 #include "opal/runtime/opal.h"
  26 #include "opal/class/opal_list.h"
  27 #include "opal/util/output.h"
  28 #include "opal/mca/mca.h"
  29 #include "opal/mca/base/base.h"
  30 #include "opal/mca/base/mca_base_component_repository.h"
  31 #include "opal/constants.h"
  32 
  33 
  34 int mca_base_select(const char *type_name, int output_id,
  35                     opal_list_t *components_available,
  36                     mca_base_module_t **best_module,
  37                     mca_base_component_t **best_component,
  38                     int *priority_out)
  39 {
  40     mca_base_component_list_item_t *cli = NULL;
  41     mca_base_component_t *component = NULL;
  42     mca_base_module_t *module = NULL;
  43     int priority = 0, best_priority = INT32_MIN;
  44     int rc;
  45 
  46     *best_module = NULL;
  47     *best_component = NULL;
  48 
  49     opal_output_verbose (MCA_BASE_VERBOSE_COMPONENT, output_id,
  50                          "mca:base:select: Auto-selecting %s components",
  51                          type_name);
  52 
  53     
  54 
  55 
  56 
  57     OPAL_LIST_FOREACH(cli, components_available, mca_base_component_list_item_t) {
  58         component = (mca_base_component_t *) cli->cli_component;
  59 
  60         
  61 
  62 
  63         if (NULL == component->mca_query_component) {
  64             opal_output_verbose (MCA_BASE_VERBOSE_COMPONENT, output_id,
  65                                  "mca:base:select:(%5s) Skipping component [%s]. It does not implement a query function",
  66                                  type_name, component->mca_component_name );
  67             continue;
  68         }
  69 
  70         
  71 
  72 
  73         opal_output_verbose (MCA_BASE_VERBOSE_COMPONENT, output_id,
  74                              "mca:base:select:(%5s) Querying component [%s]",
  75                              type_name, component->mca_component_name);
  76 
  77         rc = component->mca_query_component(&module, &priority);
  78         if (OPAL_ERR_FATAL == rc) {
  79             
  80 
  81 
  82 
  83 
  84              return rc;
  85         } else if (OPAL_SUCCESS != rc) {
  86             
  87             continue;
  88         }
  89 
  90         
  91 
  92 
  93         if (NULL == module) {
  94             opal_output_verbose (MCA_BASE_VERBOSE_COMPONENT, output_id,
  95                                  "mca:base:select:(%5s) Skipping component [%s]. Query failed to return a module",
  96                                  type_name, component->mca_component_name );
  97             continue;
  98         }
  99 
 100         
 101 
 102 
 103         opal_output_verbose (MCA_BASE_VERBOSE_COMPONENT, output_id,
 104                              "mca:base:select:(%5s) Query of component [%s] set priority to %d",
 105                              type_name, component->mca_component_name, priority);
 106         if (priority > best_priority) {
 107             best_priority  = priority;
 108             *best_component = component;
 109             *best_module    = module;
 110         }
 111     }
 112 
 113     if (priority_out) {
 114         *priority_out = best_priority;
 115     }
 116 
 117     
 118 
 119 
 120 
 121     if (NULL == *best_component) {
 122         opal_output_verbose (MCA_BASE_VERBOSE_COMPONENT, output_id,
 123                             "mca:base:select:(%5s) No component selected!",
 124                             type_name);
 125         
 126 
 127 
 128         mca_base_components_close(0, 
 129                                   components_available,
 130                                   NULL);
 131         return OPAL_ERR_NOT_FOUND;
 132     }
 133 
 134     opal_output_verbose (MCA_BASE_VERBOSE_COMPONENT, output_id,
 135                          "mca:base:select:(%5s) Selected component [%s]",
 136                          type_name, (*best_component)->mca_component_name);
 137 
 138     
 139 
 140 
 141     mca_base_components_close(output_id,
 142                               components_available,
 143                               (mca_base_component_t *) (*best_component));
 144 
 145 
 146     return OPAL_SUCCESS;
 147 }