From ef3af1c4fdfe4402c46b4439b04161c5f335b198 Mon Sep 17 00:00:00 2001 From: XMRig Date: Fri, 9 Jun 2017 03:37:56 +0300 Subject: [PATCH] Restore autoconf. --- src/Options.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++++++ src/Options.h | 5 +++++ 2 files changed, 52 insertions(+) diff --git a/src/Options.cpp b/src/Options.cpp index 3cd3ac5f3..a2702a653 100644 --- a/src/Options.cpp +++ b/src/Options.cpp @@ -179,10 +179,21 @@ Options::Options(int argc, char **argv) : m_pass = strdup("x"); } + m_algoVariant = getAlgoVariant(); if (m_algoVariant == AV2_AESNI_DOUBLE || m_algoVariant == AV4_SOFT_AES_DOUBLE) { m_doubleHash = true; } + if (!m_threads) { + m_threads = Cpu::optimalThreadsCount(m_algo, m_doubleHash, m_maxCpuUsage); + } + else if (m_safe) { + const int count = Cpu::optimalThreadsCount(m_algo, m_doubleHash, m_maxCpuUsage); + if (m_threads > count) { + m_threads = count; + } + } + m_ready = true; } @@ -442,3 +453,39 @@ bool Options::setUserpass(const char *userpass) return true; } + + +int Options::getAlgoVariant() const +{ +# ifndef XMRIG_NO_AEON + if (m_algo == ALGO_CRYPTONIGHT_LITE) { + return getAlgoVariantLite(); + } +# endif + + if (m_algoVariant <= AV0_AUTO || m_algoVariant >= AV_MAX) { + return Cpu::hasAES() ? AV1_AESNI : AV3_SOFT_AES; + } + + if (m_safe && !Cpu::hasAES() && m_algoVariant <= AV2_AESNI_DOUBLE) { + return m_algoVariant + 2; + } + + return m_algoVariant; +} + + +#ifndef XMRIG_NO_AEON +int Options::getAlgoVariantLite() const +{ + if (m_algoVariant <= AV0_AUTO || m_algoVariant >= AV_MAX) { + return Cpu::hasAES() ? AV2_AESNI_DOUBLE : AV4_SOFT_AES_DOUBLE; + } + + if (m_safe && !Cpu::hasAES() && m_algoVariant <= AV2_AESNI_DOUBLE) { + return m_algoVariant + 2; + } + + return m_algoVariant; +} +#endif diff --git a/src/Options.h b/src/Options.h index e9f4a7437..4955a7f35 100644 --- a/src/Options.h +++ b/src/Options.h @@ -84,6 +84,11 @@ private: bool setAlgo(const char *algo); bool setUserpass(const char *userpass); + int getAlgoVariant() const; +# ifndef XMRIG_NO_AEON + int getAlgoVariantLite() const; +# endif + bool m_background; bool m_colors; bool m_doubleHash;