diff --git a/src/common/crypto/Algorithm.cpp b/src/common/crypto/Algorithm.cpp index 31035fb1..c253d9c8 100644 --- a/src/common/crypto/Algorithm.cpp +++ b/src/common/crypto/Algorithm.cpp @@ -7,6 +7,7 @@ * Copyright 2017-2018 XMR-Stak , * Copyright 2018 Lee Clagett * Copyright 2016-2018 XMRig , + * Copyright 2018 MoneroOcean , * * 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 @@ -223,3 +224,51 @@ const char *xmrig::Algorithm::name(bool shortName) const return "invalid"; } + + +// returns string name of the PerfAlgo +const char *xmrig::Algorithm::perfAlgoName(const xmrig::PerfAlgo pa) { + static const char* perf_algo_names[xmrig::PerfAlgo::PA_MAX] = { + "cn", + "cn-fast", + "cn-lite", + "cn-heavy", + }; + return perf_algo_names[pa]; +} + +// constructs Algorithm from PerfAlgo +xmrig::Algorithm::Algorithm(const xmrig::PerfAlgo pa) { + switch (pa) { + case PA_CN: + m_algo = xmrig::CRYPTONIGHT; + m_variant = xmrig::VARIANT_1; + break; + case PA_CN_FAST: + m_algo = xmrig::CRYPTONIGHT; + m_variant = xmrig::VARIANT_MSR; + break; + case PA_CN_LITE: + m_algo = xmrig::CRYPTONIGHT_LITE; + m_variant = xmrig::VARIANT_1; + break; + case PA_CN_HEAVY: + m_algo = xmrig::CRYPTONIGHT_HEAVY; + m_variant = xmrig::VARIANT_0; + break; + default: + m_algo = xmrig::INVALID_ALGO; + m_variant = xmrig::VARIANT_AUTO; + } +} + +// returns PerfAlgo that corresponds to current Algorithm +xmrig::PerfAlgo xmrig::Algorithm::perf_algo() const { + if (m_variant == VARIANT_MSR) return PA_CN_FAST; + switch (m_algo) { + case CRYPTONIGHT: return PA_CN; + case CRYPTONIGHT_LITE: return PA_CN_LITE; + case CRYPTONIGHT_HEAVY: return PA_CN_HEAVY; + default: return PA_INVALID; + } +} diff --git a/src/common/crypto/Algorithm.h b/src/common/crypto/Algorithm.h index bcf029d8..77e2dfff 100644 --- a/src/common/crypto/Algorithm.h +++ b/src/common/crypto/Algorithm.h @@ -7,6 +7,7 @@ * Copyright 2017-2018 XMR-Stak , * Copyright 2018 Lee Clagett * Copyright 2016-2018 XMRig , + * Copyright 2018 MoneroOcean , * * 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 @@ -49,6 +50,9 @@ public: setAlgo(algo); } + // constructs Algorithm from PerfAlgo + Algorithm(const xmrig::PerfAlgo); + inline Algorithm(const char *algo) { parseAlgorithm(algo); @@ -56,8 +60,10 @@ public: bool isEqual(const Algorithm &other) const { return m_algo == other.m_algo && m_variant == other.m_variant; } inline Algo algo() const { return m_algo; } + xmrig::PerfAlgo perf_algo() const; // returns PerfAlgo that corresponds to current Algorithm inline const char *name() const { return name(false); } inline const char *shortName() const { return name(true); } + static const char *perfAlgoName(xmrig::PerfAlgo); // returns string name of the PerfAlgo inline Variant variant() const { return m_variant; } inline void setVariant(Variant variant) { m_variant = variant; } diff --git a/src/common/xmrig.h b/src/common/xmrig.h index 0ff945b9..515c6709 100644 --- a/src/common/xmrig.h +++ b/src/common/xmrig.h @@ -6,6 +6,7 @@ * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , * Copyright 2016-2018 XMRig , + * Copyright 2018 MoneroOcean , * * 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 @@ -36,6 +37,15 @@ enum Algo { CRYPTONIGHT_HEAVY /* CryptoNight-Heavy (SUMO) */ }; +// algorithms that can has different performance +enum PerfAlgo { + PA_INVALID = -1, + PA_CN, /* CryptoNight (Monero) */ + PA_CN_FAST, /* CryptoNight-Fast (Masari) */ + PA_CN_LITE, /* CryptoNight-Lite (AEON) */ + PA_CN_HEAVY, /* CryptoNight-Heavy (SUMO) */ + PA_MAX +}; //--av=1 For CPUs with hardware AES. //--av=2 Lower power mode (double hash) of 1.