diff --git a/src/backend/cpu/CpuWorker.cpp b/src/backend/cpu/CpuWorker.cpp index 39e46f6d6..3eb6e4683 100644 --- a/src/backend/cpu/CpuWorker.cpp +++ b/src/backend/cpu/CpuWorker.cpp @@ -77,8 +77,11 @@ xmrig::CpuWorker::CpuWorker(size_t id, const CpuLaunchData &data) : { # ifdef XMRIG_ALGO_CN_HEAVY // cn-heavy optimization for Zen3 CPUs - const bool is_vermeer = (Cpu::info()->arch() == ICpuInfo::ARCH_ZEN3) && (Cpu::info()->model() == 0x21); - if ((N == 1) && (m_av == CnHash::AV_SINGLE) && (m_algorithm.family() == Algorithm::CN_HEAVY) && (m_assembly != Assembly::NONE) && is_vermeer) { + const auto arch = Cpu::info()->arch(); + const uint32_t model = Cpu::info()->model(); + const bool is_vermeer = (arch == ICpuInfo::ARCH_ZEN3) && (model == 0x21); + const bool is_raphael = (arch == ICpuInfo::ARCH_ZEN4) && (model == 0x61); + if ((N == 1) && (m_av == CnHash::AV_SINGLE) && (m_algorithm.family() == Algorithm::CN_HEAVY) && (m_assembly != Assembly::NONE) && (is_vermeer || is_raphael)) { std::lock_guard lock(cn_heavyZen3MemoryMutex); if (!cn_heavyZen3Memory) { // Round up number of threads to the multiple of 8 diff --git a/src/backend/cpu/interfaces/ICpuInfo.h b/src/backend/cpu/interfaces/ICpuInfo.h index f2b56009a..387f319b1 100644 --- a/src/backend/cpu/interfaces/ICpuInfo.h +++ b/src/backend/cpu/interfaces/ICpuInfo.h @@ -45,19 +45,21 @@ public: ARCH_ZEN, ARCH_ZEN_PLUS, ARCH_ZEN2, - ARCH_ZEN3 + ARCH_ZEN3, + ARCH_ZEN4 }; enum MsrMod : uint32_t { MSR_MOD_NONE, MSR_MOD_RYZEN_17H, MSR_MOD_RYZEN_19H, + MSR_MOD_RYZEN_19H_ZEN4, MSR_MOD_INTEL, MSR_MOD_CUSTOM, MSR_MOD_MAX }; -# define MSR_NAMES_LIST "none", "ryzen_17h", "ryzen_19h", "intel", "custom" +# define MSR_NAMES_LIST "none", "ryzen_17h", "ryzen_19h", "ryzen_19h_zen4", "intel", "custom" enum Flag : uint32_t { FLAG_AES, diff --git a/src/backend/cpu/platform/BasicCpuInfo.cpp b/src/backend/cpu/platform/BasicCpuInfo.cpp index 0f81ae254..0680d1bf8 100644 --- a/src/backend/cpu/platform/BasicCpuInfo.cpp +++ b/src/backend/cpu/platform/BasicCpuInfo.cpp @@ -64,7 +64,7 @@ static_assert(kCpuFlagsSize == ICpuInfo::FLAG_MAX, "kCpuFlagsSize and FLAG_MAX m #ifdef XMRIG_FEATURE_MSR -constexpr size_t kMsrArraySize = 5; +constexpr size_t kMsrArraySize = 6; static const std::array msrNames = { MSR_NAMES_LIST }; static_assert(kMsrArraySize == ICpuInfo::MSR_MOD_MAX, "kMsrArraySize and MSR_MOD_MAX mismatch"); #endif @@ -250,8 +250,14 @@ xmrig::BasicCpuInfo::BasicCpuInfo() : break; case 0x19: - m_arch = ARCH_ZEN3; - m_msrMod = MSR_MOD_RYZEN_19H; + if (m_model == 0x61) { + m_arch = ARCH_ZEN4; + m_msrMod = MSR_MOD_RYZEN_19H_ZEN4; + } + else { + m_arch = ARCH_ZEN3; + m_msrMod = MSR_MOD_RYZEN_19H; + } break; default: diff --git a/src/crypto/cn/CnHash.cpp b/src/crypto/cn/CnHash.cpp index 9fbccd83e..4b4b006f3 100644 --- a/src/crypto/cn/CnHash.cpp +++ b/src/crypto/cn/CnHash.cpp @@ -407,8 +407,12 @@ xmrig::cn_hash_fun xmrig::CnHash::fn(const Algorithm &algorithm, AlgoVariant av, } # ifdef XMRIG_ALGO_CN_HEAVY - // cn-heavy optimization for Zen3 CPUs - if ((av == AV_SINGLE) && (assembly != Assembly::NONE) && (Cpu::info()->arch() == ICpuInfo::ARCH_ZEN3) && (Cpu::info()->model() == 0x21)) { + // cn-heavy optimization for Zen3/Zen4 CPUs + const auto arch = Cpu::info()->arch(); + const uint32_t model = Cpu::info()->model(); + const bool is_vermeer = (arch == ICpuInfo::ARCH_ZEN3) && (model == 0x21); + const bool is_raphael = (arch == ICpuInfo::ARCH_ZEN4) && (model == 0x61); + if ((av == AV_SINGLE) && (assembly != Assembly::NONE) && (is_vermeer || is_raphael)) { switch (algorithm.id()) { case Algorithm::CN_HEAVY_0: return cryptonight_single_hash; diff --git a/src/crypto/randomx/jit_compiler_x86.cpp b/src/crypto/randomx/jit_compiler_x86.cpp index 93e8c18fe..7d2603e5e 100644 --- a/src/crypto/randomx/jit_compiler_x86.cpp +++ b/src/crypto/randomx/jit_compiler_x86.cpp @@ -262,6 +262,10 @@ namespace randomx { // AVX2 init is faster on Zen3 initDatasetAVX2 = true; break; + case xmrig::ICpuInfo::ARCH_ZEN4: + // AVX2 init is slower on Zen4 + initDatasetAVX2 = false; + break; } } } diff --git a/src/crypto/rx/RxConfig.cpp b/src/crypto/rx/RxConfig.cpp index 1cd6f6eb1..362876071 100644 --- a/src/crypto/rx/RxConfig.cpp +++ b/src/crypto/rx/RxConfig.cpp @@ -58,12 +58,13 @@ static const std::array modeNames = { "auto", " #ifdef XMRIG_FEATURE_MSR -constexpr size_t kMsrArraySize = 5; +constexpr size_t kMsrArraySize = 6; 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{{ 0xC0011020, 0x0004400000000000ULL }, { 0xC0011021, 0x0004000000000040ULL, ~0x20ULL }, { 0xC0011022, 0x8680000401570000ULL }, { 0xC001102b, 0x2040cc10ULL }}, MsrItems{{ 0x1a4, 0xf }}, MsrItems() };