diff --git a/src/workers/Handle.cpp b/src/workers/Handle.cpp index 29f57fb25..01d032e9b 100644 --- a/src/workers/Handle.cpp +++ b/src/workers/Handle.cpp @@ -25,7 +25,8 @@ #include "workers/Handle.h" -Handle::Handle(xmrig::IThread *config, size_t totalThreads, size_t totalWays) : +Handle::Handle(xmrig::IThread *config, size_t totalThreads, size_t totalWays, int64_t affinity) : + m_affinity(affinity), m_worker(nullptr), m_totalThreads(totalThreads), m_totalWays(totalWays), diff --git a/src/workers/Handle.h b/src/workers/Handle.h index b3a7c76f7..8a64922a5 100644 --- a/src/workers/Handle.h +++ b/src/workers/Handle.h @@ -38,10 +38,11 @@ class IWorker; class Handle { public: - Handle(xmrig::IThread *config, size_t totalThreads, size_t totalWays); + Handle(xmrig::IThread *config, size_t totalThreads, size_t totalWays, int64_t affinity); void join(); void start(void (*callback) (void *)); + inline int64_t affinity() const { return m_affinity; } inline IWorker *worker() const { return m_worker; } inline size_t threadId() const { return m_config->index(); } inline size_t totalThreads() const { return m_totalThreads; } @@ -50,6 +51,7 @@ public: inline xmrig::IThread *config() const { return m_config; } private: + int64_t m_affinity; IWorker *m_worker; size_t m_totalThreads; size_t m_totalWays; diff --git a/src/workers/Worker.cpp b/src/workers/Worker.cpp index bf4f62da7..f9162e3f6 100644 --- a/src/workers/Worker.cpp +++ b/src/workers/Worker.cpp @@ -42,9 +42,9 @@ Worker::Worker(Handle *handle) : m_sequence(0), m_thread(static_cast(handle->config())) { -// if (Cpu::threads() > 1 && handle->affinity() != -1L) { -// Cpu::setAffinity(m_id, handle->affinity()); -// } + if (Cpu::threads() > 1 && handle->affinity() != -1L) { + Cpu::setAffinity(m_id, handle->affinity()); + } Platform::setThreadPriority(handle->config()->priority()); m_ctx = Mem::create(m_id); diff --git a/src/workers/Workers.cpp b/src/workers/Workers.cpp index 00941c7be..38965d8ad 100644 --- a/src/workers/Workers.cpp +++ b/src/workers/Workers.cpp @@ -130,7 +130,7 @@ void Workers::start(xmrig::Controller *controller) uv_timer_start(&m_timer, Workers::onTick, 500, 500); for (xmrig::IThread *thread : threads) { - Handle *handle = new Handle(thread, threads.size(), totalWays); + Handle *handle = new Handle(thread, threads.size(), totalWays, controller->config()->affinity()); m_workers.push_back(handle); handle->start(Workers::onReady); }