This source file includes following definitions.
- mca_vprotocol_base_select
1
2
3
4
5
6
7
8
9
10
11
12
13
14 #include "ompi_config.h"
15
16 #include <string.h>
17
18 #include "base.h"
19 #include "ompi/mca/mca.h"
20 #include "opal/mca/base/base.h"
21 #include "ompi/mca/pml/v/pml_v_output.h"
22
23 mca_vprotocol_base_module_t mca_vprotocol = {0};
24 mca_vprotocol_base_component_t mca_vprotocol_component = {
25 {MCA_VPROTOCOL_BASE_VERSION_0_0_0}
26 };
27
28 typedef struct opened_component_t {
29 opal_list_item_t super;
30 mca_vprotocol_base_component_t *om_component;
31 } opened_component_t;
32
33
34
35
36
37
38
39
40
41
42
43
44 int mca_vprotocol_base_select(bool enable_progress_threads,
45 bool enable_mpi_threads)
46 {
47 int priority = 0, best_priority = -1;
48 opal_list_item_t *item = NULL;
49 mca_base_component_list_item_t *cli = NULL;
50 mca_vprotocol_base_component_t *component = NULL, *best_component = NULL;
51 mca_vprotocol_base_module_t *module = NULL, *best_module = NULL;
52 opal_list_t opened;
53 opened_component_t *om = NULL;
54
55
56
57 OBJ_CONSTRUCT(&opened, opal_list_t);
58 OPAL_LIST_FOREACH(cli, &ompi_vprotocol_base_framework.framework_components, mca_base_component_list_item_t)
59 {
60 component = (mca_vprotocol_base_component_t *) cli->cli_component;
61
62 if (NULL == mca_vprotocol_base_include_list) {
63 continue;
64 }
65
66 V_OUTPUT_VERBOSE(500, "vprotocol select: initializing %s component %s", component->pmlm_version.mca_type_name, component->pmlm_version.mca_component_name);
67 if(strcmp(component->pmlm_version.mca_component_name,
68 mca_vprotocol_base_include_list)) {
69 V_OUTPUT_VERBOSE(500, "This component is not in the include list: skipping %s", component->pmlm_version.mca_component_name);
70 continue;
71 }
72 if(NULL == component->pmlm_init) {
73 V_OUTPUT_VERBOSE(2, "vprotocol select: no init function; ignoring component %s", component->pmlm_version.mca_component_name);
74 continue;
75 }
76 module = component->pmlm_init(&priority, enable_progress_threads, enable_mpi_threads);
77 if (NULL == module) {
78 V_OUTPUT_VERBOSE(2, "vprotocol select: init returned failure for component %s", component->pmlm_version.mca_component_name);
79 continue;
80 }
81 V_OUTPUT_VERBOSE(500, "vprotocol select: component %s init returned priority %d", component->pmlm_version.mca_component_name, priority);
82 if (priority > best_priority)
83 {
84 best_priority = priority;
85 best_component = component;
86 best_module = module;
87 }
88
89 om = (opened_component_t *) malloc(sizeof(opened_component_t));
90 if (NULL == om) return OMPI_ERR_OUT_OF_RESOURCE;
91 OBJ_CONSTRUCT(om, opal_list_item_t);
92 om->om_component = component;
93 opal_list_append(&opened, (opal_list_item_t*) om);
94 }
95
96
97 if (NULL == best_component) {
98 V_OUTPUT_VERBOSE(2, "vprotocol select: no protocol has returned a positive priority, fault tolerance is OFF");
99 }
100 else
101 {
102
103 mca_vprotocol_component = *best_component;
104 mca_vprotocol = *best_module;
105 }
106
107
108 for (item = opal_list_remove_first(&opened);
109 NULL != item;
110 item = opal_list_remove_first(&opened))
111 {
112 om = (opened_component_t *) item;
113 if (om->om_component != best_component) {
114
115 V_OUTPUT_VERBOSE(500, "vprotocol select: component %s not selected / finalized", om->om_component->pmlm_version.mca_component_name);
116 if (NULL != om->om_component->pmlm_finalize) {
117
118
119
120 om->om_component->pmlm_finalize();
121 }
122 }
123 OBJ_DESTRUCT(om);
124 free(om);
125 }
126
127 mca_base_components_close(mca_pml_v.output,
128 &ompi_vprotocol_base_framework.framework_components,
129 (mca_base_component_t *) best_component);
130
131
132 if(best_component != NULL)
133 {
134 V_OUTPUT_VERBOSE(500, "vprotocol select: component %s selected", mca_vprotocol_component.pmlm_version.mca_component_name);
135 return OMPI_SUCCESS;
136 }
137 else
138 return OMPI_ERR_NOT_FOUND;
139 }