From 0c20d7a125f2cb823b6e4b6aa4577e951126f17a Mon Sep 17 00:00:00 2001 From: XMRig Date: Sun, 23 Sep 2018 19:09:05 +0300 Subject: [PATCH] Auto-detect proper asm variant. --- src/common/cpu/BasicCpuInfo_arm.cpp | 2 +- src/core/cpu/AdvancedCpuInfo.cpp | 12 +++++++++++- src/core/cpu/AdvancedCpuInfo.h | 4 ++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/common/cpu/BasicCpuInfo_arm.cpp b/src/common/cpu/BasicCpuInfo_arm.cpp index 34eb7388..c1c127db 100644 --- a/src/common/cpu/BasicCpuInfo_arm.cpp +++ b/src/common/cpu/BasicCpuInfo_arm.cpp @@ -36,7 +36,7 @@ xmrig::BasicCpuInfo::BasicCpuInfo() : memcpy(m_brand, "Unknown", 7); # if __ARM_FEATURE_CRYPTO - m_flags |= AES; + m_aes = true; # endif } diff --git a/src/core/cpu/AdvancedCpuInfo.cpp b/src/core/cpu/AdvancedCpuInfo.cpp index 009a2bcb..ac5508c3 100644 --- a/src/core/cpu/AdvancedCpuInfo.cpp +++ b/src/core/cpu/AdvancedCpuInfo.cpp @@ -31,6 +31,7 @@ xmrig::AdvancedCpuInfo::AdvancedCpuInfo() : + m_assembly(ASM_NONE), m_aes(false), m_L2_exclusive(false), m_brand(), @@ -71,7 +72,16 @@ xmrig::AdvancedCpuInfo::AdvancedCpuInfo() : m_L2 = data.l2_cache > 0 ? data.l2_cache * cores() * m_sockets : 0; } - m_aes = data.flags[CPU_FEATURE_AES]; + if (data.flags[CPU_FEATURE_AES]) { + m_aes = true; + + if (data.vendor == VENDOR_AMD && data.ext_family >= 23) { + m_assembly = ASM_RYZEN; + } + else if (data.vendor == VENDOR_INTEL && data.ext_model >= 42) { + m_assembly = ASM_INTEL; + } + } } diff --git a/src/core/cpu/AdvancedCpuInfo.h b/src/core/cpu/AdvancedCpuInfo.h index 96fd329a..5e8967ad 100644 --- a/src/core/cpu/AdvancedCpuInfo.h +++ b/src/core/cpu/AdvancedCpuInfo.h @@ -7,7 +7,6 @@ * Copyright 2017-2018 XMR-Stak , * Copyright 2016-2018 XMRig , * - * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -40,7 +39,7 @@ public: protected: size_t optimalThreadsCount(size_t memSize, int maxCpuUsage) const override; - inline Assembly assembly() const override { return ASM_NONE; } + inline Assembly assembly() const override { return m_assembly; } inline bool hasAES() const override { return m_aes; } inline bool isSupported() const override { return true; } inline const char *brand() const override { return m_brand; } @@ -58,6 +57,7 @@ protected: # endif private: + Assembly m_assembly; bool m_aes; bool m_L2_exclusive; char m_brand[64];