From 7901f6e364a2d3016d12232675db8a3746ba9bf1 Mon Sep 17 00:00:00 2001 From: Thomas Roehl Date: Fri, 15 Nov 2024 16:42:01 +0100 Subject: [PATCH] Fix detection of CPU dies --- src/applications/likwid-topology.lua | 1 + src/topology_hwloc.c | 70 ++++++++++++++++------------ 2 files changed, 42 insertions(+), 29 deletions(-) diff --git a/src/applications/likwid-topology.lua b/src/applications/likwid-topology.lua index 436a80870..36d0c92f2 100644 --- a/src/applications/likwid-topology.lua +++ b/src/applications/likwid-topology.lua @@ -144,6 +144,7 @@ table.insert(output_csv, "STRUCT,Hardware Thread Topology,3") table.insert(output_csv, "Hardware Thread Topology") table.insert(output_csv, likwid.sline) table.insert(output_csv, string.format("Sockets:\t\t%u",cputopo["numSockets"])) +table.insert(output_csv, string.format("CPU dies:\t\t%u",cputopo["numDies"])) table.insert(output_csv, string.format("Cores per socket:\t%u",cputopo["numCoresPerSocket"])) table.insert(output_csv, string.format("Threads per core:\t%u",cputopo["numThreadsPerCore"])) table.insert(output_csv, likwid.hline) diff --git a/src/topology_hwloc.c b/src/topology_hwloc.c index 7e3dd363f..2c9baeebd 100644 --- a/src/topology_hwloc.c +++ b/src/topology_hwloc.c @@ -387,6 +387,7 @@ hwloc_init_nodeTopology(cpu_set_t cpuSet) int consecutive_cores = -1; int from_file = (getenv("HWLOC_FSROOT") != NULL); hwloc_obj_type_t socket_type = HWLOC_OBJ_SOCKET; + hwloc_obj_type_t die_type = HWLOC_OBJ_DIE; if (!from_file) { for (uint32_t i=0;itype != HWLOC_OBJ_DIE) { - obj = obj->parent; - if (!obj) - { - skip = 1; - break; - } - } - if (skip) - { - hwThreadPool[id].dieId = 0; - continue; - } - if (obj->type == HWLOC_OBJ_DIE) - { - hwThreadPool[id].dieId = obj->os_index; - } - else - { - hwThreadPool[id].dieId = 0; - } - } - else - { - hwThreadPool[id].dieId = 0; - } while (obj->type != socket_type) { obj = obj->parent; if (!obj) @@ -567,6 +545,40 @@ hwloc_init_nodeTopology(cpu_set_t cpuSet) #else hwThreadPool[id].packageId = obj->os_index; #endif + if (maxNumSockets < maxNumDies) + { + printf("Searching for socket of die\n"); + hwloc_obj_t t = obj->parent; + while (t->type != die_type) { + t = t->parent; + if (!t) + { + printf("Cannot find type %d\n", die_type); + skip = 1; + break; + } + } + if (skip) + { + printf("setting die id = 0\n"); + hwThreadPool[id].dieId = 0; + continue; + } + if (t->type == die_type) + { + printf("setting die id = %d\n", t->os_index); + hwThreadPool[id].dieId = t->os_index; + } + else + { + printf("setting die id = 0 (else)\n"); + hwThreadPool[id].dieId = 0; + } + } + else + { + hwThreadPool[id].dieId = 0; + } DEBUG_PRINT(DEBUGLEV_DEVELOP, HWLOC Thread Pool PU %d Thread %d Core %d Die %d Socket %d inCpuSet %d, hwThreadPool[id].apicId, hwThreadPool[id].threadId,