diff --git a/src/backend/common/GpuWorker.h b/src/backend/common/GpuWorker.h index 3c828e528..462cf6fad 100644 --- a/src/backend/common/GpuWorker.h +++ b/src/backend/common/GpuWorker.h @@ -49,6 +49,8 @@ protected: std::atomic m_index = {}; uint64_t m_hashCount[2] = {}; uint64_t m_timestamp[2] = {}; + + uint64_t m_count = 0; }; diff --git a/src/backend/common/Worker.h b/src/backend/common/Worker.h index cc1a0e2ec..23056b752 100644 --- a/src/backend/common/Worker.h +++ b/src/backend/common/Worker.h @@ -39,8 +39,6 @@ protected: inline size_t id() const override { return m_id; } inline uint32_t node() const { return m_node; } - std::atomic m_count = {0}; - private: const int64_t m_affinity; const size_t m_id; diff --git a/src/backend/cpu/CpuWorker.cpp b/src/backend/cpu/CpuWorker.cpp index 3ff312254..014247481 100644 --- a/src/backend/cpu/CpuWorker.cpp +++ b/src/backend/cpu/CpuWorker.cpp @@ -219,8 +219,8 @@ bool xmrig::CpuWorker::selfTest() template void xmrig::CpuWorker::hashrateData(uint64_t &hashCount, uint64_t &, uint64_t &rawHashes) const { - hashCount = m_count; - rawHashes = m_count; + hashCount = m_count.load(std::memory_order_relaxed); + rawHashes = hashCount; } @@ -332,7 +332,8 @@ void xmrig::CpuWorker::start() JobResults::submit(job, current_job_nonces[i], m_hash + (i * 32), job.hasMinerSignature() ? miner_signature_saved : nullptr); } } - m_count += N; + + m_count.fetch_add(N, std::memory_order_relaxed); } if (m_yield) { diff --git a/src/backend/cpu/CpuWorker.h b/src/backend/cpu/CpuWorker.h index 487b20cc0..65274d6dd 100644 --- a/src/backend/cpu/CpuWorker.h +++ b/src/backend/cpu/CpuWorker.h @@ -90,6 +90,8 @@ private: # ifdef XMRIG_FEATURE_BENCHMARK uint32_t m_benchSize = 0; # endif + + std::atomic m_count = {0}; };