13
13
* Copyright (c) 2011-2015 Cisco Systems, Inc. All rights reserved.
14
14
* Copyright (c) 2011-2013 Los Alamos National Security, LLC.
15
15
* All rights reserved.
16
- * Copyright (c) 2013-2017 Intel, Inc. All rights reserved.
16
+ * Copyright (c) 2013-2018 Intel, Inc. All rights reserved.
17
17
* $COPYRIGHT$
18
18
*
19
19
* Additional copyrights may follow
@@ -442,9 +442,12 @@ int orte_dt_print_node(char **output, char *prefix, orte_node_t *src, opal_data_
442
442
*/
443
443
int orte_dt_print_proc (char * * output , char * prefix , orte_proc_t * src , opal_data_type_t type )
444
444
{
445
- char * tmp , * tmp2 , * pfx2 ;
446
- hwloc_obj_t loc = NULL , bd = NULL ;
447
- char locale [1024 ], bind [1024 ];
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
+
448
451
449
452
/* set default result */
450
453
* output = NULL ;
@@ -470,10 +473,6 @@ int orte_dt_print_proc(char **output, char *prefix, orte_proc_t *src, opal_data_
470
473
}
471
474
472
475
if (!orte_devel_level_output ) {
473
- hwloc_cpuset_t mycpus ;
474
- char tmp1 [1024 ], tmp2 [1024 ];
475
- char * str = NULL , * cpu_bitmap = NULL ;
476
-
477
476
if (orte_get_attribute (& src -> attributes , ORTE_PROC_CPU_BITMAP , (void * * )& cpu_bitmap , OPAL_STRING ) &&
478
477
NULL != src -> node -> topology && NULL != src -> node -> topology -> topo ) {
479
478
mycpus = hwloc_bitmap_alloc ();
@@ -509,10 +508,10 @@ int orte_dt_print_proc(char **output, char *prefix, orte_proc_t *src, opal_data_
509
508
510
509
asprintf (& tmp , "\n%sData for proc: %s" , pfx2 , ORTE_NAME_PRINT (& src -> name ));
511
510
512
- asprintf (& tmp2 , "%s\n%s\tPid: %ld\tLocal rank: %lu\tNode rank: %lu\tApp rank: %d" , tmp , pfx2 ,
511
+ asprintf (& tmp3 , "%s\n%s\tPid: %ld\tLocal rank: %lu\tNode rank: %lu\tApp rank: %d" , tmp , pfx2 ,
513
512
(long )src -> pid , (unsigned long )src -> local_rank , (unsigned long )src -> node_rank , src -> app_rank );
514
513
free (tmp );
515
- tmp = tmp2 ;
514
+ tmp = tmp3 ;
516
515
517
516
if (orte_get_attribute (& src -> attributes , ORTE_PROC_HWLOC_LOCALE , (void * * )& loc , OPAL_PTR )) {
518
517
if (NULL != loc ) {
@@ -525,23 +524,26 @@ int orte_dt_print_proc(char **output, char *prefix, orte_proc_t *src, opal_data_
525
524
} else {
526
525
strcpy (locale , "UNKNOWN" );
527
526
}
528
- if (orte_get_attribute (& src -> attributes , ORTE_PROC_HWLOC_BOUND , (void * * )& bd , OPAL_PTR )) {
529
- if (NULL != bd ) {
530
- if (OPAL_ERR_NOT_BOUND == opal_hwloc_base_cset2mapstr (bind , sizeof (bind ), src -> node -> topology -> topo , bd -> cpuset )) {
531
- strcpy (bind , "UNBOUND" );
532
- }
533
- } else {
534
- strcpy (bind , "UNBOUND" );
535
- }
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 );
536
532
} else {
537
- strcpy ( bind , "UNBOUND" );
533
+ snprintf ( tmp2 , sizeof ( tmp2 ) , "UNBOUND" );
538
534
}
539
- asprintf (& tmp2 , "%s\n%s\tState: %s\tApp_context: %ld\n%s\tLocale: %s\n%s\tBinding: %s" , tmp , pfx2 ,
540
- orte_proc_state_to_str (src -> state ), (long )src -> app_idx , pfx2 , locale , pfx2 , bind );
535
+ 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 );
541
537
free (tmp );
538
+ if (NULL != str ) {
539
+ free (str );
540
+ }
541
+ if (NULL != cpu_bitmap ) {
542
+ free (cpu_bitmap );
543
+ }
542
544
543
545
/* set the return */
544
- * output = tmp2 ;
546
+ * output = tmp3 ;
545
547
546
548
free (pfx2 );
547
549
return ORTE_SUCCESS ;
0 commit comments