From a680220d28f187ddd3f9b176a5da037ba59531c1 Mon Sep 17 00:00:00 2001 From: XMRig Date: Wed, 2 Aug 2017 18:59:24 +0300 Subject: [PATCH] Fixed autoconf mode for AMD FX CPUs. --- src/Cpu.cpp | 27 ++++++++++++++++++--------- src/Cpu.h | 1 + src/config.json | 2 +- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/Cpu.cpp b/src/Cpu.cpp index 2f0a1195..e8f7ee17 100644 --- a/src/Cpu.cpp +++ b/src/Cpu.cpp @@ -29,13 +29,14 @@ #include "Cpu.h" -char Cpu::m_brand[64] = { 0 }; -int Cpu::m_flags = 0; -int Cpu::m_l2_cache = 0; -int Cpu::m_l3_cache = 0; -int Cpu::m_sockets = 1; -int Cpu::m_totalCores = 0; -int Cpu::m_totalThreads = 0; +bool Cpu::m_l2_exclusive = false; +char Cpu::m_brand[64] = { 0 }; +int Cpu::m_flags = 0; +int Cpu::m_l2_cache = 0; +int Cpu::m_l3_cache = 0; +int Cpu::m_sockets = 1; +int Cpu::m_totalCores = 0; +int Cpu::m_totalThreads = 0; int Cpu::optimalThreadsCount(int algo, bool doubleHash, int maxCpuUsage) @@ -44,7 +45,14 @@ int Cpu::optimalThreadsCount(int algo, bool doubleHash, int maxCpuUsage) return 1; } - int cache = m_l3_cache ? m_l3_cache : m_l2_cache; + int cache = 0; + if (m_l3_cache) { + cache = m_l2_exclusive ? (m_l2_cache + m_l3_cache) : m_l3_cache; + } + else { + cache = m_l2_cache; + } + int count = 0; const int size = (algo ? 1024 : 2048) * (doubleHash ? 2 : 1); @@ -84,8 +92,9 @@ void Cpu::initCommon() m_l3_cache = data.l3_cache > 0 ? data.l3_cache * m_sockets : 0; // Workaround for AMD CPUs https://github.com/anrieff/libcpuid/issues/97 - if (data.vendor == VENDOR_AMD && data.l3_cache <= 0 && data.l2_assoc == 16 && data.ext_family >= 21) { + if (data.vendor == VENDOR_AMD && data.ext_family >= 0x15 && data.ext_family < 0x17) { m_l2_cache = data.l2_cache * (m_totalCores / 2) * m_sockets; + m_l2_exclusive = true; } else { m_l2_cache = data.l2_cache > 0 ? data.l2_cache * m_totalCores * m_sockets : 0; diff --git a/src/Cpu.h b/src/Cpu.h index 7f1f7614..8b7c3643 100644 --- a/src/Cpu.h +++ b/src/Cpu.h @@ -53,6 +53,7 @@ public: private: static void initCommon(); + static bool m_l2_exclusive; static char m_brand[64]; static int m_flags; static int m_l2_cache; diff --git a/src/config.json b/src/config.json index 248e0a9a..a0ce1a3b 100644 --- a/src/config.json +++ b/src/config.json @@ -12,7 +12,7 @@ "retry-pause": 5, "safe": false, "syslog": false, - "threads": 4, + "threads": null, "pools": [ { "url": "pool.minemonero.pro:5555",