mirror of
https://github.com/xmrig/xmrig.git
synced 2025-01-03 17:40:13 +00:00
RandomX: added MSR mod for Zen 4
+0.8% faster on Ryzen 9 7950X
This commit is contained in:
parent
7b52a41459
commit
7fc45dfb2d
6 changed files with 30 additions and 10 deletions
|
@ -77,8 +77,11 @@ xmrig::CpuWorker<N>::CpuWorker(size_t id, const CpuLaunchData &data) :
|
||||||
{
|
{
|
||||||
# ifdef XMRIG_ALGO_CN_HEAVY
|
# ifdef XMRIG_ALGO_CN_HEAVY
|
||||||
// cn-heavy optimization for Zen3 CPUs
|
// cn-heavy optimization for Zen3 CPUs
|
||||||
const bool is_vermeer = (Cpu::info()->arch() == ICpuInfo::ARCH_ZEN3) && (Cpu::info()->model() == 0x21);
|
const auto arch = Cpu::info()->arch();
|
||||||
if ((N == 1) && (m_av == CnHash::AV_SINGLE) && (m_algorithm.family() == Algorithm::CN_HEAVY) && (m_assembly != Assembly::NONE) && is_vermeer) {
|
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<std::mutex> lock(cn_heavyZen3MemoryMutex);
|
std::lock_guard<std::mutex> lock(cn_heavyZen3MemoryMutex);
|
||||||
if (!cn_heavyZen3Memory) {
|
if (!cn_heavyZen3Memory) {
|
||||||
// Round up number of threads to the multiple of 8
|
// Round up number of threads to the multiple of 8
|
||||||
|
|
|
@ -45,19 +45,21 @@ public:
|
||||||
ARCH_ZEN,
|
ARCH_ZEN,
|
||||||
ARCH_ZEN_PLUS,
|
ARCH_ZEN_PLUS,
|
||||||
ARCH_ZEN2,
|
ARCH_ZEN2,
|
||||||
ARCH_ZEN3
|
ARCH_ZEN3,
|
||||||
|
ARCH_ZEN4
|
||||||
};
|
};
|
||||||
|
|
||||||
enum MsrMod : uint32_t {
|
enum MsrMod : uint32_t {
|
||||||
MSR_MOD_NONE,
|
MSR_MOD_NONE,
|
||||||
MSR_MOD_RYZEN_17H,
|
MSR_MOD_RYZEN_17H,
|
||||||
MSR_MOD_RYZEN_19H,
|
MSR_MOD_RYZEN_19H,
|
||||||
|
MSR_MOD_RYZEN_19H_ZEN4,
|
||||||
MSR_MOD_INTEL,
|
MSR_MOD_INTEL,
|
||||||
MSR_MOD_CUSTOM,
|
MSR_MOD_CUSTOM,
|
||||||
MSR_MOD_MAX
|
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 {
|
enum Flag : uint32_t {
|
||||||
FLAG_AES,
|
FLAG_AES,
|
||||||
|
|
|
@ -64,7 +64,7 @@ static_assert(kCpuFlagsSize == ICpuInfo::FLAG_MAX, "kCpuFlagsSize and FLAG_MAX m
|
||||||
|
|
||||||
|
|
||||||
#ifdef XMRIG_FEATURE_MSR
|
#ifdef XMRIG_FEATURE_MSR
|
||||||
constexpr size_t kMsrArraySize = 5;
|
constexpr size_t kMsrArraySize = 6;
|
||||||
static const std::array<const char *, kMsrArraySize> msrNames = { MSR_NAMES_LIST };
|
static const std::array<const char *, kMsrArraySize> msrNames = { MSR_NAMES_LIST };
|
||||||
static_assert(kMsrArraySize == ICpuInfo::MSR_MOD_MAX, "kMsrArraySize and MSR_MOD_MAX mismatch");
|
static_assert(kMsrArraySize == ICpuInfo::MSR_MOD_MAX, "kMsrArraySize and MSR_MOD_MAX mismatch");
|
||||||
#endif
|
#endif
|
||||||
|
@ -250,8 +250,14 @@ xmrig::BasicCpuInfo::BasicCpuInfo() :
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x19:
|
case 0x19:
|
||||||
|
if (m_model == 0x61) {
|
||||||
|
m_arch = ARCH_ZEN4;
|
||||||
|
m_msrMod = MSR_MOD_RYZEN_19H_ZEN4;
|
||||||
|
}
|
||||||
|
else {
|
||||||
m_arch = ARCH_ZEN3;
|
m_arch = ARCH_ZEN3;
|
||||||
m_msrMod = MSR_MOD_RYZEN_19H;
|
m_msrMod = MSR_MOD_RYZEN_19H;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -407,8 +407,12 @@ xmrig::cn_hash_fun xmrig::CnHash::fn(const Algorithm &algorithm, AlgoVariant av,
|
||||||
}
|
}
|
||||||
|
|
||||||
# ifdef XMRIG_ALGO_CN_HEAVY
|
# ifdef XMRIG_ALGO_CN_HEAVY
|
||||||
// cn-heavy optimization for Zen3 CPUs
|
// cn-heavy optimization for Zen3/Zen4 CPUs
|
||||||
if ((av == AV_SINGLE) && (assembly != Assembly::NONE) && (Cpu::info()->arch() == ICpuInfo::ARCH_ZEN3) && (Cpu::info()->model() == 0x21)) {
|
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()) {
|
switch (algorithm.id()) {
|
||||||
case Algorithm::CN_HEAVY_0:
|
case Algorithm::CN_HEAVY_0:
|
||||||
return cryptonight_single_hash<Algorithm::CN_HEAVY_0, false, 3>;
|
return cryptonight_single_hash<Algorithm::CN_HEAVY_0, false, 3>;
|
||||||
|
|
|
@ -262,6 +262,10 @@ namespace randomx {
|
||||||
// AVX2 init is faster on Zen3
|
// AVX2 init is faster on Zen3
|
||||||
initDatasetAVX2 = true;
|
initDatasetAVX2 = true;
|
||||||
break;
|
break;
|
||||||
|
case xmrig::ICpuInfo::ARCH_ZEN4:
|
||||||
|
// AVX2 init is slower on Zen4
|
||||||
|
initDatasetAVX2 = false;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,12 +58,13 @@ static const std::array<const char *, RxConfig::ModeMax> modeNames = { "auto", "
|
||||||
|
|
||||||
|
|
||||||
#ifdef XMRIG_FEATURE_MSR
|
#ifdef XMRIG_FEATURE_MSR
|
||||||
constexpr size_t kMsrArraySize = 5;
|
constexpr size_t kMsrArraySize = 6;
|
||||||
|
|
||||||
static const std::array<MsrItems, kMsrArraySize> msrPresets = {
|
static const std::array<MsrItems, kMsrArraySize> msrPresets = {
|
||||||
MsrItems(),
|
MsrItems(),
|
||||||
MsrItems{{ 0xC0011020, 0ULL }, { 0xC0011021, 0x40ULL, ~0x20ULL }, { 0xC0011022, 0x1510000ULL }, { 0xC001102b, 0x2000cc16ULL }},
|
MsrItems{{ 0xC0011020, 0ULL }, { 0xC0011021, 0x40ULL, ~0x20ULL }, { 0xC0011022, 0x1510000ULL }, { 0xC001102b, 0x2000cc16ULL }},
|
||||||
MsrItems{{ 0xC0011020, 0x0004480000000000ULL }, { 0xC0011021, 0x001c000200000040ULL, ~0x20ULL }, { 0xC0011022, 0xc000000401500000ULL }, { 0xC001102b, 0x2000cc14ULL }},
|
MsrItems{{ 0xC0011020, 0x0004480000000000ULL }, { 0xC0011021, 0x001c000200000040ULL, ~0x20ULL }, { 0xC0011022, 0xc000000401500000ULL }, { 0xC001102b, 0x2000cc14ULL }},
|
||||||
|
MsrItems{{ 0xC0011020, 0x0004400000000000ULL }, { 0xC0011021, 0x0004000000000040ULL, ~0x20ULL }, { 0xC0011022, 0x8680000401570000ULL }, { 0xC001102b, 0x2040cc10ULL }},
|
||||||
MsrItems{{ 0x1a4, 0xf }},
|
MsrItems{{ 0x1a4, 0xf }},
|
||||||
MsrItems()
|
MsrItems()
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue