From 4583d979db793eabdaac399dd7fcae3f2cbd7c5a Mon Sep 17 00:00:00 2001 From: XMRig Date: Fri, 9 Aug 2019 12:51:27 +0700 Subject: [PATCH] Fixed auto configuration without hwloc. --- src/backend/cpu/CpuThreads.cpp | 10 +++++++ src/backend/cpu/CpuThreads.h | 1 + src/backend/cpu/platform/AdvancedCpuInfo.cpp | 14 +++++++--- src/backend/cpu/platform/BasicCpuInfo.cpp | 28 +++++++++++++++++--- 4 files changed, 46 insertions(+), 7 deletions(-) diff --git a/src/backend/cpu/CpuThreads.cpp b/src/backend/cpu/CpuThreads.cpp index 2e8b9e1fd..07e8ca33f 100644 --- a/src/backend/cpu/CpuThreads.cpp +++ b/src/backend/cpu/CpuThreads.cpp @@ -110,6 +110,16 @@ xmrig::CpuThreads::CpuThreads(const rapidjson::Value &value) } +xmrig::CpuThreads::CpuThreads(size_t count, int intensity) +{ + m_data.reserve(count); + + for (size_t i = 0; i < count; ++i) { + add(-1, intensity); + } +} + + rapidjson::Value xmrig::CpuThreads::toJSON(rapidjson::Document &doc) const { using namespace rapidjson; diff --git a/src/backend/cpu/CpuThreads.h b/src/backend/cpu/CpuThreads.h index 461cc1f28..f8ad64308 100644 --- a/src/backend/cpu/CpuThreads.h +++ b/src/backend/cpu/CpuThreads.h @@ -42,6 +42,7 @@ public: inline CpuThreads(size_t count) : m_data(count) {} CpuThreads(const rapidjson::Value &value); + CpuThreads(size_t count, int intensity); inline bool isEmpty() const { return m_data.empty(); } inline const std::vector &data() const { return m_data; } diff --git a/src/backend/cpu/platform/AdvancedCpuInfo.cpp b/src/backend/cpu/platform/AdvancedCpuInfo.cpp index f8871d3c1..de8ff2721 100644 --- a/src/backend/cpu/platform/AdvancedCpuInfo.cpp +++ b/src/backend/cpu/platform/AdvancedCpuInfo.cpp @@ -112,7 +112,7 @@ xmrig::AdvancedCpuInfo::AdvancedCpuInfo() : xmrig::CpuThreads xmrig::AdvancedCpuInfo::threads(const Algorithm &algorithm) const { if (threads() == 1) { - return CpuThreads(1); + return 1; } # ifdef XMRIG_ALGO_CN_GPU @@ -132,7 +132,7 @@ xmrig::CpuThreads xmrig::AdvancedCpuInfo::threads(const Algorithm &algorithm) co } if (cache) { - const size_t memory = algorithm.memory(); + const size_t memory = algorithm.l3(); assert(memory > 0); count = cache / memory; @@ -145,5 +145,13 @@ xmrig::CpuThreads xmrig::AdvancedCpuInfo::threads(const Algorithm &algorithm) co count = threads() / 2; } - return CpuThreads(std::max(std::min(count, threads()), 1)); + int intensity = algorithm.maxIntensity() == 1 ? -1 : 1; + +# ifdef XMRIG_ALGO_CN_PICO + if (algorithm == Algorithm::CN_PICO_0 && (count / cores()) >= 2) { + intensity = 2; + } +# endif + + return CpuThreads(std::max(std::min(count, threads()), 1), intensity); } diff --git a/src/backend/cpu/platform/BasicCpuInfo.cpp b/src/backend/cpu/platform/BasicCpuInfo.cpp index 49d4b0059..2f3177d2e 100644 --- a/src/backend/cpu/platform/BasicCpuInfo.cpp +++ b/src/backend/cpu/platform/BasicCpuInfo.cpp @@ -194,13 +194,33 @@ xmrig::CpuThreads xmrig::BasicCpuInfo::threads(const Algorithm &algorithm) const } # endif - if (algorithm.family() == Algorithm::CN_LITE || algorithm.family() == Algorithm::CN_PICO) { - return count; +# ifdef XMRIG_ALGO_CN_LITE + if (algorithm.family() == Algorithm::CN_LITE) { + return CpuThreads(count, 1); } +# endif +# ifdef XMRIG_ALGO_CN_PICO + if (algorithm.family() == Algorithm::CN_PICO) { + return CpuThreads(count, 2); + } +# endif + +# ifdef XMRIG_ALGO_CN_HEAVY if (algorithm.family() == Algorithm::CN_HEAVY) { - return std::max(count / 4, 1); + return CpuThreads(std::max(count / 4, 1), 1); } +# endif - return std::max(count / 2, 1); +# ifdef XMRIG_ALGO_RANDOMX + if (algorithm.family() == Algorithm::RANDOM_X) { + if (algorithm == Algorithm::RX_WOW) { + return count; + } + + return std::max(count / 2, 1); + } +# endif + + return CpuThreads(std::max(count / 2, 1), 1); }