1313 * Copyright (c) 2011-2015 Cisco Systems, Inc. All rights reserved.
1414 * Copyright (c) 2011-2013 Los Alamos National Security, LLC.
1515 * All rights reserved.
16- * Copyright (c) 2013-2017 Intel, Inc. All rights reserved.
16+ * Copyright (c) 2013-2018 Intel, Inc. All rights reserved.
1717 * $COPYRIGHT$
1818 *
1919 * Additional copyrights may follow
@@ -442,9 +442,12 @@ int orte_dt_print_node(char **output, char *prefix, orte_node_t *src, opal_data_
442442 */
443443int orte_dt_print_proc (char * * output , char * prefix , orte_proc_t * src , opal_data_type_t type )
444444{
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+
448451
449452 /* set default result */
450453 * output = NULL ;
@@ -470,10 +473,6 @@ int orte_dt_print_proc(char **output, char *prefix, orte_proc_t *src, opal_data_
470473 }
471474
472475 if (!orte_devel_level_output ) {
473- hwloc_cpuset_t mycpus ;
474- char tmp1 [1024 ], tmp2 [1024 ];
475- char * str = NULL , * cpu_bitmap = NULL ;
476-
477476 if (orte_get_attribute (& src -> attributes , ORTE_PROC_CPU_BITMAP , (void * * )& cpu_bitmap , OPAL_STRING ) &&
478477 NULL != src -> node -> topology && NULL != src -> node -> topology -> topo ) {
479478 mycpus = hwloc_bitmap_alloc ();
@@ -509,10 +508,10 @@ int orte_dt_print_proc(char **output, char *prefix, orte_proc_t *src, opal_data_
509508
510509 asprintf (& tmp , "\n%sData for proc: %s" , pfx2 , ORTE_NAME_PRINT (& src -> name ));
511510
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 ,
513512 (long )src -> pid , (unsigned long )src -> local_rank , (unsigned long )src -> node_rank , src -> app_rank );
514513 free (tmp );
515- tmp = tmp2 ;
514+ tmp = tmp3 ;
516515
517516 if (orte_get_attribute (& src -> attributes , ORTE_PROC_HWLOC_LOCALE , (void * * )& loc , OPAL_PTR )) {
518517 if (NULL != loc ) {
@@ -525,23 +524,26 @@ int orte_dt_print_proc(char **output, char *prefix, orte_proc_t *src, opal_data_
525524 } else {
526525 strcpy (locale , "UNKNOWN" );
527526 }
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 );
536532 } else {
537- strcpy ( bind , "UNBOUND" );
533+ snprintf ( tmp2 , sizeof ( tmp2 ) , "UNBOUND" );
538534 }
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 );
541537 free (tmp );
538+ if (NULL != str ) {
539+ free (str );
540+ }
541+ if (NULL != cpu_bitmap ) {
542+ free (cpu_bitmap );
543+ }
542544
543545 /* set the return */
544- * output = tmp2 ;
546+ * output = tmp3 ;
545547
546548 free (pfx2 );
547549 return ORTE_SUCCESS ;
0 commit comments