From 206b675892da33a5f5dbc69fa640c7b0d072f0b0 Mon Sep 17 00:00:00 2001 From: XMRig Date: Sun, 16 Aug 2020 17:36:38 +0700 Subject: [PATCH] Always use all available threads on ARM. --- src/backend/cpu/platform/HwlocCpuInfo.cpp | 28 ++++++++++++++++++++++- src/backend/cpu/platform/HwlocCpuInfo.h | 1 + 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/backend/cpu/platform/HwlocCpuInfo.cpp b/src/backend/cpu/platform/HwlocCpuInfo.cpp index 4a59c786..0d587332 100644 --- a/src/backend/cpu/platform/HwlocCpuInfo.cpp +++ b/src/backend/cpu/platform/HwlocCpuInfo.cpp @@ -218,10 +218,11 @@ xmrig::CpuThreads xmrig::HwlocCpuInfo::threads(const Algorithm &algorithm, uint3 { # ifdef XMRIG_ALGO_ASTROBWT if (algorithm == Algorithm::ASTROBWT_DERO) { - return BasicCpuInfo::threads(algorithm, limit); + return allThreads(algorithm, limit); } # endif +# ifndef XMRIG_ARM if (L2() == 0 && L3() == 0) { return BasicCpuInfo::threads(algorithm, limit); } @@ -263,11 +264,35 @@ xmrig::CpuThreads xmrig::HwlocCpuInfo::threads(const Algorithm &algorithm, uint3 } return threads; +# else + return allThreads(algorithm, limit); +# endif } +xmrig::CpuThreads xmrig::HwlocCpuInfo::allThreads(const Algorithm &algorithm, uint32_t limit) const +{ + CpuThreads threads; + threads.reserve(m_threads); + + hwloc_obj_t pu = nullptr; + + while ((pu = hwloc_get_next_obj_by_type(m_topology, HWLOC_OBJ_PU, pu)) != nullptr) { + threads.add(pu->os_index, 0); + } + + if (threads.isEmpty()) { + return BasicCpuInfo::threads(algorithm, limit); + } + + return threads; +} + + + void xmrig::HwlocCpuInfo::processTopLevelCache(hwloc_obj_t cache, const Algorithm &algorithm, CpuThreads &threads, size_t limit) const { +# ifndef XMRIG_ARM constexpr size_t oneMiB = 1024U * 1024U; size_t PUs = countByType(cache, HWLOC_OBJ_PU); @@ -366,4 +391,5 @@ void xmrig::HwlocCpuInfo::processTopLevelCache(hwloc_obj_t cache, const Algorith pu_id++; } +# endif } diff --git a/src/backend/cpu/platform/HwlocCpuInfo.h b/src/backend/cpu/platform/HwlocCpuInfo.h index 3746f151..eed3ae8b 100644 --- a/src/backend/cpu/platform/HwlocCpuInfo.h +++ b/src/backend/cpu/platform/HwlocCpuInfo.h @@ -70,6 +70,7 @@ protected: inline size_t packages() const override { return m_packages; } private: + CpuThreads allThreads(const Algorithm &algorithm, uint32_t limit) const; void processTopLevelCache(hwloc_obj_t obj, const Algorithm &algorithm, CpuThreads &threads, size_t limit) const;