From 9bf4c2c98f2d24bb673014d3166bbbf3bbd3bfa2 Mon Sep 17 00:00:00 2001 From: XMRig Date: Sat, 6 Jul 2019 11:31:12 +0700 Subject: [PATCH] Generate "rx" and "rx/wow" sections of CPU threads. --- src/backend/cpu/CpuConfig.cpp | 10 ++++++++++ src/backend/cpu/platform/AdvancedCpuInfo.cpp | 4 ++-- src/crypto/common/Algorithm.cpp | 14 ++++++++++---- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/backend/cpu/CpuConfig.cpp b/src/backend/cpu/CpuConfig.cpp index 34dcff44..b4a9c363 100644 --- a/src/backend/cpu/CpuConfig.cpp +++ b/src/backend/cpu/CpuConfig.cpp @@ -57,6 +57,11 @@ static const char *kCnHeavy = "cn-heavy"; static const char *kCnPico = "cn-pico"; #endif +#ifdef XMRIG_ALGO_RANDOMX +static const char *kRx = "rx"; +static const char *kRxWOW = "rx/wow"; +#endif + extern template class Threads; } @@ -135,6 +140,11 @@ void xmrig::CpuConfig::read(const rapidjson::Value &value) # ifdef XMRIG_ALGO_CN_PICO m_threads.move(kCnPico, Cpu::info()->threads(Algorithm::CN_PICO_0)); # endif + +# ifdef XMRIG_ALGO_RANDOMX + m_threads.move(kRx, Cpu::info()->threads(Algorithm::RX_0)); + m_threads.move(kRxWOW, Cpu::info()->threads(Algorithm::RX_WOW)); +# endif } } diff --git a/src/backend/cpu/platform/AdvancedCpuInfo.cpp b/src/backend/cpu/platform/AdvancedCpuInfo.cpp index 4c3b30ab..b5b2fe91 100644 --- a/src/backend/cpu/platform/AdvancedCpuInfo.cpp +++ b/src/backend/cpu/platform/AdvancedCpuInfo.cpp @@ -22,12 +22,11 @@ * along with this program. If not, see . */ +#include #include #include #include -#include - #include "backend/cpu/platform/AdvancedCpuInfo.h" @@ -144,6 +143,7 @@ xmrig::CpuThreads xmrig::AdvancedCpuInfo::threads(const Algorithm &algorithm) co if (cache) { cache *= 1024; const size_t memory = algorithm.memory(); + assert(memory > 0); count = cache / memory; diff --git a/src/crypto/common/Algorithm.cpp b/src/crypto/common/Algorithm.cpp index 4af3fd41..7680ef02 100644 --- a/src/crypto/common/Algorithm.cpp +++ b/src/crypto/common/Algorithm.cpp @@ -130,7 +130,10 @@ rapidjson::Value xmrig::Algorithm::toJSON() const size_t xmrig::Algorithm::memory() const { - if (family() < RANDOM_X) { + const Family f = family(); + assert(f != UNKNOWN); + + if (f < RANDOM_X) { return CnAlgo<>::memory(m_id); } @@ -138,7 +141,7 @@ size_t xmrig::Algorithm::memory() const return 0x100000; } - return 0; + return 0x200000; } @@ -181,12 +184,15 @@ xmrig::Algorithm::Family xmrig::Algorithm::family(Id id) # endif # ifdef XMRIG_ALGO_RANDOMX + case RX_0: case RX_WOW: + case RX_LOKI: return RANDOM_X; # endif - default: - break; + case INVALID: + case MAX: + return UNKNOWN; } return UNKNOWN;