This source file includes following definitions.
- pmix_mca_base_select
   1 
   2 
   3 
   4 
   5 
   6 
   7 
   8 
   9 
  10 
  11 
  12 
  13 
  14 
  15 
  16 #include <src/include/pmix_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 "src/class/pmix_list.h"
  26 #include "src/util/error.h"
  27 #include "src/util/output.h"
  28 #include "src/mca/mca.h"
  29 #include "src/mca/base/base.h"
  30 #include "src/mca/base/pmix_mca_base_component_repository.h"
  31 #include "pmix_common.h"
  32 
  33 
  34 int pmix_mca_base_select(const char *type_name, int output_id,
  35                          pmix_list_t *components_available,
  36                          pmix_mca_base_module_t **best_module,
  37                          pmix_mca_base_component_t **best_component,
  38                          int *priority_out)
  39 {
  40     pmix_mca_base_component_list_item_t *cli = NULL;
  41     pmix_mca_base_component_t *component = NULL;
  42     pmix_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     pmix_output_verbose (PMIX_MCA_BASE_VERBOSE_COMPONENT, output_id,
  50                          "mca:base:select: Auto-selecting %s components",
  51                          type_name);
  52 
  53     
  54 
  55 
  56 
  57     PMIX_LIST_FOREACH(cli, components_available, pmix_mca_base_component_list_item_t) {
  58         component = (pmix_mca_base_component_t *) cli->cli_component;
  59 
  60         
  61 
  62 
  63         if (NULL == component->pmix_mca_query_component) {
  64             pmix_output_verbose (PMIX_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->pmix_mca_component_name );
  67             continue;
  68         }
  69 
  70         
  71 
  72 
  73         pmix_output_verbose (PMIX_MCA_BASE_VERBOSE_COMPONENT, output_id,
  74                              "mca:base:select:(%5s) Querying component [%s]",
  75                              type_name, component->pmix_mca_component_name);
  76 
  77         rc = component->pmix_mca_query_component(&module, &priority);
  78         if (PMIX_ERR_FATAL == rc) {
  79             
  80 
  81 
  82 
  83 
  84              return rc;
  85         } else if (PMIX_SUCCESS != rc) {
  86             
  87             continue;
  88         }
  89 
  90         
  91 
  92 
  93         if (NULL == module) {
  94             pmix_output_verbose (PMIX_MCA_BASE_VERBOSE_COMPONENT, output_id,
  95                                  "mca:base:select:(%5s) Skipping component [%s]. Query failed to return a module",
  96                                  type_name, component->pmix_mca_component_name );
  97             continue;
  98         }
  99 
 100         
 101 
 102 
 103         pmix_output_verbose (PMIX_MCA_BASE_VERBOSE_COMPONENT, output_id,
 104                              "mca:base:select:(%5s) Query of component [%s] set priority to %d",
 105                              type_name, component->pmix_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         pmix_output_verbose (PMIX_MCA_BASE_VERBOSE_COMPONENT, output_id,
 123                             "mca:base:select:(%5s) No component selected!",
 124                             type_name);
 125         
 126 
 127 
 128         pmix_mca_base_components_close(0, 
 129                                   components_available,
 130                                   NULL);
 131         return PMIX_ERR_NOT_FOUND;
 132     }
 133 
 134     pmix_output_verbose (PMIX_MCA_BASE_VERBOSE_COMPONENT, output_id,
 135                          "mca:base:select:(%5s) Selected component [%s]",
 136                          type_name, (*best_component)->pmix_mca_component_name);
 137 
 138     
 139 
 140 
 141     pmix_mca_base_components_close(output_id,
 142                                    components_available,
 143                                    (pmix_mca_base_component_t *) (*best_component));
 144 
 145 
 146     return PMIX_SUCCESS;
 147 }