From 5b4648339a9945f9999b3066114a21fafa9fcbcb Mon Sep 17 00:00:00 2001 From: cohcho Date: Thu, 15 Oct 2020 14:56:37 +0000 Subject: [PATCH] WorkerJob: fix calls of add/nextRound WorkerJob::nextRound() doesn't require roundSize to be power of 2 Use CudaWorker::intensity(), OclWorker::intensity() to get device batch size Sync nonce and device iteration --- src/backend/cuda/CudaWorker.cpp | 19 ++----------------- src/backend/opencl/OclWorker.cpp | 19 ++----------------- src/backend/opencl/OclWorker.h | 1 - 3 files changed, 4 insertions(+), 35 deletions(-) diff --git a/src/backend/cuda/CudaWorker.cpp b/src/backend/cuda/CudaWorker.cpp index c0a4f9333..7bb8844c1 100644 --- a/src/backend/cuda/CudaWorker.cpp +++ b/src/backend/cuda/CudaWorker.cpp @@ -64,19 +64,6 @@ std::atomic CudaWorker::ready; static inline bool isReady() { return !Nonce::isPaused() && CudaWorker::ready; } -static inline uint32_t roundSize(uint32_t intensity) -{ -#ifdef _MSC_VER - unsigned long index; - _BitScanReverse(&index, intensity - 1); - const uint32_t n = 31 - index; -#else - const uint32_t n = __builtin_clz(intensity - 1); -#endif - return 1U << (32 - n); -} - - } // namespace xmrig @@ -188,8 +175,7 @@ void xmrig::CudaWorker::start() JobResults::submit(m_job.currentJob(), foundNonce, foundCount, m_deviceIndex); } - const size_t batch_size = intensity(); - if (!Nonce::isOutdated(Nonce::CUDA, m_job.sequence()) && !m_job.nextRound(1, roundSize(batch_size))) { + if (!Nonce::isOutdated(Nonce::CUDA, m_job.sequence()) && !m_job.nextRound(1, intensity())) { JobResults::done(m_job.currentJob()); } @@ -210,8 +196,7 @@ bool xmrig::CudaWorker::consumeJob() return false; } - const size_t batch_size = intensity(); - m_job.add(m_miner->job(), roundSize(batch_size), Nonce::CUDA); + m_job.add(m_miner->job(), intensity(), Nonce::CUDA); return m_runner->set(m_job.currentJob(), m_job.blob()); } diff --git a/src/backend/opencl/OclWorker.cpp b/src/backend/opencl/OclWorker.cpp index bf5a7e14f..ac493ab55 100644 --- a/src/backend/opencl/OclWorker.cpp +++ b/src/backend/opencl/OclWorker.cpp @@ -61,18 +61,6 @@ std::atomic OclWorker::ready; static inline bool isReady() { return !Nonce::isPaused() && OclWorker::ready; } -static inline uint32_t roundSize(uint32_t intensity) -{ -#ifdef _MSC_VER - unsigned long index; - _BitScanReverse(&index, intensity - 1); - const uint32_t n = 31 - index; -#else - const uint32_t n = __builtin_clz(intensity - 1); -#endif - return 1U << (32 - n); -} - static inline void printError(size_t id, const char *error) { @@ -88,7 +76,6 @@ xmrig::OclWorker::OclWorker(size_t id, const OclLaunchData &data) : Worker(id, data.affinity, -1), m_algorithm(data.algorithm), m_miner(data.miner), - m_intensity(data.thread.intensity()), m_sharedData(OclSharedState::get(data.device.index())), m_deviceIndex(data.device.index()) { @@ -180,8 +167,6 @@ void xmrig::OclWorker::start() { cl_uint results[0x100]; - const uint32_t runnerRoundSize = roundSize(m_runner->roundSize()); - while (Nonce::sequence(Nonce::OPENCL) > 0) { if (!isReady()) { m_sharedData.setResumeCounter(0); @@ -220,7 +205,7 @@ void xmrig::OclWorker::start() JobResults::submit(m_job.currentJob(), results, results[0xFF], m_deviceIndex); } - if (!Nonce::isOutdated(Nonce::OPENCL, m_job.sequence()) && !m_job.nextRound(1, runnerRoundSize)) { + if (!Nonce::isOutdated(Nonce::OPENCL, m_job.sequence()) && !m_job.nextRound(1, intensity())) { JobResults::done(m_job.currentJob()); } @@ -241,7 +226,7 @@ bool xmrig::OclWorker::consumeJob() return false; } - m_job.add(m_miner->job(), roundSize(m_intensity), Nonce::OPENCL); + m_job.add(m_miner->job(), intensity(), Nonce::OPENCL); try { m_runner->set(m_job.currentJob(), m_job.blob()); diff --git a/src/backend/opencl/OclWorker.h b/src/backend/opencl/OclWorker.h index c62dc27c0..403a0765d 100644 --- a/src/backend/opencl/OclWorker.h +++ b/src/backend/opencl/OclWorker.h @@ -67,7 +67,6 @@ private: const Algorithm m_algorithm; const Miner *m_miner; - const uint32_t m_intensity; IOclRunner *m_runner = nullptr; OclSharedData &m_sharedData; WorkerJob<1> m_job;