@@ -39,6 +39,10 @@ struct hwloc_x86_backend_data_s {
39
39
char * src_cpuiddump_path ;
40
40
int is_knl ;
41
41
int is_hybrid ;
42
+ int found_die_ids ;
43
+ int found_unit_ids ;
44
+ int found_module_ids ;
45
+ int found_tile_ids ;
42
46
};
43
47
44
48
/************************************
@@ -481,7 +485,7 @@ static void read_amd_cores_legacy(struct procinfo *infos, struct cpuiddump *src_
481
485
}
482
486
483
487
/* AMD unit/node from CPUID 0x8000001e leaf (topoext) */
484
- static void read_amd_cores_topoext (struct procinfo * infos , unsigned long flags , struct cpuiddump * src_cpuiddump )
488
+ static void read_amd_cores_topoext (struct hwloc_x86_backend_data_s * data , struct procinfo * infos , unsigned long flags , struct cpuiddump * src_cpuiddump )
485
489
{
486
490
unsigned apic_id , nodes_per_proc = 0 ;
487
491
unsigned eax , ebx , ecx , edx ;
@@ -511,6 +515,7 @@ static void read_amd_cores_topoext(struct procinfo *infos, unsigned long flags,
511
515
unsigned cores_per_unit ;
512
516
/* coreid was obtained from read_amd_cores_legacy() earlier */
513
517
infos -> ids [UNIT ] = ebx & 0xff ;
518
+ data -> found_unit_ids = 1 ;
514
519
cores_per_unit = ((ebx >> 8 ) & 0xff ) + 1 ;
515
520
hwloc_debug ("topoext %08x, %u nodes, node %u, %u cores in unit %u\n" , apic_id , nodes_per_proc , infos -> ids [NODE ], cores_per_unit , infos -> ids [UNIT ]);
516
521
/* coreid and unitid are package-wide (core 0-15 and unit 0-7 on 16-core 2-NUMAnode processor).
@@ -526,7 +531,7 @@ static void read_amd_cores_topoext(struct procinfo *infos, unsigned long flags,
526
531
}
527
532
528
533
/* Intel core/thread or even die/module/tile from CPUID 0x0b or 0x1f leaves (v1 and v2 extended topology enumeration) */
529
- static void read_intel_cores_exttopoenum (struct procinfo * infos , unsigned leaf , struct cpuiddump * src_cpuiddump )
534
+ static void read_intel_cores_exttopoenum (struct hwloc_x86_backend_data_s * data , struct procinfo * infos , unsigned leaf , struct cpuiddump * src_cpuiddump )
530
535
{
531
536
unsigned level , apic_nextshift , apic_type , apic_id = 0 , apic_shift = 0 , id ;
532
537
unsigned threadid __hwloc_attribute_unused = 0 ; /* shut-up compiler */
@@ -573,12 +578,15 @@ static void read_intel_cores_exttopoenum(struct procinfo *infos, unsigned leaf,
573
578
infos -> ids [CORE ] = id ;
574
579
break ;
575
580
case 3 :
581
+ data -> found_module_ids = 1 ;
576
582
infos -> ids [MODULE ] = id ;
577
583
break ;
578
584
case 4 :
585
+ data -> found_tile_ids = 1 ;
579
586
infos -> ids [TILE ] = id ;
580
587
break ;
581
588
case 5 :
589
+ data -> found_die_ids = 1 ;
582
590
infos -> ids [DIE ] = id ;
583
591
break ;
584
592
case 6 :
@@ -736,21 +744,21 @@ static void look_proc(struct hwloc_backend *backend, struct procinfo *infos, uns
736
744
*
737
745
* Only needed when x2apic supported if NUMA nodes are needed.
738
746
*/
739
- read_amd_cores_topoext (infos , flags , src_cpuiddump );
747
+ read_amd_cores_topoext (data , infos , flags , src_cpuiddump );
740
748
}
741
749
742
750
if ((cpuid_type == intel ) && highest_cpuid >= 0x1f ) {
743
751
/* Get package/die/module/tile/core/thread information from cpuid 0x1f
744
752
* (Intel v2 Extended Topology Enumeration)
745
753
*/
746
- read_intel_cores_exttopoenum (infos , 0x1f , src_cpuiddump );
754
+ read_intel_cores_exttopoenum (data , infos , 0x1f , src_cpuiddump );
747
755
748
756
} else if ((cpuid_type == intel || cpuid_type == amd || cpuid_type == zhaoxin )
749
757
&& highest_cpuid >= 0x0b && has_x2apic (features )) {
750
758
/* Get package/core/thread information from cpuid 0x0b
751
759
* (Intel v1 Extended Topology Enumeration)
752
760
*/
753
- read_intel_cores_exttopoenum (infos , 0x0b , src_cpuiddump );
761
+ read_intel_cores_exttopoenum (data , infos , 0x0b , src_cpuiddump );
754
762
}
755
763
756
764
/**************************************
@@ -1051,21 +1059,27 @@ static void summarize(struct hwloc_backend *backend, struct procinfo *infos, uns
1051
1059
1052
1060
if (hwloc_filter_check_keep_object_type (topology , HWLOC_OBJ_GROUP )) {
1053
1061
if (fulldiscovery ) {
1054
- /* Look for AMD Compute units inside packages */
1055
- hwloc_bitmap_copy (remaining_cpuset , complete_cpuset );
1056
- hwloc_x86_add_groups (topology , infos , nbprocs , remaining_cpuset ,
1057
- UNIT , "Compute Unit" ,
1058
- HWLOC_GROUP_KIND_AMD_COMPUTE_UNIT , 0 );
1059
- /* Look for Intel Modules inside packages */
1060
- hwloc_bitmap_copy (remaining_cpuset , complete_cpuset );
1061
- hwloc_x86_add_groups (topology , infos , nbprocs , remaining_cpuset ,
1062
- MODULE , "Module" ,
1063
- HWLOC_GROUP_KIND_INTEL_MODULE , 0 );
1064
- /* Look for Intel Tiles inside packages */
1065
- hwloc_bitmap_copy (remaining_cpuset , complete_cpuset );
1066
- hwloc_x86_add_groups (topology , infos , nbprocs , remaining_cpuset ,
1067
- TILE , "Tile" ,
1068
- HWLOC_GROUP_KIND_INTEL_TILE , 0 );
1062
+ if (data -> found_unit_ids ) {
1063
+ /* Look for AMD Compute units inside packages */
1064
+ hwloc_bitmap_copy (remaining_cpuset , complete_cpuset );
1065
+ hwloc_x86_add_groups (topology , infos , nbprocs , remaining_cpuset ,
1066
+ UNIT , "Compute Unit" ,
1067
+ HWLOC_GROUP_KIND_AMD_COMPUTE_UNIT , 0 );
1068
+ }
1069
+ if (data -> found_module_ids ) {
1070
+ /* Look for Intel Modules inside packages */
1071
+ hwloc_bitmap_copy (remaining_cpuset , complete_cpuset );
1072
+ hwloc_x86_add_groups (topology , infos , nbprocs , remaining_cpuset ,
1073
+ MODULE , "Module" ,
1074
+ HWLOC_GROUP_KIND_INTEL_MODULE , 0 );
1075
+ }
1076
+ if (data -> found_tile_ids ) {
1077
+ /* Look for Intel Tiles inside packages */
1078
+ hwloc_bitmap_copy (remaining_cpuset , complete_cpuset );
1079
+ hwloc_x86_add_groups (topology , infos , nbprocs , remaining_cpuset ,
1080
+ TILE , "Tile" ,
1081
+ HWLOC_GROUP_KIND_INTEL_TILE , 0 );
1082
+ }
1069
1083
1070
1084
/* Look for unknown objects */
1071
1085
if (infos [one ].otherids ) {
@@ -1099,7 +1113,8 @@ static void summarize(struct hwloc_backend *backend, struct procinfo *infos, uns
1099
1113
}
1100
1114
}
1101
1115
1102
- if (hwloc_filter_check_keep_object_type (topology , HWLOC_OBJ_DIE )) {
1116
+ if (data -> found_die_ids
1117
+ && hwloc_filter_check_keep_object_type (topology , HWLOC_OBJ_DIE )) {
1103
1118
/* Look for Intel Dies inside packages */
1104
1119
if (fulldiscovery ) {
1105
1120
hwloc_bitmap_t die_cpuset ;
@@ -1838,6 +1853,10 @@ hwloc_x86_component_instantiate(struct hwloc_topology *topology,
1838
1853
data -> apicid_set = hwloc_bitmap_alloc ();
1839
1854
data -> apicid_unique = 1 ;
1840
1855
data -> src_cpuiddump_path = NULL ;
1856
+ data -> found_die_ids = 0 ;
1857
+ data -> found_unit_ids = 0 ;
1858
+ data -> found_module_ids = 0 ;
1859
+ data -> found_tile_ids = 0 ;
1841
1860
1842
1861
src_cpuiddump_path = getenv ("HWLOC_CPUID_PATH" );
1843
1862
if (src_cpuiddump_path ) {
0 commit comments