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

@ -29,8 +29,8 @@
#include <uv.h>
#include "base/kernel/Platform.h"
#include "base/io/log/Log.h"
#include "Platform.h"
#include "version.h"
@ -51,10 +51,10 @@ static inline OSVERSIONINFOEX winOsVersion()
HMODULE ntdll = GetModuleHandleW(L"ntdll.dll");
if (ntdll ) {
RtlGetVersionFunction pRtlGetVersion = reinterpret_cast<RtlGetVersionFunction>(GetProcAddress(ntdll, "RtlGetVersion"));
auto pRtlGetVersion = reinterpret_cast<RtlGetVersionFunction>(GetProcAddress(ntdll, "RtlGetVersion"));
if (pRtlGetVersion) {
pRtlGetVersion((LPOSVERSIONINFO) &result);
pRtlGetVersion(reinterpret_cast<LPOSVERSIONINFO>(&result));
}
}
@ -62,7 +62,7 @@ static inline OSVERSIONINFOEX winOsVersion()
}
char *Platform::createUserAgent()
char *xmrig::Platform::createUserAgent()
{
const auto osver = winOsVersion();
constexpr const size_t max = 256;
@ -91,7 +91,8 @@ char *Platform::createUserAgent()
}
bool Platform::setThreadAffinity(uint64_t cpu_id)
#ifndef XMRIG_FEATURE_HWLOC
bool xmrig::Platform::setThreadAffinity(uint64_t cpu_id)
{
if (cpu_id >= 64) {
LOG_ERR("Unable to set affinity. Windows supports only affinity up to 63.");
@ -99,9 +100,10 @@ bool Platform::setThreadAffinity(uint64_t cpu_id)
return SetThreadAffinityMask(GetCurrentThread(), 1ULL << cpu_id) != 0;
}
#endif
uint32_t Platform::setTimerResolution(uint32_t resolution)
uint32_t xmrig::Platform::setTimerResolution(uint32_t resolution)
{
# ifdef XMRIG_AMD_PROJECT
TIMECAPS tc;
@ -119,7 +121,7 @@ uint32_t Platform::setTimerResolution(uint32_t resolution)
}
void Platform::restoreTimerResolution()
void xmrig::Platform::restoreTimerResolution()
{
# ifdef XMRIG_AMD_PROJECT
if (timerResolution) {
@ -129,7 +131,7 @@ void Platform::restoreTimerResolution()
}
void Platform::setProcessPriority(int priority)
void xmrig::Platform::setProcessPriority(int priority)
{
if (priority == -1) {
return;
@ -166,7 +168,7 @@ void Platform::setProcessPriority(int priority)
}
void Platform::setThreadPriority(int priority)
void xmrig::Platform::setThreadPriority(int priority)
{
if (priority == -1) {
return;