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

Function cpu_numa_node_win

engine/src/kernels/cpu/pool.cpp:179–207  ·  view source on GitHub ↗

#6523: map a Windows encoded logical CPU (group * 64 + bit) to its NUMA node across ALL processor groups.

Source from the content-addressed store, hash-verified

177#if defined(_WIN32)
178// #6523: map a Windows encoded logical CPU (group * 64 + bit) to its NUMA node across ALL processor groups.
179static int cpu_numa_node_win(int cpu) {
180 if (cpu < 0) return -1;
181 static const std::vector<int> map = [] {
182 std::vector<int> m;
183 DWORD len = 0;
184 GetLogicalProcessorInformationEx(RelationNumaNode, nullptr, &len);
185 if (len == 0) return m;
186 std::vector<char> buf(len);
187 if (!GetLogicalProcessorInformationEx(RelationNumaNode,
188 reinterpret_cast<PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX>(buf.data()),
189 &len))
190 return m;
191 for (DWORD off = 0; off < len;) {
192 const auto* e = reinterpret_cast<const SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX*>(buf.data() + off);
193 if (e->Size == 0 || off + e->Size > len) break;
194 if (e->Relationship == RelationNumaNode) {
195 const int node = (int) e->NumaNode.NodeNumber;
196 const GROUP_AFFINITY& g = e->NumaNode.GroupMask;
197 const int base = (int) g.Group * 64;
198 if (g.Mask != 0 && base + 64 > (int) m.size()) m.resize((size_t) (base + 64), -1);
199 for (int bit = 0; bit < 64; ++bit)
200 if (g.Mask & (KAFFINITY(1) << bit)) m[(size_t) (base + bit)] = node;
201 }
202 off += e->Size;
203 }
204 return m;
205 }();
206 return cpu < (int) map.size() ? map[(size_t) cpu] : -1;
207}
208#endif
209
210static void fill_plan_fields(CpuTopology& topo, bool skip_first) {

Callers 2

fill_plan_fieldsFunction · 0.85
ExpertPoolMethod · 0.85

Calls 3

dataMethod · 0.45
sizeMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected