Skip to content

Commit 1623f38

Browse files
committed
x86: only try to build die objects and unit/tile/module groups if we found some info
Signed-off-by: Brice Goglin <[email protected]>
1 parent e3247e6 commit 1623f38

File tree

1 file changed

+40
-21
lines changed

1 file changed

+40
-21
lines changed

hwloc/topology-x86.c

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ struct hwloc_x86_backend_data_s {
3939
char *src_cpuiddump_path;
4040
int is_knl;
4141
int is_hybrid;
42+
int found_die_ids;
43+
int found_unit_ids;
44+
int found_module_ids;
45+
int found_tile_ids;
4246
};
4347

4448
/************************************
@@ -481,7 +485,7 @@ static void read_amd_cores_legacy(struct procinfo *infos, struct cpuiddump *src_
481485
}
482486

483487
/* 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)
485489
{
486490
unsigned apic_id, nodes_per_proc = 0;
487491
unsigned eax, ebx, ecx, edx;
@@ -511,6 +515,7 @@ static void read_amd_cores_topoext(struct procinfo *infos, unsigned long flags,
511515
unsigned cores_per_unit;
512516
/* coreid was obtained from read_amd_cores_legacy() earlier */
513517
infos->ids[UNIT] = ebx & 0xff;
518+
data->found_unit_ids = 1;
514519
cores_per_unit = ((ebx >> 8) & 0xff) + 1;
515520
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]);
516521
/* 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,
526531
}
527532

528533
/* 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)
530535
{
531536
unsigned level, apic_nextshift, apic_type, apic_id = 0, apic_shift = 0, id;
532537
unsigned threadid __hwloc_attribute_unused = 0; /* shut-up compiler */
@@ -573,12 +578,15 @@ static void read_intel_cores_exttopoenum(struct procinfo *infos, unsigned leaf,
573578
infos->ids[CORE] = id;
574579
break;
575580
case 3:
581+
data->found_module_ids = 1;
576582
infos->ids[MODULE] = id;
577583
break;
578584
case 4:
585+
data->found_tile_ids = 1;
579586
infos->ids[TILE] = id;
580587
break;
581588
case 5:
589+
data->found_die_ids = 1;
582590
infos->ids[DIE] = id;
583591
break;
584592
case 6:
@@ -736,21 +744,21 @@ static void look_proc(struct hwloc_backend *backend, struct procinfo *infos, uns
736744
*
737745
* Only needed when x2apic supported if NUMA nodes are needed.
738746
*/
739-
read_amd_cores_topoext(infos, flags, src_cpuiddump);
747+
read_amd_cores_topoext(data, infos, flags, src_cpuiddump);
740748
}
741749

742750
if ((cpuid_type == intel) && highest_cpuid >= 0x1f) {
743751
/* Get package/die/module/tile/core/thread information from cpuid 0x1f
744752
* (Intel v2 Extended Topology Enumeration)
745753
*/
746-
read_intel_cores_exttopoenum(infos, 0x1f, src_cpuiddump);
754+
read_intel_cores_exttopoenum(data, infos, 0x1f, src_cpuiddump);
747755

748756
} else if ((cpuid_type == intel || cpuid_type == amd || cpuid_type == zhaoxin)
749757
&& highest_cpuid >= 0x0b && has_x2apic(features)) {
750758
/* Get package/core/thread information from cpuid 0x0b
751759
* (Intel v1 Extended Topology Enumeration)
752760
*/
753-
read_intel_cores_exttopoenum(infos, 0x0b, src_cpuiddump);
761+
read_intel_cores_exttopoenum(data, infos, 0x0b, src_cpuiddump);
754762
}
755763

756764
/**************************************
@@ -1051,21 +1059,27 @@ static void summarize(struct hwloc_backend *backend, struct procinfo *infos, uns
10511059

10521060
if (hwloc_filter_check_keep_object_type(topology, HWLOC_OBJ_GROUP)) {
10531061
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+
}
10691083

10701084
/* Look for unknown objects */
10711085
if (infos[one].otherids) {
@@ -1099,7 +1113,8 @@ static void summarize(struct hwloc_backend *backend, struct procinfo *infos, uns
10991113
}
11001114
}
11011115

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)) {
11031118
/* Look for Intel Dies inside packages */
11041119
if (fulldiscovery) {
11051120
hwloc_bitmap_t die_cpuset;
@@ -1838,6 +1853,10 @@ hwloc_x86_component_instantiate(struct hwloc_topology *topology,
18381853
data->apicid_set = hwloc_bitmap_alloc();
18391854
data->apicid_unique = 1;
18401855
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;
18411860

18421861
src_cpuiddump_path = getenv("HWLOC_CPUID_PATH");
18431862
if (src_cpuiddump_path) {

0 commit comments

Comments
 (0)