From c8c0abdb00bcd2fd39e7b83fc14ea3ca32b7fe1b Mon Sep 17 00:00:00 2001 From: SChernykh Date: Sun, 8 Nov 2020 19:40:44 +0100 Subject: [PATCH] Separate MSR mod for Zen/Zen2 and Zen3 Another +0.5% speedup for Zen2 --- src/backend/cpu/interfaces/ICpuInfo.h | 3 ++- src/backend/cpu/platform/BasicCpuInfo.cpp | 17 +++++++++++++++-- src/crypto/rx/RxConfig.cpp | 5 +++-- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/backend/cpu/interfaces/ICpuInfo.h b/src/backend/cpu/interfaces/ICpuInfo.h index ffab2d7d0..57f6185a2 100644 --- a/src/backend/cpu/interfaces/ICpuInfo.h +++ b/src/backend/cpu/interfaces/ICpuInfo.h @@ -48,7 +48,8 @@ public: enum MsrMod : uint32_t { MSR_MOD_NONE, - MSR_MOD_RYZEN, + MSR_MOD_RYZEN_17H, + MSR_MOD_RYZEN_19H, MSR_MOD_INTEL, MSR_MOD_CUSTOM, MSR_MOD_MAX diff --git a/src/backend/cpu/platform/BasicCpuInfo.cpp b/src/backend/cpu/platform/BasicCpuInfo.cpp index 00422af0e..174977895 100644 --- a/src/backend/cpu/platform/BasicCpuInfo.cpp +++ b/src/backend/cpu/platform/BasicCpuInfo.cpp @@ -195,9 +195,22 @@ xmrig::BasicCpuInfo::BasicCpuInfo() : cpuid(PROCESSOR_INFO, data); const int32_t family = get_masked(data[EAX_Reg], 12, 8) + get_masked(data[EAX_Reg], 28, 20); - if (family >= 23) { + if (family >= 0x17) { m_assembly = Assembly::RYZEN; - m_msrMod = MSR_MOD_RYZEN; + + switch (family) { + case 0x17: + m_msrMod = MSR_MOD_RYZEN_17H; + break; + + case 0x19: + m_msrMod = MSR_MOD_RYZEN_19H; + break; + + default: + m_msrMod = MSR_MOD_NONE; + break; + } } else { m_assembly = Assembly::BULLDOZER; diff --git a/src/crypto/rx/RxConfig.cpp b/src/crypto/rx/RxConfig.cpp index d35be18d1..43e21a89b 100644 --- a/src/crypto/rx/RxConfig.cpp +++ b/src/crypto/rx/RxConfig.cpp @@ -64,16 +64,17 @@ static const std::array modeNames = { "auto", " #ifdef XMRIG_FEATURE_MSR -constexpr size_t kMsrArraySize = 4; +constexpr size_t kMsrArraySize = 5; static const std::array msrPresets = { MsrItems(), + MsrItems{{ 0xC0011020, 0ULL }, { 0xC0011021, 0x40ULL, ~0x20ULL }, { 0xC0011022, 0x1510000ULL }, { 0xC001102b, 0x2000cc16ULL }}, MsrItems{{ 0xC0011020, 0x0004480000000000ULL }, { 0xC0011021, 0x001c000200000040ULL, ~0x20ULL }, { 0xC0011022, 0xc000000401500000ULL }, { 0xC001102b, 0x2000cc14ULL }}, MsrItems{{ 0x1a4, 0xf }}, MsrItems() }; -static const std::array modNames = { "none", "ryzen", "intel", "custom" }; +static const std::array modNames = { "none", "ryzen_17h", "ryzen_19h", "intel", "custom" }; static_assert (kMsrArraySize == ICpuInfo::MSR_MOD_MAX, "kMsrArraySize and MSR_MOD_MAX mismatch"); #endif