Skip to content

Commit 6ae7cb3

Browse files
committed
cpu: xbyak: workaround smt identification
This commit partially reverts a6e933a to remove division by number of smt units because it may be incorrect. The getNumCores, setCacheHierarchy and setNumCores functions should be checked and fixed. The number of cores sharing L3 cache is identified incorrectly for some configurations.
1 parent f7e7c95 commit 6ae7cb3

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/cpu/xbyak/xbyak_util.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,6 @@ class Cpu {
162162
|| level_type == core_level)
163163
n_cores[level_type - 1] = extractBit(data[1], 0, 15);
164164
}
165-
if (n_cores[smt_level - 1] != 0)
166-
n_cores[core_level - 1] /= n_cores[smt_level - 1];
167165
} else {
168166
/* Failed to deremine num of cores without x2APIC support.
169167
TODO: USE initial APIC ID to determine ncores. */
@@ -213,6 +211,8 @@ class Cpu {
213211
* (data[2] + 1);
214212
if (cacheType == DATA_CACHE && smt_width == 0) smt_width = actual_logical_cores;
215213
assert(smt_width != 0);
214+
// FIXME: check and fix number of cores sharing L3 cache for different configurations
215+
// (HT-, 2 sockets), (HT-, 1 socket), (HT+, 2 sockets), (HT+, 1 socket)
216216
cores_sharing_data_cache[data_cache_levels] = (std::max)(actual_logical_cores / smt_width, 1u);
217217
data_cache_levels++;
218218
}
@@ -243,7 +243,9 @@ class Cpu {
243243
if (topology_level != smt_level
244244
&& topology_level != core_level) throw Error(ERR_BAD_PARAMETER);
245245
if (!x2APIC_supported) throw Error(ERR_x2APIC_NOT_SUPPORTED_CANT_GET_NCORES);
246-
return n_cores[topology_level - 1];
246+
return (topology_level == core_level)
247+
? n_cores[topology_level - 1] / n_cores[smt_level - 1]
248+
: n_cores[topology_level - 1];
247249
}
248250

249251
unsigned int getDataCacheLevels() const { return data_cache_levels; }

0 commit comments

Comments
 (0)