Fix nonce allocation in DoubleWorker.

This commit is contained in:
XMRig 2018-04-03 03:27:44 +07:00
parent c1bc6acd26
commit d7c5630509
9 changed files with 14 additions and 9 deletions

View file

@ -136,7 +136,7 @@ int App::exec()
m_httpd->start();
# endif
Workers::start(m_controller->config()->affinity(), m_controller->config()->priority(), m_controller);
Workers::start(m_controller);
m_controller->network()->connect();

View file

@ -46,7 +46,7 @@ bool Mem::allocate(int algo, int threads, bool doubleHash, bool enabled)
m_threads = threads;
m_doubleHash = doubleHash;
const int ratio = (doubleHash && algo != xmrig::ALGO_CRYPTONIGHT_LITE) ? 2 : 1;
const int ratio = (doubleHash && algo != xmrig::CRYPTONIGHT_LITE) ? 2 : 1;
m_size = MONERO_MEMORY * (threads * ratio + 1);
if (!enabled) {

View file

@ -135,11 +135,11 @@ void DoubleWorker::consumeJob()
if (m_state->job.isNicehash()) {
m_state->nonce1 = (*Job::nonce(m_state->blob) & 0xff000000U) + (0xffffffU / m_totalWays * m_id);
m_state->nonce2 = (*Job::nonce(m_state->blob + m_state->job.size()) & 0xff000000U) + (0xffffffU / m_totalWays * (m_id + m_totalWays));
m_state->nonce2 = (*Job::nonce(m_state->blob + m_state->job.size()) & 0xff000000U) + (0xffffffU / m_totalWays * (m_id + m_totalThreads));
}
else {
m_state->nonce1 = 0xffffffffU / m_totalWays * m_id;
m_state->nonce2 = 0xffffffffU / m_totalWays * (m_id + m_totalWays);
m_state->nonce2 = 0xffffffffU / m_totalWays * (m_id + m_totalThreads);
}
}

View file

@ -25,8 +25,9 @@
#include "workers/Handle.h"
Handle::Handle(xmrig::IThread *config, size_t totalWays) :
Handle::Handle(xmrig::IThread *config, size_t totalThreads, size_t totalWays) :
m_worker(nullptr),
m_totalThreads(totalThreads),
m_totalWays(totalWays),
m_config(config)
{

View file

@ -38,18 +38,20 @@ class IWorker;
class Handle
{
public:
Handle(xmrig::IThread *config, size_t totalWays);
Handle(xmrig::IThread *config, size_t totalThreads, size_t totalWays);
void join();
void start(void (*callback) (void *));
inline IWorker *worker() const { return m_worker; }
inline size_t threadId() const { return m_config->index(); }
inline size_t totalThreads() const { return m_totalThreads; }
inline size_t totalWays() const { return m_totalWays; }
inline void setWorker(IWorker *worker) { m_worker = worker; }
inline xmrig::IThread *config() const { return m_config; }
private:
IWorker *m_worker;
size_t m_totalThreads;
size_t m_totalWays;
uv_thread_t m_thread;
xmrig::IThread *m_config;

View file

@ -34,6 +34,7 @@
Worker::Worker(Handle *handle) :
m_id(handle->threadId()),
m_totalThreads(handle->totalThreads()),
m_totalWays(handle->totalWays()),
m_hashCount(0),
m_timestamp(0),

View file

@ -55,6 +55,7 @@ protected:
cryptonight_ctx *m_ctx;
size_t m_id;
size_t m_totalThreads;
size_t m_totalWays;
std::atomic<uint64_t> m_hashCount;
std::atomic<uint64_t> m_timestamp;

View file

@ -107,7 +107,7 @@ void Workers::setJob(const Job &job, bool donate)
}
void Workers::start(int64_t affinity, int priority, xmrig::Controller *controller)
void Workers::start(xmrig::Controller *controller)
{
const std::vector<xmrig::IThread *> &threads = controller->config()->threads();
@ -129,7 +129,7 @@ void Workers::start(int64_t affinity, int priority, xmrig::Controller *controlle
uv_timer_start(&m_timer, Workers::onTick, 500, 500);
for (xmrig::IThread *thread : threads) {
Handle *handle = new Handle(thread, totalWays);
Handle *handle = new Handle(thread, threads.size(), totalWays);
m_workers.push_back(handle);
handle->start(Workers::onReady);
}

View file

@ -51,7 +51,7 @@ public:
static void printHashrate(bool detail);
static void setEnabled(bool enabled);
static void setJob(const Job &job, bool donate);
static void start(int64_t affinity, int priority, xmrig::Controller *controller);
static void start(xmrig::Controller *controller);
static void stop();
static void submit(const JobResult &result);