cpu pool: --host-core sibling, the host on the first core's other hardware thread (hybrid CPUs too)

Windows sends a GPU's interrupts to one logical processor, usually the first,
and the host thread spins there (--host-core first, the default). --host-core
last moves it to the last physical core, but not on a hybrid CPU, whose first
core is its best P-core, so a 12th-14th gen Intel or a Core Ultra keeps the
host on logical processor 0 with the interrupts.

--host-core sibling (or STRATA_HOST_CORE=sibling) keeps the host on that same
first core but on its other hardware thread. The interrupts keep the first
logical processor, which nothing else is pinned to, and the workers keep
every other core, since they take one logical processor per core (with
--pool-affinity auto / p-cores, which also use the P-cores' siblings, the
host's sibling is taken out of their list). Without an SMT sibling it is
--host-core first. It works the same on Linux (the sibling from sysfs), where
the interrupts are usually spread anyway.

detect_cpu_topology records the host core's sibling (CpuTopology::host_sibling)
in each layout; pool_affinity_test checks, in every affinity mode, that
sibling puts the host there with no worker on its core, and that it is first
without SMT. The startup log names the placement.
This commit is contained in:
Francesco Albano authored and Niko1221 committed 2026-10-14 07:08:35 +02:00
1 parent 1ab0fbd02a
commit 051b970303
6 files changed
+77 -13

No files matched your search

+11 -5
View File
@@ -441,7 +441,7 @@ struct Options {
/// --pool-affinity measure (opt-in, hybrid CPUs, native packs): `all` and `p-cores` are timed on this pack's
/// own experts at start and the faster layout is taken (measure_pool_affinity)
bool pool_measure = false;
/// --host-core first|last (STRATA_HOST_CORE): the host thread's core (see HostCore in pool.hpp)
/// --host-core first|last|sibling (STRATA_HOST_CORE): the host thread's core (see HostCore in pool.hpp)
std::string host_core;
/// --aux-cpus off|auto|LIST (STRATA_AUX_CPUS): where the non-pool, non-host threads run (strata/platform/aux_cpus.hpp)
std::string aux_cpus;
@@ -915,7 +915,9 @@ void usage() {
" last (the last physical core, the workers on the others). Windows sends a GPU's\n"
" interrupts to one logical processor, usually the first, and every copy that lands\n"
" raises one: a spinning host there waits for them. Moves threads only, never a\n"
" result. Not on hybrid CPUs (STRATA_HOST_CORE sets it too).\n"
" result. Not on hybrid CPUs. sibling: the first core's other hardware thread\n"
" (SMT), so the interrupts keep the first logical processor and the workers keep\n"
" every core; hybrid CPUs too, first without SMT (STRATA_HOST_CORE sets it too).\n"
" --aux-cpus SET Where the threads that are neither pool workers nor the host thread run (the\n"
" adaptive tier's job thread, the prefill helpers, the CUDA driver's threads, ...):\n"
" off (the default: wherever they were created), auto (the SMT siblings of the host's\n"
@@ -2092,8 +2094,9 @@ int main(int argc, char** argv) {
}
else if (a == "--host-core") {
o.host_core = next("--host-core");
if (o.host_core != "first" && o.host_core != "last") {
std::fprintf(stderr, "strata generate: unknown --host-core value '%s' (expected first or last)\n", o.host_core.c_str());
if (o.host_core != "first" && o.host_core != "last" && o.host_core != "sibling") {
std::fprintf(stderr, "strata generate: unknown --host-core value '%s' (expected first, last or sibling)\n",
o.host_core.c_str());
return 2;
}
}
@@ -2398,6 +2401,7 @@ int main(int argc, char** argv) {
if (hc.empty())
if (const char* e = std::getenv("STRATA_HOST_CORE")) hc = e;
if (hc == "last") strata::kernels::cpu::set_host_core(strata::kernels::cpu::HostCore::Last);
if (hc == "sibling") strata::kernels::cpu::set_host_core(strata::kernels::cpu::HostCore::Sibling);
}
{ // --aux-cpus / STRATA_AUX_CPUS: read the CPUs this process may use now, before any thread is pinned; the plan
// follows once the pool exists (it needs the workers' CPUs)
@@ -5175,7 +5179,9 @@ int main(int argc, char** argv) {
std::fprintf(stderr, "strata generate: %d pool workers on logical processors %s, the host thread on %d%s "
"(--host-core %s)\n", pool.workers(), on.c_str(), ht.host_core,
pool.host_works() ? " (draining too)" : "",
strata::kernels::cpu::host_core_setting() == strata::kernels::cpu::HostCore::Last ? "last" : "first");
strata::kernels::cpu::host_core_setting() == strata::kernels::cpu::HostCore::Last ? "last"
: strata::kernels::cpu::host_core_setting() == strata::kernels::cpu::HostCore::Sibling ? "sibling"
: "first");
// --aux-cpus: the plan, now the workers' CPUs are known; the threads that exist already (the CUDA driver's) move
// now when it is on, the ones created later pin themselves (strata/platform/aux_cpus.hpp)
const size_t nw = std::min<size_t>((size_t) pool.workers(), ht.worker_cores.size());