This source file includes following definitions.
- mca_sharedfp_base_file_select
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 #include "ompi_config.h"
24
25 #include <string.h>
26
27 #include "opal/class/opal_list.h"
28 #include "opal/util/argv.h"
29 #include "ompi/mca/mca.h"
30 #include "opal/mca/base/base.h"
31 #include "ompi/mca/sharedfp/sharedfp.h"
32 #include "ompi/mca/sharedfp/base/base.h"
33 #include "ompi/mca/common/ompio/common_ompio.h"
34
35
36
37
38
39
40
41 struct queried_module_t {
42 opal_list_item_t super;
43 mca_sharedfp_base_component_t *om_component;
44 mca_sharedfp_base_module_t *om_module;
45 };
46 typedef struct queried_module_t queried_module_t;
47 static OBJ_CLASS_INSTANCE(queried_module_t, opal_list_item_t, NULL, NULL);
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68 int mca_sharedfp_base_file_select (struct ompio_file_t *file,
69 mca_base_component_t *preferred)
70 {
71 int priority;
72 int best_priority;
73 opal_list_item_t *item;
74 mca_base_component_list_item_t *cli;
75 mca_sharedfp_base_component_t *component;
76 mca_sharedfp_base_component_t *best_component;
77 mca_sharedfp_base_module_t *module;
78 opal_list_t queried;
79 queried_module_t *om;
80 char *str;
81 int err = MPI_SUCCESS;
82
83
84
85
86 if (NULL != preferred) {
87
88
89
90
91 str = &(preferred->mca_component_name[0]);
92
93 opal_output_verbose(10, ompi_sharedfp_base_framework.framework_output,
94 "sharedfp:base:file_select: Checking preferred component: %s",
95 str);
96
97
98
99
100 component = (mca_sharedfp_base_component_t *)preferred;
101 module = component->sharedfpm_file_query (file, &priority);
102 if (NULL != module &&
103 NULL != module->sharedfp_module_init) {
104
105
106
107
108
109
110
111 file->f_sharedfp = module;
112 file->f_sharedfp_component = preferred;
113
114 return module->sharedfp_module_init(file);
115 }
116
117
118
119
120
121 }
122
123
124
125
126
127
128
129
130
131
132
133
134 best_component = NULL;
135 best_priority = -1;
136 OBJ_CONSTRUCT(&queried, opal_list_t);
137
138 OPAL_LIST_FOREACH(cli, &ompi_sharedfp_base_framework.framework_components, mca_base_component_list_item_t) {
139 component = (mca_sharedfp_base_component_t *) cli->cli_component;
140 opal_output_verbose(10, ompi_sharedfp_base_framework.framework_output,
141 "select: initialising %s component %s",
142 component->sharedfpm_version.mca_type_name,
143 component->sharedfpm_version.mca_component_name);
144
145
146
147
148 if (NULL == component->sharedfpm_file_query) {
149 opal_output_verbose(10, ompi_sharedfp_base_framework.framework_output,
150 "select: no query, ignoring the component");
151 } else {
152
153
154
155 module = component->sharedfpm_file_query (file, &priority);
156
157 if (NULL == module ||
158 NULL == module->sharedfp_module_init) {
159
160
161
162 opal_output_verbose(10, ompi_sharedfp_base_framework.framework_output,
163 "select: query returned failure");
164 } else {
165 opal_output_verbose(10, ompi_sharedfp_base_framework.framework_output,
166 "select: query returned priority %d",
167 priority);
168
169
170
171 if (priority > best_priority) {
172 best_priority = priority;
173 best_component = component;
174 }
175
176 om = OBJ_NEW(queried_module_t);
177
178
179
180 if (NULL == om) {
181 OBJ_DESTRUCT(&queried);
182 return OMPI_ERR_OUT_OF_RESOURCE;
183 }
184 om->om_component = component;
185 om->om_module = module;
186 opal_list_append(&queried, (opal_list_item_t *)om);
187 }
188 }
189 }
190
191
192
193
194
195
196
197
198 if (NULL == best_component) {
199
200
201
202
203 OBJ_DESTRUCT(&queried);
204 return OMPI_ERROR;
205 }
206
207
208
209
210
211
212
213 for (item = opal_list_remove_first(&queried);
214 NULL != item;
215 item = opal_list_remove_first(&queried)) {
216 om = (queried_module_t *) item;
217 if (om->om_component == best_component) {
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234 file->f_sharedfp = om->om_module;
235 err = om->om_module->sharedfp_module_init(file);
236 file->f_sharedfp_component = (mca_base_component_t *)best_component;
237
238 } else {
239
240
241
242 if (NULL != om->om_component->sharedfpm_file_unquery) {
243
244
245
246
247
248 (void) om->om_component->sharedfpm_file_unquery(file);
249 opal_output_verbose(10, ompi_sharedfp_base_framework.framework_output,
250 "select: component %s is not selected",
251 om->om_component->sharedfpm_version.mca_component_name);
252 }
253 }
254 OBJ_RELEASE(om);
255 }
256
257 opal_output_verbose(10, ompi_sharedfp_base_framework.framework_output,
258 "select: component %s selected",
259 best_component->sharedfpm_version.mca_component_name);
260
261 OBJ_DESTRUCT(&queried);
262
263 return err;
264 }