Skip to content

Commit d4123b8

Browse files
committed
Quick fix, temporary use old style affinity.
1 parent dd6bc33 commit d4123b8

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

src/workers/Handle.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
#include "workers/Handle.h"
2626

2727

28-
Handle::Handle(xmrig::IThread *config, size_t totalThreads, size_t totalWays) :
28+
Handle::Handle(xmrig::IThread *config, size_t totalThreads, size_t totalWays, int64_t affinity) :
29+
m_affinity(affinity),
2930
m_worker(nullptr),
3031
m_totalThreads(totalThreads),
3132
m_totalWays(totalWays),

src/workers/Handle.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ class IWorker;
3838
class Handle
3939
{
4040
public:
41-
Handle(xmrig::IThread *config, size_t totalThreads, size_t totalWays);
41+
Handle(xmrig::IThread *config, size_t totalThreads, size_t totalWays, int64_t affinity);
4242
void join();
4343
void start(void (*callback) (void *));
4444

45+
inline int64_t affinity() const { return m_affinity; }
4546
inline IWorker *worker() const { return m_worker; }
4647
inline size_t threadId() const { return m_config->index(); }
4748
inline size_t totalThreads() const { return m_totalThreads; }
@@ -50,6 +51,7 @@ class Handle
5051
inline xmrig::IThread *config() const { return m_config; }
5152

5253
private:
54+
int64_t m_affinity;
5355
IWorker *m_worker;
5456
size_t m_totalThreads;
5557
size_t m_totalWays;

src/workers/Worker.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ Worker::Worker(Handle *handle) :
4242
m_sequence(0),
4343
m_thread(static_cast<xmrig::CpuThread *>(handle->config()))
4444
{
45-
// if (Cpu::threads() > 1 && handle->affinity() != -1L) {
46-
// Cpu::setAffinity(m_id, handle->affinity());
47-
// }
45+
if (Cpu::threads() > 1 && handle->affinity() != -1L) {
46+
Cpu::setAffinity(m_id, handle->affinity());
47+
}
4848

4949
Platform::setThreadPriority(handle->config()->priority());
5050
m_ctx = Mem::create(m_id);

src/workers/Workers.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ void Workers::start(xmrig::Controller *controller)
130130
uv_timer_start(&m_timer, Workers::onTick, 500, 500);
131131

132132
for (xmrig::IThread *thread : threads) {
133-
Handle *handle = new Handle(thread, threads.size(), totalWays);
133+
Handle *handle = new Handle(thread, threads.size(), totalWays, controller->config()->affinity());
134134
m_workers.push_back(handle);
135135
handle->start(Workers::onReady);
136136
}

0 commit comments

Comments
 (0)