MCPcopy Create free account
hub / github.com/Niko1221/Strata / host_sibling_layout

Function host_sibling_layout

engine/src/kernels/cpu/pool_affinity_test.cpp:111–131  ·  view source on GitHub ↗

--host-core sibling: the host on the first layout's host core's SMT sibling, which no worker takes, and the first logical processor left to nothing; `first` on a core without SMT. Every affinity mode.

Source from the content-addressed store, hash-verified

109// --host-core sibling: the host on the first layout's host core's SMT sibling, which no worker takes, and the first
110// logical processor left to nothing; `first` on a core without SMT. Every affinity mode.
111static bool host_sibling_layout() {
112 bool ok = true;
113 for (const auto affinity : {cpu::PoolAffinity::All, cpu::PoolAffinity::Auto, cpu::PoolAffinity::PCores}) {
114 cpu::set_host_core(cpu::HostCore::First);
115 const cpu::CpuTopology first = cpu::detect_cpu_topology(true, affinity);
116 cpu::set_host_core(cpu::HostCore::Sibling);
117 const cpu::CpuTopology sib = cpu::detect_cpu_topology(true, affinity);
118 cpu::set_host_core(cpu::HostCore::First);
119 const auto has = [&](int core) {
120 return std::find(sib.worker_cores.begin(), sib.worker_cores.end(), core) != sib.worker_cores.end();
121 };
122 if (first.host_sibling < 0)
123 ok = check(sib.host_core == first.host_core && sib.worker_cores == first.worker_cores,
124 "--host-core sibling without SMT must be first") && ok;
125 else
126 ok = check(sib.host_core == first.host_sibling && sib.host_core != first.host_core && !has(sib.host_core) &&
127 !has(first.host_core),
128 "--host-core sibling: the host on the sibling, no worker on its core") && ok;
129 }
130 return ok;
131}
132
133int main() {
134 if (!host_sibling_layout()) return 1;

Callers 1

mainFunction · 0.85

Calls 7

set_host_coreFunction · 0.70
detect_cpu_topologyFunction · 0.70
checkFunction · 0.70
findFunction · 0.50
hasFunction · 0.50
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected