--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.
| 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. |
| 111 | static 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 | |
| 133 | int main() { |
| 134 | if (!host_sibling_layout()) return 1; |
no test coverage detected