This source file includes following definitions.
- _notification_eviction_cbfunc
- pmix_rte_init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 #include <src/include/pmix_config.h>
31
32 #ifdef HAVE_UNISTD_H
33 #include <unistd.h>
34 #endif
35
36 #include <pmix_rename.h>
37
38 #include "src/include/pmix_globals.h"
39 #include "src/util/output.h"
40 #include "src/util/show_help.h"
41 #include "src/mca/base/base.h"
42 #include "src/mca/base/pmix_mca_base_var.h"
43 #include "src/mca/bfrops/base/base.h"
44 #include "src/mca/pcompress/base/base.h"
45 #include "src/mca/gds/base/base.h"
46 #include "src/mca/pif/base/base.h"
47 #include "src/mca/pinstalldirs/base/base.h"
48 #include "src/mca/plog/base/base.h"
49 #include "src/mca/pnet/base/base.h"
50 #include "src/mca/psec/base/base.h"
51 #include "src/mca/preg/base/base.h"
52 #include "src/mca/ptl/base/base.h"
53
54 #include "src/client/pmix_client_ops.h"
55 #include "src/common/pmix_attributes.h"
56 #include "src/event/pmix_event.h"
57 #include "src/include/types.h"
58 #include "src/util/error.h"
59 #include "src/util/keyval_parse.h"
60
61 #include "src/runtime/pmix_rte.h"
62 #include "src/runtime/pmix_progress_threads.h"
63
64 const char pmix_version_string[] = PMIX_IDENT_STRING;
65
66 PMIX_EXPORT int pmix_initialized = 0;
67 PMIX_EXPORT bool pmix_init_called = false;
68
69
70
71
72
73
74 PMIX_EXPORT pmix_globals_t pmix_globals = {
75 .init_cntr = 0,
76 .mypeer = NULL,
77 .hostname = NULL,
78 .nodeid = UINT32_MAX,
79 .pindex = 0,
80 .evbase = NULL,
81 .external_evbase = false,
82 .debug_output = -1,
83 .connected = false,
84 .commits_pending = false,
85 .mygds = NULL,
86 .pushstdin = false
87 };
88
89
90 static void _notification_eviction_cbfunc(struct pmix_hotel_t *hotel,
91 int room_num,
92 void *occupant)
93 {
94 pmix_notify_caddy_t *cache = (pmix_notify_caddy_t*)occupant;
95 PMIX_RELEASE(cache);
96 }
97
98
99 int pmix_rte_init(pmix_proc_type_t type,
100 pmix_info_t info[], size_t ninfo,
101 pmix_ptl_cbfunc_t cbfunc)
102 {
103 int ret, debug_level;
104 char *error = NULL, *evar;
105 size_t n;
106 char hostname[PMIX_MAXHOSTNAMELEN];
107
108 if( ++pmix_initialized != 1 ) {
109 if( pmix_initialized < 1 ) {
110 return PMIX_ERROR;
111 }
112 return PMIX_SUCCESS;
113 }
114
115 #if PMIX_NO_LIB_DESTRUCTOR
116 if (pmix_init_called) {
117
118 fprintf (stderr, "pmix_init: attempted to initialize after finalize without compiler "
119 "support for either __attribute__(destructor) or linker support for -fini -- process "
120 "will likely abort\n");
121 return PMIX_ERR_NOT_SUPPORTED;
122 }
123 #endif
124
125 pmix_init_called = true;
126
127
128 if (!pmix_output_init()) {
129 return PMIX_ERROR;
130 }
131
132
133 if (PMIX_SUCCESS != (ret = pmix_mca_base_framework_open(&pmix_pinstalldirs_base_framework, 0))) {
134 fprintf(stderr, "pmix_pinstalldirs_base_open() failed -- process will likely abort (%s:%d, returned %d instead of PMIX_SUCCESS)\n",
135 __FILE__, __LINE__, ret);
136 return ret;
137 }
138
139
140 pmix_show_help_init();
141
142
143 if (PMIX_SUCCESS != (ret = pmix_util_keyval_parse_init())) {
144 error = "pmix_util_keyval_parse_init";
145 goto return_error;
146 }
147
148
149 if (PMIX_SUCCESS != (ret = pmix_mca_base_var_init())) {
150 error = "mca_base_var_init";
151 goto return_error;
152 }
153
154
155 if (PMIX_SUCCESS != (ret = pmix_register_params())) {
156 error = "pmix_register_params";
157 goto return_error;
158 }
159
160
161 if (PMIX_SUCCESS != (ret = pmix_mca_base_open())) {
162 error = "mca_base_open";
163 goto return_error;
164 }
165
166
167 gethostname(hostname, PMIX_MAXHOSTNAMELEN);
168 pmix_globals.hostname = strdup(hostname);
169 memset(&pmix_globals.myid.nspace, 0, PMIX_MAX_NSLEN+1);
170 pmix_globals.myid.rank = PMIX_RANK_INVALID;
171 PMIX_CONSTRUCT(&pmix_globals.events, pmix_events_t);
172 pmix_globals.event_window.tv_sec = pmix_event_caching_window;
173 pmix_globals.event_window.tv_usec = 0;
174 PMIX_CONSTRUCT(&pmix_globals.cached_events, pmix_list_t);
175
176 PMIX_CONSTRUCT(&pmix_globals.notifications, pmix_hotel_t);
177 ret = pmix_hotel_init(&pmix_globals.notifications, pmix_globals.max_events,
178 pmix_globals.evbase, pmix_globals.event_eviction_time,
179 _notification_eviction_cbfunc);
180 if (PMIX_SUCCESS != ret) {
181 error = "notification hotel init";
182 goto return_error;
183 }
184
185 PMIX_CONSTRUCT(&pmix_globals.iof_requests, pmix_list_t);
186
187 PMIX_CONSTRUCT(&pmix_globals.stdin_targets, pmix_list_t);
188
189
190
191 if (0 < pmix_client_globals.get_verbose) {
192
193 pmix_client_globals.get_output = pmix_output_open(NULL);
194 pmix_output_set_verbosity(pmix_client_globals.get_output,
195 pmix_client_globals.get_verbose);
196 }
197 if (0 < pmix_client_globals.connect_verbose) {
198
199 pmix_client_globals.connect_output = pmix_output_open(NULL);
200 pmix_output_set_verbosity(pmix_client_globals.connect_output,
201 pmix_client_globals.connect_verbose);
202 }
203 if (0 < pmix_client_globals.fence_verbose) {
204
205 pmix_client_globals.fence_output = pmix_output_open(NULL);
206 pmix_output_set_verbosity(pmix_client_globals.fence_output,
207 pmix_client_globals.fence_verbose);
208 }
209 if (0 < pmix_client_globals.pub_verbose) {
210
211 pmix_client_globals.pub_output = pmix_output_open(NULL);
212 pmix_output_set_verbosity(pmix_client_globals.pub_output,
213 pmix_client_globals.pub_verbose);
214 }
215 if (0 < pmix_client_globals.spawn_verbose) {
216
217 pmix_client_globals.spawn_output = pmix_output_open(NULL);
218 pmix_output_set_verbosity(pmix_client_globals.spawn_output,
219 pmix_client_globals.spawn_verbose);
220 }
221 if (0 < pmix_client_globals.event_verbose) {
222
223 pmix_client_globals.event_output = pmix_output_open(NULL);
224 pmix_output_set_verbosity(pmix_client_globals.event_output,
225 pmix_client_globals.event_verbose);
226 }
227 if (0 < pmix_client_globals.iof_verbose) {
228
229 pmix_client_globals.iof_output = pmix_output_open(NULL);
230 pmix_output_set_verbosity(pmix_client_globals.iof_output,
231 pmix_client_globals.iof_verbose);
232 }
233
234
235 pmix_globals.uid = geteuid();
236 pmix_globals.gid = getegid();
237
238 if (NULL != (evar = getenv("PMIX_DEBUG"))) {
239 debug_level = strtol(evar, NULL, 10);
240 pmix_globals.debug_output = pmix_output_open(NULL);
241 pmix_output_set_verbosity(pmix_globals.debug_output, debug_level);
242 }
243
244 pmix_globals.mypeer = PMIX_NEW(pmix_peer_t);
245 if (NULL == pmix_globals.mypeer) {
246 ret = PMIX_ERR_NOMEM;
247 goto return_error;
248 }
249
250 pmix_globals.mypeer->proc_type = type | PMIX_PROC_V3;
251
252
253 pmix_globals.mypeer->nptr = PMIX_NEW(pmix_namespace_t);
254 if (NULL == pmix_globals.mypeer->nptr) {
255 PMIX_RELEASE(pmix_globals.mypeer);
256 ret = PMIX_ERR_NOMEM;
257 goto return_error;
258 }
259
260
261 if (NULL != info) {
262 for (n=0; n < ninfo; n++) {
263 if (PMIX_CHECK_KEY(&info[n], PMIX_EVENT_BASE)) {
264 pmix_globals.evbase = (pmix_event_base_t*)info[n].value.data.ptr;
265 pmix_globals.external_evbase = true;
266 } else if (PMIX_CHECK_KEY(&info[n], PMIX_HOSTNAME)) {
267 if (NULL != pmix_globals.hostname) {
268 free(pmix_globals.hostname);
269 }
270 pmix_globals.hostname = strdup(info[n].value.data.string);
271 } else if (PMIX_CHECK_KEY(&info[n], PMIX_NODEID)) {
272 PMIX_VALUE_GET_NUMBER(ret, &info[n].value, pmix_globals.nodeid, uint32_t);
273 if (PMIX_SUCCESS != ret) {
274 goto return_error;
275 }
276 }
277 }
278 }
279
280
281
282
283
284
285 if (PMIX_SUCCESS != (ret = pmix_mca_base_framework_open(&pmix_bfrops_base_framework, 0)) ) {
286 error = "pmix_bfrops_base_open";
287 goto return_error;
288 }
289 if (PMIX_SUCCESS != (ret = pmix_bfrop_base_select()) ) {
290 error = "pmix_bfrops_base_select";
291 goto return_error;
292 }
293
294
295 if (PMIX_SUCCESS != (ret = pmix_mca_base_framework_open(&pmix_pcompress_base_framework, 0)) ) {
296 error = "pmix_pcompress_base_open";
297 goto return_error;
298 }
299 if (PMIX_SUCCESS != (ret = pmix_compress_base_select()) ) {
300 error = "pmix_pcompress_base_select";
301 goto return_error;
302 }
303
304
305 if (PMIX_SUCCESS != (ret = pmix_mca_base_framework_open(&pmix_ptl_base_framework, 0)) ) {
306 error = "pmix_ptl_base_open";
307 goto return_error;
308 }
309 if (PMIX_SUCCESS != (ret = pmix_ptl_base_select()) ) {
310 error = "pmix_ptl_base_select";
311 goto return_error;
312 }
313
314 if (PMIX_SUCCESS != (ret = pmix_ptl_base_set_notification_cbfunc(cbfunc))) {
315 error = "pmix_ptl_set_notification_cbfunc";
316 goto return_error;
317 }
318
319
320 if (PMIX_SUCCESS != (ret = pmix_mca_base_framework_open(&pmix_psec_base_framework, 0))) {
321 error = "pmix_psec_base_open";
322 goto return_error;
323 }
324 if (PMIX_SUCCESS != (ret = pmix_psec_base_select())) {
325 error = "pmix_psec_base_select";
326 goto return_error;
327 }
328
329
330 if (PMIX_SUCCESS != (ret = pmix_mca_base_framework_open(&pmix_gds_base_framework, 0)) ) {
331 error = "pmix_gds_base_open";
332 goto return_error;
333 }
334 if (PMIX_SUCCESS != (ret = pmix_gds_base_select(info, ninfo)) ) {
335 error = "pmix_gds_base_select";
336 goto return_error;
337 }
338
339
340 if (PMIX_SUCCESS != (ret = pmix_mca_base_framework_open(&pmix_pif_base_framework, 0))) {
341 error = "pmix_pif_base_open";
342 return ret;
343 }
344
345
346 if (PMIX_SUCCESS != (ret = pmix_mca_base_framework_open(&pmix_preg_base_framework, 0)) ) {
347 error = "pmix_preg_base_open";
348 goto return_error;
349 }
350 if (PMIX_SUCCESS != (ret = pmix_preg_base_select()) ) {
351 error = "pmix_preg_base_select";
352 goto return_error;
353 }
354
355
356 if (PMIX_SUCCESS != (ret = pmix_mca_base_framework_open(&pmix_plog_base_framework, 0)) ) {
357 error = "pmix_plog_base_open";
358 goto return_error;
359 }
360 if (PMIX_SUCCESS != (ret = pmix_plog_base_select()) ) {
361 error = "pmix_plog_base_select";
362 goto return_error;
363 }
364
365
366 pmix_init_registered_attrs();
367
368
369 if (!pmix_globals.external_evbase) {
370
371 pmix_event_use_threads();
372
373
374 if (NULL == (pmix_globals.evbase = pmix_progress_thread_init(NULL))) {
375 error = "progress thread";
376 ret = PMIX_ERROR;
377 goto return_error;
378 }
379 }
380
381 return PMIX_SUCCESS;
382
383 return_error:
384 if (PMIX_ERR_SILENT != ret) {
385 pmix_show_help( "help-pmix-runtime.txt",
386 "pmix_init:startup:internal-failure", true,
387 error, ret );
388 }
389 return ret;
390 }