This source file includes following definitions.
- orte_dt_quick_print
- orte_dt_std_print
- orte_dt_print_job
- orte_dt_print_node
- orte_dt_print_proc
- orte_dt_print_app_context
- orte_dt_print_map
- orte_dt_print_attr
- orte_dt_print_sig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 #include "orte_config.h"
25 #include "orte/types.h"
26
27 #include <sys/types.h>
28
29 #include "opal/util/argv.h"
30 #include "opal/mca/hwloc/base/base.h"
31
32 #include "orte/mca/errmgr/errmgr.h"
33 #include "orte/mca/grpcomm/grpcomm.h"
34 #include "orte/mca/rmaps/base/base.h"
35 #include "opal/dss/dss.h"
36 #include "orte/util/name_fns.h"
37 #include "orte/util/error_strings.h"
38 #include "orte/runtime/orte_globals.h"
39
40 #include "orte/runtime/data_type_support/orte_dt_support.h"
41
42 static void orte_dt_quick_print(char **output, char *type_name, char *prefix, void *src, opal_data_type_t real_type)
43 {
44 int8_t *i8;
45 int16_t *i16;
46 int32_t *i32;
47 int64_t *i64;
48 uint8_t *ui8;
49 uint16_t *ui16;
50 uint32_t *ui32;
51 uint64_t *ui64;
52
53
54 *output = NULL;
55
56
57 if (NULL == src) {
58 opal_asprintf(output, "%sData type: %s\tData size: 8-bit\tValue: NULL pointer",
59 (NULL == prefix) ? "" : prefix, type_name);
60 return;
61 }
62
63 switch(real_type) {
64 case OPAL_INT8:
65 i8 = (int8_t*)src;
66 opal_asprintf(output, "%sData type: %s\tData size: 8-bit\tValue: %d",
67 (NULL == prefix) ? "" : prefix, type_name, (int) *i8);
68 break;
69
70 case OPAL_UINT8:
71 ui8 = (uint8_t*)src;
72 opal_asprintf(output, "%sData type: %s\tData size: 8-bit\tValue: %u",
73 (NULL == prefix) ? "" : prefix, type_name, (unsigned int)*ui8);
74 break;
75
76 case OPAL_INT16:
77 i16 = (int16_t*)src;
78 opal_asprintf(output, "%sData type: %s\tData size: 16-bit\tValue: %d",
79 (NULL == prefix) ? "" : prefix, type_name, (int) *i16);
80 break;
81
82 case OPAL_UINT16:
83 ui16 = (uint16_t*)src;
84 opal_asprintf(output, "%sData type: %s\tData size: 16-bit\tValue: %u",
85 (NULL == prefix) ? "" : prefix, type_name, (unsigned int) *ui16);
86 break;
87
88 case OPAL_INT32:
89 i32 = (int32_t*)src;
90 opal_asprintf(output, "%sData type: %s\tData size: 32-bit\tValue: %ld",
91 (NULL == prefix) ? "" : prefix, type_name, (long) *i32);
92 break;
93
94 case OPAL_UINT32:
95 ui32 = (uint32_t*)src;
96 opal_asprintf(output, "%sData type: %s\tData size: 32-bit\tValue: %lu",
97 (NULL == prefix) ? "" : prefix, type_name, (unsigned long) *ui32);
98 break;
99
100 case OPAL_INT64:
101 i64 = (int64_t*)src;
102 opal_asprintf(output, "%sData type: %s\tData size: 64-bit\tValue: %ld",
103 (NULL == prefix) ? "" : prefix, type_name, (long) *i64);
104 break;
105
106 case OPAL_UINT64:
107 ui64 = (uint64_t*)src;
108 opal_asprintf(output, "%sData type: %s\tData size: 64-bit\tValue: %lu",
109 (NULL == prefix) ? "" : prefix, type_name, (unsigned long) *ui64);
110 break;
111
112 default:
113 return;
114 }
115
116 return;
117 }
118
119
120
121
122 int orte_dt_std_print(char **output, char *prefix, void *src, opal_data_type_t type)
123 {
124
125 *output = NULL;
126
127 switch(type) {
128 case ORTE_STD_CNTR:
129 orte_dt_quick_print(output, "ORTE_STD_CNTR", prefix, src, ORTE_STD_CNTR_T);
130 break;
131
132 case ORTE_PROC_STATE:
133 orte_dt_quick_print(output, "ORTE_PROC_STATE", prefix, src, ORTE_PROC_STATE_T);
134 break;
135
136 case ORTE_JOB_STATE:
137 orte_dt_quick_print(output, "ORTE_JOB_STATE", prefix, src, ORTE_JOB_STATE_T);
138 break;
139
140 case ORTE_NODE_STATE:
141 orte_dt_quick_print(output, "ORTE_NODE_STATE", prefix, src, ORTE_NODE_STATE_T);
142 break;
143
144 case ORTE_EXIT_CODE:
145 orte_dt_quick_print(output, "ORTE_EXIT_CODE", prefix, src, ORTE_EXIT_CODE_T);
146 break;
147
148 case ORTE_RML_TAG:
149 orte_dt_quick_print(output, "ORTE_RML_TAG", prefix, src, ORTE_RML_TAG_T);
150 break;
151
152 case ORTE_DAEMON_CMD:
153 orte_dt_quick_print(output, "ORTE_DAEMON_CMD", prefix, src, ORTE_DAEMON_CMD_T);
154 break;
155
156 case ORTE_IOF_TAG:
157 orte_dt_quick_print(output, "ORTE_IOF_TAG", prefix, src, ORTE_IOF_TAG_T);
158 break;
159
160 default:
161 ORTE_ERROR_LOG(ORTE_ERR_UNKNOWN_DATA_TYPE);
162 return ORTE_ERR_UNKNOWN_DATA_TYPE;
163 }
164
165 return ORTE_SUCCESS;
166 }
167
168
169
170
171 int orte_dt_print_job(char **output, char *prefix, orte_job_t *src, opal_data_type_t type)
172 {
173 char *tmp, *tmp2, *tmp3, *pfx2, *pfx;
174 int32_t i;
175 int rc;
176 orte_app_context_t *app;
177 orte_proc_t *proc;
178
179
180 *output = NULL;
181
182
183 if (NULL == prefix) {
184 opal_asprintf(&pfx2, " ");
185 } else {
186 opal_asprintf(&pfx2, "%s", prefix);
187 }
188
189 tmp2 = opal_argv_join(src->personality, ',');
190 opal_asprintf(&tmp, "\n%sData for job: %s\tPersonality: %s\tRecovery: %s(%s)\n%s\tNum apps: %ld\tStdin target: %s\tState: %s\tAbort: %s", pfx2,
191 ORTE_JOBID_PRINT(src->jobid), tmp2,
192 (ORTE_FLAG_TEST(src, ORTE_JOB_FLAG_RECOVERABLE)) ? "ENABLED" : "DISABLED",
193 (orte_get_attribute(&src->attributes, ORTE_JOB_RECOVER_DEFINED, NULL, OPAL_BOOL)) ? "DEFINED" : "DEFAULT",
194 pfx2,
195 (long)src->num_apps, ORTE_VPID_PRINT(src->stdin_target),
196 orte_job_state_to_str(src->state), (ORTE_FLAG_TEST(src, ORTE_JOB_FLAG_ABORTED)) ? "True" : "False");
197 free(tmp2);
198 opal_asprintf(&pfx, "%s\t", pfx2);
199 free(pfx2);
200
201 for (i=0; i < src->apps->size; i++) {
202 if (NULL == (app = (orte_app_context_t*)opal_pointer_array_get_item(src->apps, i))) {
203 continue;
204 }
205 opal_dss.print(&tmp2, pfx, app, ORTE_APP_CONTEXT);
206 opal_asprintf(&tmp3, "%s\n%s", tmp, tmp2);
207 free(tmp);
208 free(tmp2);
209 tmp = tmp3;
210 }
211
212 if (NULL != src->map) {
213 if (ORTE_SUCCESS != (rc = opal_dss.print(&tmp2, pfx, src->map, ORTE_JOB_MAP))) {
214 ORTE_ERROR_LOG(rc);
215 return rc;
216 }
217 opal_asprintf(&tmp3, "%s%s", tmp, tmp2);
218 free(tmp);
219 free(tmp2);
220 tmp = tmp3;
221 } else {
222 opal_asprintf(&tmp2, "%s\n%sNo Map", tmp, pfx);
223 free(tmp);
224 tmp = tmp2;
225 }
226
227 opal_asprintf(&tmp2, "%s\n%sNum procs: %ld\tOffset: %ld", tmp, pfx, (long)src->num_procs, (long)src->offset);
228 free(tmp);
229 tmp = tmp2;
230
231 for (i=0; i < src->procs->size; i++) {
232 if (NULL == (proc = (orte_proc_t*)opal_pointer_array_get_item(src->procs, i))) {
233 continue;
234 }
235 if (ORTE_SUCCESS != (rc = opal_dss.print(&tmp2, pfx, proc, ORTE_PROC))) {
236 ORTE_ERROR_LOG(rc);
237 return rc;
238 }
239 opal_asprintf(&tmp3, "%s%s", tmp, tmp2);
240 free(tmp);
241 free(tmp2);
242 tmp = tmp3;
243 }
244
245 opal_asprintf(&tmp2, "%s\n%s\tNum launched: %ld\tNum reported: %ld\tNum terminated: %ld",
246 tmp, pfx, (long)src->num_launched, (long)src->num_reported,
247 (long)src->num_terminated);
248 free(tmp);
249 tmp = tmp2;
250
251
252 *output = tmp;
253 free(pfx);
254
255 return ORTE_SUCCESS;
256 }
257
258
259
260
261 int orte_dt_print_node(char **output, char *prefix, orte_node_t *src, opal_data_type_t type)
262 {
263 char *tmp, *tmp2, *tmp3, *pfx2, *pfx;
264 int32_t i;
265 int rc;
266 orte_proc_t *proc;
267 char **alias;
268
269 *output = NULL;
270
271
272 if (NULL == prefix) {
273 opal_asprintf(&pfx2, " ");
274 } else {
275 opal_asprintf(&pfx2, "%s", prefix);
276 }
277
278 if (orte_xml_output) {
279
280 opal_asprintf(&tmp, "%s<host name=\"%s\" slots=\"%d\" max_slots=\"%d\">\n", pfx2,
281 (NULL == src->name) ? "UNKNOWN" : src->name,
282 (int)src->slots, (int)src->slots_max);
283
284 tmp3 = NULL;
285 if (orte_get_attribute(&src->attributes, ORTE_NODE_ALIAS, (void**)&tmp3, OPAL_STRING)) {
286 alias = opal_argv_split(tmp3, ',');
287 for (i=0; NULL != alias[i]; i++) {
288 opal_asprintf(&tmp2, "%s%s\t<noderesolve resolved=\"%s\"/>\n", tmp, pfx2, alias[i]);
289 free(tmp);
290 tmp = tmp2;
291 }
292 opal_argv_free(alias);
293 }
294 if (NULL != tmp3) {
295 free(tmp3);
296 }
297 *output = tmp;
298 free(pfx2);
299 return ORTE_SUCCESS;
300 }
301
302 if (!orte_devel_level_output) {
303
304 if (0 == src->num_procs) {
305
306 opal_asprintf(&tmp, "\n%sData for node: %s\tNum slots: %ld\tMax slots: %ld",
307 pfx2, (NULL == src->name) ? "UNKNOWN" : src->name,
308 (long)src->slots, (long)src->slots_max);
309
310 tmp3 = NULL;
311 if (orte_get_attribute(&src->attributes, ORTE_NODE_ALIAS, (void**)&tmp3, OPAL_STRING)) {
312 alias = opal_argv_split(tmp3, ',');
313 for (i=0; NULL != alias[i]; i++) {
314 opal_asprintf(&tmp2, "%s%s\tresolved from %s\n", tmp, pfx2, alias[i]);
315 free(tmp);
316 tmp = tmp2;
317 }
318 opal_argv_free(alias);
319 }
320 if (NULL != tmp3) {
321 free(tmp3);
322 }
323 free(pfx2);
324 *output = tmp;
325 return ORTE_SUCCESS;
326 }
327 opal_asprintf(&tmp, "\n%sData for node: %s\tNum slots: %ld\tMax slots: %ld\tNum procs: %ld",
328 pfx2, (NULL == src->name) ? "UNKNOWN" : src->name,
329 (long)src->slots, (long)src->slots_max, (long)src->num_procs);
330
331 tmp3 = NULL;
332 if (orte_get_attribute(&src->attributes, ORTE_NODE_ALIAS, (void**)&tmp3, OPAL_STRING)) {
333 alias = opal_argv_split(tmp3, ',');
334 for (i=0; NULL != alias[i]; i++) {
335 opal_asprintf(&tmp2, "%s%s\tresolved from %s\n", tmp, pfx2, alias[i]);
336 free(tmp);
337 tmp = tmp2;
338 }
339 opal_argv_free(alias);
340 }
341 if (NULL != tmp3) {
342 free(tmp3);
343 }
344 goto PRINT_PROCS;
345 }
346
347 opal_asprintf(&tmp, "\n%sData for node: %s\tState: %0x\tFlags: %02x",
348 pfx2, (NULL == src->name) ? "UNKNOWN" : src->name, src->state, src->flags);
349
350 tmp3 = NULL;
351 if (orte_get_attribute(&src->attributes, ORTE_NODE_ALIAS, (void**)&tmp3, OPAL_STRING)) {
352 alias = opal_argv_split(tmp3, ',');
353 for (i=0; NULL != alias[i]; i++) {
354 opal_asprintf(&tmp2, "%s%s\tresolved from %s\n", tmp, pfx2, alias[i]);
355 free(tmp);
356 tmp = tmp2;
357 }
358 opal_argv_free(alias);
359 }
360 if (NULL != tmp3) {
361 free(tmp3);
362 }
363
364 if (NULL == src->daemon) {
365 opal_asprintf(&tmp2, "%s\n%s\tDaemon: %s\tDaemon launched: %s", tmp, pfx2,
366 "Not defined", ORTE_FLAG_TEST(src, ORTE_NODE_FLAG_DAEMON_LAUNCHED) ? "True" : "False");
367 } else {
368 opal_asprintf(&tmp2, "%s\n%s\tDaemon: %s\tDaemon launched: %s", tmp, pfx2,
369 ORTE_NAME_PRINT(&(src->daemon->name)),
370 ORTE_FLAG_TEST(src, ORTE_NODE_FLAG_DAEMON_LAUNCHED) ? "True" : "False");
371 }
372 free(tmp);
373 tmp = tmp2;
374
375 opal_asprintf(&tmp2, "%s\n%s\tNum slots: %ld\tSlots in use: %ld\tOversubscribed: %s", tmp, pfx2,
376 (long)src->slots, (long)src->slots_inuse,
377 ORTE_FLAG_TEST(src, ORTE_NODE_FLAG_OVERSUBSCRIBED) ? "TRUE" : "FALSE");
378 free(tmp);
379 tmp = tmp2;
380
381 opal_asprintf(&tmp2, "%s\n%s\tNum slots allocated: %ld\tMax slots: %ld", tmp, pfx2,
382 (long)src->slots, (long)src->slots_max);
383 free(tmp);
384 tmp = tmp2;
385
386 tmp3 = NULL;
387 if (orte_get_attribute(&src->attributes, ORTE_NODE_USERNAME, (void**)&tmp3, OPAL_STRING)) {
388 opal_asprintf(&tmp2, "%s\n%s\tUsername on node: %s", tmp, pfx2, tmp3);
389 free(tmp3);
390 free(tmp);
391 tmp = tmp2;
392 }
393
394 if (orte_display_topo_with_map && NULL != src->topology) {
395 char *pfx3;
396 opal_asprintf(&tmp2, "%s\n%s\tDetected Resources:\n", tmp, pfx2);
397 free(tmp);
398 tmp = tmp2;
399
400 tmp2 = NULL;
401 opal_asprintf(&pfx3, "%s\t\t", pfx2);
402 opal_dss.print(&tmp2, pfx3, src->topology, OPAL_HWLOC_TOPO);
403 free(pfx3);
404 opal_asprintf(&tmp3, "%s%s", tmp, tmp2);
405 free(tmp);
406 free(tmp2);
407 tmp = tmp3;
408 }
409
410 opal_asprintf(&tmp2, "%s\n%s\tNum procs: %ld\tNext node_rank: %ld", tmp, pfx2,
411 (long)src->num_procs, (long)src->next_node_rank);
412 free(tmp);
413 tmp = tmp2;
414
415 PRINT_PROCS:
416 opal_asprintf(&pfx, "%s\t", pfx2);
417 free(pfx2);
418
419 for (i=0; i < src->procs->size; i++) {
420 if (NULL == (proc = (orte_proc_t*)opal_pointer_array_get_item(src->procs, i))) {
421 continue;
422 }
423 if (ORTE_SUCCESS != (rc = opal_dss.print(&tmp2, pfx, proc, ORTE_PROC))) {
424 ORTE_ERROR_LOG(rc);
425 return rc;
426 }
427 opal_asprintf(&tmp3, "%s%s", tmp, tmp2);
428 free(tmp);
429 free(tmp2);
430 tmp = tmp3;
431 }
432 free(pfx);
433
434
435 *output = tmp;
436
437 return ORTE_SUCCESS;
438 }
439
440
441
442
443 int orte_dt_print_proc(char **output, char *prefix, orte_proc_t *src, opal_data_type_t type)
444 {
445 char *tmp, *tmp3, *pfx2;
446 hwloc_obj_t loc=NULL;
447 char locale[1024], tmp1[1024], tmp2[1024];
448 hwloc_cpuset_t mycpus;
449 char *str=NULL, *cpu_bitmap=NULL;
450
451
452
453 *output = NULL;
454
455
456 if (NULL == prefix) {
457 opal_asprintf(&pfx2, " ");
458 } else {
459 opal_asprintf(&pfx2, "%s", prefix);
460 }
461
462 if (orte_xml_output) {
463
464 if (0 == src->pid) {
465 opal_asprintf(output, "%s<process rank=\"%s\" status=\"%s\"/>\n", pfx2,
466 ORTE_VPID_PRINT(src->name.vpid), orte_proc_state_to_str(src->state));
467 } else {
468 opal_asprintf(output, "%s<process rank=\"%s\" pid=\"%d\" status=\"%s\"/>\n", pfx2,
469 ORTE_VPID_PRINT(src->name.vpid), (int)src->pid, orte_proc_state_to_str(src->state));
470 }
471 free(pfx2);
472 return ORTE_SUCCESS;
473 }
474
475 if (!orte_devel_level_output) {
476 if (orte_get_attribute(&src->attributes, ORTE_PROC_CPU_BITMAP, (void**)&cpu_bitmap, OPAL_STRING) &&
477 NULL != src->node->topology && NULL != src->node->topology->topo) {
478 mycpus = hwloc_bitmap_alloc();
479 hwloc_bitmap_list_sscanf(mycpus, cpu_bitmap);
480 if (OPAL_ERR_NOT_BOUND == opal_hwloc_base_cset2str(tmp1, sizeof(tmp1), src->node->topology->topo, mycpus)) {
481 str = strdup("UNBOUND");
482 } else {
483 opal_hwloc_base_cset2mapstr(tmp2, sizeof(tmp2), src->node->topology->topo, mycpus);
484 opal_asprintf(&str, "%s:%s", tmp1, tmp2);
485 }
486 hwloc_bitmap_free(mycpus);
487 opal_asprintf(&tmp, "\n%sProcess OMPI jobid: %s App: %ld Process rank: %s Bound: %s", pfx2,
488 ORTE_JOBID_PRINT(src->name.jobid), (long)src->app_idx,
489 ORTE_VPID_PRINT(src->name.vpid), (NULL == str) ? "N/A" : str);
490 if (NULL != str) {
491 free(str);
492 }
493 if (NULL != cpu_bitmap) {
494 free(cpu_bitmap);
495 }
496 } else {
497
498 opal_asprintf(&tmp, "\n%sProcess OMPI jobid: %s App: %ld Process rank: %s Bound: N/A", pfx2,
499 ORTE_JOBID_PRINT(src->name.jobid), (long)src->app_idx,
500 ORTE_VPID_PRINT(src->name.vpid));
501 }
502
503
504 *output = tmp;
505 free(pfx2);
506 return ORTE_SUCCESS;
507 }
508
509 opal_asprintf(&tmp, "\n%sData for proc: %s", pfx2, ORTE_NAME_PRINT(&src->name));
510
511 opal_asprintf(&tmp3, "%s\n%s\tPid: %ld\tLocal rank: %lu\tNode rank: %lu\tApp rank: %d", tmp, pfx2,
512 (long)src->pid, (unsigned long)src->local_rank, (unsigned long)src->node_rank, src->app_rank);
513 free(tmp);
514 tmp = tmp3;
515
516 if (orte_get_attribute(&src->attributes, ORTE_PROC_HWLOC_LOCALE, (void**)&loc, OPAL_PTR)) {
517 if (NULL != loc) {
518 if (OPAL_ERR_NOT_BOUND == opal_hwloc_base_cset2mapstr(locale, sizeof(locale), src->node->topology->topo, loc->cpuset)) {
519 strcpy(locale, "NODE");
520 }
521 } else {
522 strcpy(locale, "UNKNOWN");
523 }
524 } else {
525 strcpy(locale, "UNKNOWN");
526 }
527 if (orte_get_attribute(&src->attributes, ORTE_PROC_CPU_BITMAP, (void**)&cpu_bitmap, OPAL_STRING) &&
528 NULL != src->node->topology && NULL != src->node->topology->topo) {
529 mycpus = hwloc_bitmap_alloc();
530 hwloc_bitmap_list_sscanf(mycpus, cpu_bitmap);
531 opal_hwloc_base_cset2mapstr(tmp2, sizeof(tmp2), src->node->topology->topo, mycpus);
532 } else {
533 snprintf(tmp2, sizeof(tmp2), "UNBOUND");
534 }
535 opal_asprintf(&tmp3, "%s\n%s\tState: %s\tApp_context: %ld\n%s\tLocale: %s\n%s\tBinding: %s", tmp, pfx2,
536 orte_proc_state_to_str(src->state), (long)src->app_idx, pfx2, locale, pfx2, tmp2);
537 free(tmp);
538 if (NULL != str) {
539 free(str);
540 }
541 if (NULL != cpu_bitmap) {
542 free(cpu_bitmap);
543 }
544
545
546 *output = tmp3;
547
548 free(pfx2);
549 return ORTE_SUCCESS;
550 }
551
552
553
554
555 int orte_dt_print_app_context(char **output, char *prefix, orte_app_context_t *src, opal_data_type_t type)
556 {
557 char *tmp, *tmp2, *tmp3, *pfx2;
558 int i, count;
559 opal_value_t *kv;
560
561
562 *output = NULL;
563
564
565 if (NULL == prefix) {
566 opal_asprintf(&pfx2, " ");
567 } else {
568 opal_asprintf(&pfx2, "%s", prefix);
569 }
570
571 opal_asprintf(&tmp, "\n%sData for app_context: index %lu\tapp: %s\n%s\tNum procs: %lu\tFirstRank: %s",
572 pfx2, (unsigned long)src->idx,
573 (NULL == src->app) ? "NULL" : src->app,
574 pfx2, (unsigned long)src->num_procs,
575 ORTE_VPID_PRINT(src->first_rank));
576
577 count = opal_argv_count(src->argv);
578 for (i=0; i < count; i++) {
579 opal_asprintf(&tmp2, "%s\n%s\tArgv[%d]: %s", tmp, pfx2, i, src->argv[i]);
580 free(tmp);
581 tmp = tmp2;
582 }
583
584 count = opal_argv_count(src->env);
585 for (i=0; i < count; i++) {
586 opal_asprintf(&tmp2, "%s\n%s\tEnv[%lu]: %s", tmp, pfx2, (unsigned long)i, src->env[i]);
587 free(tmp);
588 tmp = tmp2;
589 }
590
591 tmp3 = NULL;
592 orte_get_attribute(&src->attributes, ORTE_APP_PREFIX_DIR, (void**)&tmp3, OPAL_STRING);
593 opal_asprintf(&tmp2, "%s\n%s\tWorking dir: %s\n%s\tPrefix: %s\n%s\tUsed on node: %s", tmp,
594 pfx2, (NULL == src->cwd) ? "NULL" : src->cwd,
595 pfx2, (NULL == tmp3) ? "NULL" : tmp3,
596 pfx2, ORTE_FLAG_TEST(src, ORTE_APP_FLAG_USED_ON_NODE) ? "TRUE" : "FALSE");
597 free(tmp);
598 tmp = tmp2;
599
600 OPAL_LIST_FOREACH(kv, &src->attributes, opal_value_t) {
601 opal_dss.print(&tmp2, pfx2, kv, ORTE_ATTRIBUTE);
602 opal_asprintf(&tmp3, "%s\n%s", tmp, tmp2);
603 free(tmp2);
604 free(tmp);
605 tmp = tmp3;
606 }
607
608
609 *output = tmp;
610
611 free(pfx2);
612 return ORTE_SUCCESS;
613 }
614
615
616
617
618 int orte_dt_print_map(char **output, char *prefix, orte_job_map_t *src, opal_data_type_t type)
619 {
620 char *tmp=NULL, *tmp2, *tmp3, *pfx, *pfx2;
621 int32_t i, j;
622 int rc;
623 orte_node_t *node;
624 orte_proc_t *proc;
625
626
627 *output = NULL;
628
629
630 if (NULL == prefix) {
631 opal_asprintf(&pfx2, " ");
632 } else {
633 opal_asprintf(&pfx2, "%s", prefix);
634 }
635
636 if (orte_xml_output) {
637
638 opal_asprintf(&tmp, "<map>\n");
639
640 for (i=0; i < src->nodes->size; i++) {
641 if (NULL == (node = (orte_node_t*)opal_pointer_array_get_item(src->nodes, i))) {
642 continue;
643 }
644 orte_dt_print_node(&tmp2, "\t", node, ORTE_NODE);
645 opal_asprintf(&tmp3, "%s%s", tmp, tmp2);
646 free(tmp2);
647 free(tmp);
648 tmp = tmp3;
649
650 for (j=0; j < node->procs->size; j++) {
651 if (NULL == (proc = (orte_proc_t*)opal_pointer_array_get_item(node->procs, j))) {
652 continue;
653 }
654 orte_dt_print_proc(&tmp2, "\t\t", proc, ORTE_PROC);
655 opal_asprintf(&tmp3, "%s%s", tmp, tmp2);
656 free(tmp2);
657 free(tmp);
658 tmp = tmp3;
659 }
660 opal_asprintf(&tmp3, "%s\t</host>\n", tmp);
661 free(tmp);
662 tmp = tmp3;
663 }
664 opal_asprintf(&tmp2, "%s</map>\n", tmp);
665 free(tmp);
666 free(pfx2);
667 *output = tmp2;
668 return ORTE_SUCCESS;
669
670 }
671
672 opal_asprintf(&pfx, "%s\t", pfx2);
673
674 if (orte_devel_level_output) {
675 opal_asprintf(&tmp, "\n%sMapper requested: %s Last mapper: %s Mapping policy: %s Ranking policy: %s\n%sBinding policy: %s Cpu set: %s PPR: %s Cpus-per-rank: %d",
676 pfx2, (NULL == src->req_mapper) ? "NULL" : src->req_mapper,
677 (NULL == src->last_mapper) ? "NULL" : src->last_mapper,
678 orte_rmaps_base_print_mapping(src->mapping),
679 orte_rmaps_base_print_ranking(src->ranking),
680 pfx2, opal_hwloc_base_print_binding(src->binding),
681 (NULL == opal_hwloc_base_cpu_list) ? "NULL" : opal_hwloc_base_cpu_list,
682 (NULL == src->ppr) ? "NULL" : src->ppr,
683 (int)src->cpus_per_rank);
684
685 if (ORTE_VPID_INVALID == src->daemon_vpid_start) {
686 opal_asprintf(&tmp2, "%s\n%sNum new daemons: %ld\tNew daemon starting vpid INVALID\n%sNum nodes: %ld",
687 tmp, pfx, (long)src->num_new_daemons, pfx, (long)src->num_nodes);
688 } else {
689 opal_asprintf(&tmp2, "%s\n%sNum new daemons: %ld\tNew daemon starting vpid %ld\n%sNum nodes: %ld",
690 tmp, pfx, (long)src->num_new_daemons, (long)src->daemon_vpid_start,
691 pfx, (long)src->num_nodes);
692 }
693 free(tmp);
694 tmp = tmp2;
695 } else {
696
697 opal_asprintf(&tmp, "\n%s======================== JOB MAP ========================", pfx2);
698 }
699
700
701 for (i=0; i < src->nodes->size; i++) {
702 if (NULL == (node = (orte_node_t*)opal_pointer_array_get_item(src->nodes, i))) {
703 continue;
704 }
705 if (ORTE_SUCCESS != (rc = opal_dss.print(&tmp2, pfx2, node, ORTE_NODE))) {
706 ORTE_ERROR_LOG(rc);
707 free(pfx);
708 free(tmp);
709 return rc;
710 }
711 opal_asprintf(&tmp3, "%s\n%s", tmp, tmp2);
712 free(tmp);
713 free(tmp2);
714 tmp = tmp3;
715 }
716
717 if (!orte_devel_level_output) {
718
719 opal_asprintf(&tmp2, "%s\n\n%s=============================================================\n", tmp, pfx2);
720 free(tmp);
721 tmp = tmp2;
722 }
723 free(pfx2);
724
725
726 *output = tmp;
727
728 free(pfx);
729 return ORTE_SUCCESS;
730 }
731
732
733 int orte_dt_print_attr(char **output, char *prefix,
734 orte_attribute_t *src, opal_data_type_t type)
735 {
736 char *prefx;
737
738
739 if (NULL == prefix) opal_asprintf(&prefx, " ");
740 else prefx = strdup(prefix);
741
742
743 if (NULL == src) {
744 opal_asprintf(output, "%sData type: ORTE_ATTR\tValue: NULL pointer", prefx);
745 free(prefx);
746 return OPAL_SUCCESS;
747 }
748
749 switch (src->type) {
750 case OPAL_STRING:
751 opal_asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_STRING\tKey: %s\tValue: %s",
752 prefx, src->local ? "LOCAL" : "GLOBAL", orte_attr_key_to_str(src->key), src->data.string);
753 break;
754 case OPAL_SIZE:
755 opal_asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_SIZE\tKey: %s\tValue: %lu",
756 prefx, src->local ? "LOCAL" : "GLOBAL", orte_attr_key_to_str(src->key), (unsigned long)src->data.size);
757 break;
758 case OPAL_PID:
759 opal_asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_PID\tKey: %s\tValue: %lu",
760 prefx, src->local ? "LOCAL" : "GLOBAL", orte_attr_key_to_str(src->key), (unsigned long)src->data.pid);
761 break;
762 case OPAL_INT:
763 opal_asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_INT\tKey: %s\tValue: %d",
764 prefx, src->local ? "LOCAL" : "GLOBAL", orte_attr_key_to_str(src->key), src->data.integer);
765 break;
766 case OPAL_INT8:
767 opal_asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_INT8\tKey: %s\tValue: %d",
768 prefx, src->local ? "LOCAL" : "GLOBAL", orte_attr_key_to_str(src->key), (int)src->data.int8);
769 break;
770 case OPAL_INT16:
771 opal_asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_INT16\tKey: %s\tValue: %d",
772 prefx, src->local ? "LOCAL" : "GLOBAL", orte_attr_key_to_str(src->key), (int)src->data.int16);
773 break;
774 case OPAL_INT32:
775 opal_asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_INT32\tKey: %s\tValue: %d",
776 prefx, src->local ? "LOCAL" : "GLOBAL", orte_attr_key_to_str(src->key), src->data.int32);
777 break;
778 case OPAL_INT64:
779 opal_asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_INT64\tKey: %s\tValue: %d",
780 prefx, src->local ? "LOCAL" : "GLOBAL", orte_attr_key_to_str(src->key), (int)src->data.int64);
781 break;
782 case OPAL_UINT:
783 opal_asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_UINT\tKey: %s\tValue: %u",
784 prefx, src->local ? "LOCAL" : "GLOBAL", orte_attr_key_to_str(src->key), (unsigned int)src->data.uint);
785 break;
786 case OPAL_UINT8:
787 opal_asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_UINT8\tKey: %s\tValue: %u",
788 prefx, src->local ? "LOCAL" : "GLOBAL", orte_attr_key_to_str(src->key), (unsigned int)src->data.uint8);
789 break;
790 case OPAL_UINT16:
791 opal_asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_UINT16\tKey: %s\tValue: %u",
792 prefx, src->local ? "LOCAL" : "GLOBAL", orte_attr_key_to_str(src->key), (unsigned int)src->data.uint16);
793 break;
794 case OPAL_UINT32:
795 opal_asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_UINT32\tKey: %s\tValue: %u",
796 prefx, src->local ? "LOCAL" : "GLOBAL", orte_attr_key_to_str(src->key), src->data.uint32);
797 break;
798 case OPAL_UINT64:
799 opal_asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_UINT64\tKey: %s\tValue: %lu",
800 prefx, src->local ? "LOCAL" : "GLOBAL", orte_attr_key_to_str(src->key), (unsigned long)src->data.uint64);
801 break;
802 case OPAL_BYTE_OBJECT:
803 opal_asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_BYTE_OBJECT\tKey: %s\tValue: UNPRINTABLE",
804 prefx, src->local ? "LOCAL" : "GLOBAL", orte_attr_key_to_str(src->key));
805 break;
806 case OPAL_BUFFER:
807 opal_asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_BUFFER\tKey: %s\tValue: UNPRINTABLE",
808 prefx, src->local ? "LOCAL" : "GLOBAL", orte_attr_key_to_str(src->key));
809 break;
810 case OPAL_FLOAT:
811 opal_asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_FLOAT\tKey: %s\tValue: %f",
812 prefx, src->local ? "LOCAL" : "GLOBAL", orte_attr_key_to_str(src->key), src->data.fval);
813 break;
814 case OPAL_TIMEVAL:
815 opal_asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_TIMEVAL\tKey: %s\tValue: %ld.%06ld", prefx,
816 src->local ? "LOCAL" : "GLOBAL", orte_attr_key_to_str(src->key), (long)src->data.tv.tv_sec, (long)src->data.tv.tv_usec);
817 break;
818 case OPAL_PTR:
819 opal_asprintf(output, "%sORTE_ATTR: %s Data type: OPAL_PTR\tKey: %s", prefx,
820 src->local ? "LOCAL" : "GLOBAL", orte_attr_key_to_str(src->key));
821 break;
822 case ORTE_VPID:
823 opal_asprintf(output, "%sORTE_ATTR: %s Data type: ORTE_VPID\tKey: %s\tValue: %s", prefx, src->local ? "LOCAL" : "GLOBAL",
824 orte_attr_key_to_str(src->key), ORTE_VPID_PRINT(src->data.vpid));
825 break;
826 case ORTE_JOBID:
827 opal_asprintf(output, "%sORTE_ATTR: %s Data type: ORTE_JOBID\tKey: %s\tValue: %s", prefx, src->local ? "LOCAL" : "GLOBAL",
828 orte_attr_key_to_str(src->key), ORTE_JOBID_PRINT(src->data.jobid));
829 break;
830 default:
831 opal_asprintf(output, "%sORTE_ATTR: %s Data type: UNKNOWN\tKey: %s\tValue: UNPRINTABLE",
832 prefx, orte_attr_key_to_str(src->key), src->local ? "LOCAL" : "GLOBAL");
833 break;
834 }
835 free(prefx);
836 return ORTE_SUCCESS;
837 }
838
839 int orte_dt_print_sig(char **output, char *prefix, orte_grpcomm_signature_t *src, opal_data_type_t type)
840 {
841 char *prefx;
842 size_t i;
843 char *tmp, *tmp2;
844
845
846 if (NULL == prefix) opal_asprintf(&prefx, " ");
847 else prefx = strdup(prefix);
848
849
850 if (NULL == src) {
851 opal_asprintf(output, "%sData type: ORTE_SIG", prefx);
852 free(prefx);
853 return OPAL_SUCCESS;
854 }
855
856 if (NULL == src->signature) {
857 opal_asprintf(output, "%sORTE_SIG Procs: NULL", prefx);
858 free(prefx);
859 return ORTE_SUCCESS;
860 }
861
862
863 opal_asprintf(&tmp, "%sORTE_SIG Procs: ", prefx);
864
865 for (i=0; i < src->sz; i++) {
866 opal_asprintf(&tmp2, "%s%s", tmp, ORTE_NAME_PRINT(&src->signature[i]));
867 free(tmp);
868 tmp = tmp2;
869 }
870 *output = tmp;
871 return ORTE_SUCCESS;
872 }