On Windows, how can I:
- query how many NUMA nodes the system has
- set affinity of an std::thread to the CPU cores of a specific NUMA node?
On Windows, how can I:
To get the index of the highest node:
auto highestnode = 0UL;
GetNumaHighestNodeNumber(&highestnode);
To get the affinity of all logical cores on a node for up to 64 total logical cores:
auto mask = 0ULL;
GetNumaNodeProcessorMask(nodeindex, &mask);
To set thread affinity:
SetThreadAffinityMask(GetCurrentThread(), mask);
Or for greater than 64 total logical cores:
auto node = static_cast<PGROUP_AFFINITY>(malloc(sizeof(PGROUP_AFFINITY)));;
GetNumaNodeProcessorMaskEx(nodeindex, node);
Where the mask for the node is nodes->Mask.
Large nodes with more than 64 logical cores will be split up into groups specified by nodes->Group.