From 8c979d3bc7bc67346a061862b028c1cafd7db707 Mon Sep 17 00:00:00 2001 From: SChernykh Date: Tue, 9 Jun 2020 13:53:14 +0200 Subject: [PATCH 1/5] Disabled AVX-512F for Argon2 See #1722 --- src/3rdparty/argon2/arch/x86_64/lib/argon2-avx512f.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/3rdparty/argon2/arch/x86_64/lib/argon2-avx512f.c b/src/3rdparty/argon2/arch/x86_64/lib/argon2-avx512f.c index f9df1b87..282c2f41 100644 --- a/src/3rdparty/argon2/arch/x86_64/lib/argon2-avx512f.c +++ b/src/3rdparty/argon2/arch/x86_64/lib/argon2-avx512f.c @@ -309,7 +309,10 @@ void xmrig_ar2_fill_segment_avx512f(const argon2_instance_t *instance, argon2_po } extern int cpu_flags_has_avx512f(void); -int xmrig_ar2_check_avx512f(void) { return cpu_flags_has_avx512f(); } + +// Argon2 AVX-512F implementation is broken +// TODO: enable it back when it's fixed +int xmrig_ar2_check_avx512f(void) { return 0 /*cpu_flags_has_avx512f()*/; } #else From 2d2f3d4eb20d04893c2f1a2af5a3c5b1179f005e Mon Sep 17 00:00:00 2001 From: SChernykh Date: Tue, 9 Jun 2020 17:47:23 +0200 Subject: [PATCH 2/5] Fixed detection of AVX2/AVX512 --- .../argon2/arch/x86_64/lib/argon2-avx512f.c | 5 +---- src/backend/cpu/platform/BasicCpuInfo.cpp | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/3rdparty/argon2/arch/x86_64/lib/argon2-avx512f.c b/src/3rdparty/argon2/arch/x86_64/lib/argon2-avx512f.c index 282c2f41..f9df1b87 100644 --- a/src/3rdparty/argon2/arch/x86_64/lib/argon2-avx512f.c +++ b/src/3rdparty/argon2/arch/x86_64/lib/argon2-avx512f.c @@ -309,10 +309,7 @@ void xmrig_ar2_fill_segment_avx512f(const argon2_instance_t *instance, argon2_po } extern int cpu_flags_has_avx512f(void); - -// Argon2 AVX-512F implementation is broken -// TODO: enable it back when it's fixed -int xmrig_ar2_check_avx512f(void) { return 0 /*cpu_flags_has_avx512f()*/; } +int xmrig_ar2_check_avx512f(void) { return cpu_flags_has_avx512f(); } #else diff --git a/src/backend/cpu/platform/BasicCpuInfo.cpp b/src/backend/cpu/platform/BasicCpuInfo.cpp index eb042980..bf152851 100644 --- a/src/backend/cpu/platform/BasicCpuInfo.cpp +++ b/src/backend/cpu/platform/BasicCpuInfo.cpp @@ -119,10 +119,24 @@ static inline int32_t get_masked(int32_t val, int32_t h, int32_t l) } +static inline uint64_t xgetbv() +{ +#ifdef _MSC_VER + return _xgetbv(_XCR_XFEATURE_ENABLED_MASK); +#else + uint32_t eax_reg = 0; + uint32_t edx_reg = 0; + __asm__ __volatile__("xgetbv": "=a"(eax_reg), "=d"(edx_reg) : "c"(0) : "cc"); + return (static_cast(edx_reg) << 32) | eax_reg; +#endif +} + +static inline bool has_xcr_avx2() { return (xgetbv() & 0x06) == 0x06; } +static inline bool has_xcr_avx512() { return (xgetbv() & 0xE6) == 0xE6; } static inline bool has_osxsave() { return has_feature(PROCESSOR_INFO, ECX_Reg, 1 << 27); } static inline bool has_aes_ni() { return has_feature(PROCESSOR_INFO, ECX_Reg, 1 << 25); } -static inline bool has_avx2() { return has_feature(EXTENDED_FEATURES, EBX_Reg, 1 << 5) && has_osxsave(); } -static inline bool has_avx512f() { return has_feature(EXTENDED_FEATURES, EBX_Reg, 1 << 16) && has_osxsave(); } +static inline bool has_avx2() { return has_feature(EXTENDED_FEATURES, EBX_Reg, 1 << 5) && has_osxsave() && has_xcr_avx2(); } +static inline bool has_avx512f() { return has_feature(EXTENDED_FEATURES, EBX_Reg, 1 << 16) && has_osxsave() && has_xcr_avx512(); } static inline bool has_bmi2() { return has_feature(EXTENDED_FEATURES, EBX_Reg, 1 << 8); } static inline bool has_pdpe1gb() { return has_feature(PROCESSOR_EXT_INFO, EDX_Reg, 1 << 26); } static inline bool has_sse2() { return has_feature(PROCESSOR_INFO, EDX_Reg, 1 << 26); } From e4779ab6ca1c250020edc1446a8e90634630bbe9 Mon Sep 17 00:00:00 2001 From: XMRig Date: Wed, 10 Jun 2020 00:55:15 +0700 Subject: [PATCH 3/5] v5.11.4-dev --- src/version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/version.h b/src/version.h index c98b99c3..82b1f416 100644 --- a/src/version.h +++ b/src/version.h @@ -28,7 +28,7 @@ #define APP_ID "xmrig" #define APP_NAME "XMRig" #define APP_DESC "XMRig miner" -#define APP_VERSION "5.11.3" +#define APP_VERSION "5.11.4-dev" #define APP_DOMAIN "xmrig.com" #define APP_SITE "www.xmrig.com" #define APP_COPYRIGHT "Copyright (C) 2016-2020 xmrig.com" @@ -36,7 +36,7 @@ #define APP_VER_MAJOR 5 #define APP_VER_MINOR 11 -#define APP_VER_PATCH 3 +#define APP_VER_PATCH 4 #ifdef _MSC_VER # if (_MSC_VER >= 1920) From 1b928e8bf10ffff4ef848b9bd05597c4e530f52e Mon Sep 17 00:00:00 2001 From: XMRig Date: Wed, 10 Jun 2020 23:09:11 +0700 Subject: [PATCH 4/5] #1728 Fixed x86 crash on Windows. --- src/base/kernel/Platform_win.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/base/kernel/Platform_win.cpp b/src/base/kernel/Platform_win.cpp index 018dba31..00497453 100644 --- a/src/base/kernel/Platform_win.cpp +++ b/src/base/kernel/Platform_win.cpp @@ -34,7 +34,7 @@ static inline OSVERSIONINFOEX winOsVersion() { - using RtlGetVersionFunction = NTSTATUS (*)(LPOSVERSIONINFO); + typedef NTSTATUS (NTAPI *RtlGetVersionFunction)(LPOSVERSIONINFO); OSVERSIONINFOEX result = { sizeof(OSVERSIONINFOEX), 0, 0, 0, 0, {'\0'}, 0, 0, 0, 0, 0}; HMODULE ntdll = GetModuleHandleW(L"ntdll.dll"); From 416c9eff69816f5321274f962620ee9dd8a5a5fb Mon Sep 17 00:00:00 2001 From: XMRig Date: Thu, 18 Jun 2020 11:16:26 +0700 Subject: [PATCH 5/5] Fixed AMD GPU health readings on Linux. --- src/backend/opencl/wrappers/AdlLib_linux.cpp | 37 ++++++++++++++------ 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/src/backend/opencl/wrappers/AdlLib_linux.cpp b/src/backend/opencl/wrappers/AdlLib_linux.cpp index 5ef0e5e5..7dbb1ea2 100644 --- a/src/backend/opencl/wrappers/AdlLib_linux.cpp +++ b/src/backend/opencl/wrappers/AdlLib_linux.cpp @@ -36,27 +36,29 @@ bool AdlLib::m_ready = false; static const std::string kPrefix = "/sys/bus/pci/drivers/amdgpu/"; -static inline bool sysfs_is_file(const char *path) +static inline bool sysfs_is_file(const std::string &path) { struct stat sb; - return stat(path, &sb) == 0 && ((sb.st_mode & S_IFMT) == S_IFREG); + return stat(path.c_str(), &sb) == 0 && ((sb.st_mode & S_IFMT) == S_IFREG); } -static inline std::string sysfs_prefix(const PciTopology &topology) +static inline bool sysfs_is_amdgpu(const std::string &path) { - std::string path = kPrefix + "0000:" + topology.toString().data() + "/hwmon/hwmon"; - - if (sysfs_is_file((path + "2/name").c_str())) { - return path + "2/"; + if (!sysfs_is_file(path)) { + return false; } - if (sysfs_is_file((path + "3/name").c_str())) { - return path + "3/"; + std::ifstream file(path); + if (!file.is_open()) { + return false; } - return {}; + std::string name; + std::getline(file, name); + + return name == "amdgpu"; } @@ -74,6 +76,21 @@ uint32_t sysfs_read(const std::string &path) } +static inline std::string sysfs_prefix(const PciTopology &topology) +{ + const std::string path = kPrefix + "0000:" + topology.toString().data() + "/hwmon/hwmon"; + + for (uint32_t i = 1; i < 10; ++i) { + const std::string prefix = path + std::to_string(i) + "/"; + if (sysfs_is_amdgpu(prefix + "name") && sysfs_read(prefix + "freq1_input")) { + return prefix; + } + } + + return {}; +} + + } // namespace xmrig