Use hwloc for set thread affinity.

This commit is contained in:
XMRig 2019-10-06 14:40:42 +07:00
parent 9101469308
commit 72c9d94390
9 changed files with 118 additions and 38 deletions

View file

@ -46,8 +46,11 @@ uint32_t xmrig::VirtualMemory::bindToNUMANode(int64_t affinity)
return 0;
}
auto cpu = static_cast<HwlocCpuInfo *>(Cpu::info());
hwloc_obj_t pu = hwloc_get_pu_obj_by_os_index(cpu->topology(), static_cast<unsigned>(affinity));
auto cpu = static_cast<HwlocCpuInfo *>(Cpu::info());
hwloc_obj_t pu = hwloc_get_pu_obj_by_os_index(cpu->topology(), static_cast<unsigned>(affinity));
char *buffer;
hwloc_bitmap_asprintf(&buffer, pu->cpuset);
if (pu == nullptr || !cpu->membind(pu->nodeset)) {
LOG_WARN("CPU #%02" PRId64 " warning: \"can't bind memory\"", affinity);