This source file includes following definitions.
- mca_pml_v_component_register
- mca_pml_v_component_open
- mca_pml_v_component_close
- mca_pml_v_component_parasite_finalize
- mca_pml_v_component_parasite_close
- mca_pml_v_component_init
- mca_pml_v_component_finalize
- mca_pml_v_enable
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 #include "ompi_config.h"
20
21 #include "opal/mca/base/base.h"
22 #include "opal/mca/base/mca_base_component_repository.h"
23 #include "opal/util/printf.h"
24 #include "opal/util/string_copy.h"
25 #include "ompi/constants.h"
26 #include "ompi/mca/pml/base/base.h"
27 #include "ompi/mca/vprotocol/vprotocol.h"
28 #include "ompi/mca/vprotocol/base/base.h"
29 #include "pml_v_output.h"
30 #include "pml_v.h"
31
32 static int mca_pml_v_component_register(void);
33 static int mca_pml_v_component_open(void);
34 static int mca_pml_v_component_close(void);
35 static int mca_pml_v_component_parasite_close(void);
36
37 static mca_pml_base_module_t *mca_pml_v_component_init(int* priority, bool enable_progress_threads, bool enable_mpi_thread_multiple);
38 static int mca_pml_v_component_finalize(void);
39 static int mca_pml_v_component_parasite_finalize(void);
40
41 static int mca_pml_v_enable(bool enable);
42
43 mca_pml_base_component_2_0_0_t mca_pml_v_component =
44 {
45
46
47 .pmlm_version = {
48 MCA_PML_BASE_VERSION_2_0_0,
49 .mca_component_name = "v",
50 MCA_BASE_MAKE_VERSION(component, OMPI_MAJOR_VERSION, OMPI_MINOR_VERSION,
51 OMPI_RELEASE_VERSION),
52 .mca_open_component = mca_pml_v_component_open,
53 .mca_close_component = mca_pml_v_component_close,
54 .mca_register_component_params = mca_pml_v_component_register,
55 },
56 .pmlm_data = {
57 MCA_BASE_METADATA_PARAM_NONE
58 },
59
60 .pmlm_init = mca_pml_v_component_init,
61 .pmlm_finalize = mca_pml_v_component_finalize,
62 };
63
64 static bool pml_v_enable_progress_treads = OPAL_ENABLE_PROGRESS_THREADS;
65 static bool pml_v_enable_mpi_thread_multiple = 1;
66
67 static char *ompi_pml_vprotocol_include_list;
68 static char *ompi_pml_v_output;
69 static int ompi_pml_v_verbose;
70
71
72
73
74 static int mca_pml_v_component_register(void)
75 {
76 int var_id;
77
78 ompi_pml_v_output = "stderr";
79 (void) mca_base_component_var_register(&mca_pml_v_component.pmlm_version,
80 "output", NULL, MCA_BASE_VAR_TYPE_STRING,
81 NULL, 0, 0, OPAL_INFO_LVL_9,
82 MCA_BASE_VAR_SCOPE_READONLY,
83 &ompi_pml_v_output);
84
85 ompi_pml_v_verbose = 0;
86 (void) mca_base_component_var_register(&mca_pml_v_component.pmlm_version,
87 "verbose", "Verbosity of the pml v component",
88 MCA_BASE_VAR_TYPE_INT, NULL, 0, 0,
89 OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_READONLY,
90 &ompi_pml_v_verbose);
91
92 ompi_pml_vprotocol_include_list = "";
93
94 var_id = mca_base_component_var_register(&mca_pml_v_component.pmlm_version,
95 "vprotocol", "Specify a specific vprotocol to use",
96 MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0,
97 OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_READONLY,
98 &ompi_pml_vprotocol_include_list);
99 (void) mca_base_var_register_synonym(var_id, "ompi", "vprotocol", NULL, NULL, 0);
100
101 return OMPI_SUCCESS;
102 }
103
104 static int mca_pml_v_component_open(void)
105 {
106 int rc;
107 ompi_pml_v_output_open(ompi_pml_v_output, ompi_pml_v_verbose);
108
109 V_OUTPUT_VERBOSE(500, "loaded");
110
111 mca_vprotocol_base_set_include_list(ompi_pml_vprotocol_include_list);
112
113 if (OMPI_SUCCESS != (rc = mca_base_framework_open(&ompi_vprotocol_base_framework, 0))) {
114 return rc;
115 }
116
117 if( NULL == mca_vprotocol_base_include_list ) {
118 ompi_pml_v_output_close();
119 return mca_base_framework_close(&ompi_vprotocol_base_framework);
120 }
121
122 return rc;
123 }
124
125 static int mca_pml_v_component_close(void)
126 {
127 if( NULL == mca_vprotocol_base_include_list ) {
128
129 return OMPI_SUCCESS;
130 }
131
132
133 mca_pml_v.host_pml_component = mca_pml_base_selected_component;
134 mca_pml_v.host_pml = mca_pml;
135 mca_pml_v.host_request_fns = ompi_request_functions;
136
137
138 if (NULL != mca_vprotocol_base_include_list && !mca_vprotocol_base_include_list[0]) {
139 return mca_pml_v_component_parasite_close();
140 }
141
142
143 ompi_pml_v_output_close ();
144
145
146 char *new_name;
147 opal_asprintf(&new_name, "%s]v%s",
148 mca_pml_v.host_pml_component.pmlm_version.mca_component_name,
149 mca_vprotocol_component.pmlm_version.mca_component_name);
150 opal_string_copy(mca_pml_base_selected_component.pmlm_version.mca_component_name,
151 new_name,
152 sizeof(mca_pml_base_selected_component.pmlm_version.mca_component_name));
153 free(new_name);
154
155
156 mca_pml_base_selected_component.pmlm_finalize =
157 mca_pml_v_component_parasite_finalize;
158
159
160 mca_pml.pml_enable = mca_pml_v_enable;
161
162 return OMPI_SUCCESS;
163 }
164
165
166
167
168 static int mca_pml_v_component_parasite_finalize(void)
169 {
170 mca_base_component_list_item_t *cli = NULL;
171
172 V_OUTPUT_VERBOSE(500, "parasite_finalize");
173
174
175 mca_pml_v_component.pmlm_version.mca_close_component =
176 mca_pml_v_component_parasite_close;
177 cli = OBJ_NEW(mca_base_component_list_item_t);
178 cli->cli_component = (mca_base_component_t *) &mca_pml_v_component;
179 opal_list_prepend(&ompi_pml_base_framework.framework_components,
180 (opal_list_item_t *) cli);
181
182
183 if(mca_vprotocol_base_selected())
184 mca_vprotocol_component.pmlm_finalize();
185
186 if(mca_pml_v.host_pml_component.pmlm_finalize != NULL)
187 return mca_pml_v.host_pml_component.pmlm_finalize();
188 else
189 return OMPI_SUCCESS;
190 }
191
192 static int mca_pml_v_component_parasite_close(void)
193 {
194 V_OUTPUT_VERBOSE(500, "parasite_close: Ok, I accept to die and let %s component finish",
195 mca_pml_v.host_pml_component.pmlm_version.mca_component_name);
196 mca_pml_base_selected_component = mca_pml_v.host_pml_component;
197
198 (void) mca_base_framework_close(&ompi_vprotocol_base_framework);
199 ompi_pml_v_output_close();
200
201 mca_pml.pml_enable = mca_pml_v.host_pml.pml_enable;
202
203 return OMPI_SUCCESS;
204 }
205
206
207
208
209
210 static mca_pml_base_module_t *mca_pml_v_component_init(int *priority,
211 bool enable_progress_threads,
212 bool enable_mpi_thread_multiple)
213 {
214 V_OUTPUT_VERBOSE(1, "init: I'm not supposed to be here until BTL loading stuff gets fixed!? That's strange...");
215
216 pml_v_enable_progress_treads = enable_progress_threads;
217 pml_v_enable_mpi_thread_multiple = enable_mpi_thread_multiple;
218
219
220
221
222 *priority = -1;
223 return NULL;
224 }
225
226 static int mca_pml_v_component_finalize(void)
227 {
228 V_OUTPUT_VERBOSE(1, "finalize: I'm not supposed to be here until BTL loading stuff gets fixed!? That's strange...");
229
230
231
232 return OMPI_SUCCESS;
233 }
234
235
236
237
238
239 static int mca_pml_v_enable(bool enable)
240 {
241 int ret;
242
243
244
245
246 ret = mca_pml_v.host_pml.pml_enable(enable);
247 if(OMPI_SUCCESS != ret) return ret;
248
249 if(enable) {
250
251 if(! mca_vprotocol_base_selected())
252 mca_vprotocol_base_select(pml_v_enable_progress_treads,
253 pml_v_enable_mpi_thread_multiple);
254
255
256 if(mca_vprotocol_base_selected()) {
257 V_OUTPUT_VERBOSE(1, "I don't want to die: I will parasite %s host component %s with %s %s",
258 mca_pml_base_selected_component.pmlm_version.mca_type_name,
259 mca_pml_base_selected_component.pmlm_version.mca_component_name,
260 mca_vprotocol_component.pmlm_version.mca_type_name,
261 mca_vprotocol_component.pmlm_version.mca_component_name);
262
263 ret = mca_vprotocol_base_parasite();
264 if(OMPI_SUCCESS != ret) return ret;
265 if(mca_vprotocol.enable)
266 return mca_vprotocol.enable(enable);
267 else
268 return OMPI_SUCCESS;
269 }
270 V_OUTPUT_VERBOSE(1, "No fault tolerant protocol selected. All are unloaded");
271 }
272
273 mca_pml = mca_pml_v.host_pml;
274 mca_pml.pml_enable = mca_pml_v_enable;
275
276 ompi_request_functions = mca_pml_v.host_request_fns;
277 return OMPI_SUCCESS;
278 }