diff --git a/src/core/CommonConfig.cpp b/src/core/CommonConfig.cpp
index 514486547..6a2c76ac5 100644
--- a/src/core/CommonConfig.cpp
+++ b/src/core/CommonConfig.cpp
@@ -95,9 +95,9 @@ xmrig::CommonConfig::~CommonConfig()
}
-const char *xmrig::CommonConfig::algoName() const
+const char *xmrig::CommonConfig::algoName(Algo algorithm)
{
- return algoNames[m_algorithm];
+ return algoNames[algorithm];
}
diff --git a/src/core/CommonConfig.h b/src/core/CommonConfig.h
index 0f6f6b8c9..ee9c7a20e 100644
--- a/src/core/CommonConfig.h
+++ b/src/core/CommonConfig.h
@@ -44,7 +44,7 @@ public:
CommonConfig();
~CommonConfig();
- const char *algoName() const;
+ static const char *algoName(Algo algorithm);
inline Algo algorithm() const { return m_algorithm; }
inline bool isApiIPv6() const { return m_apiIPv6; }
@@ -52,6 +52,7 @@ public:
inline bool isBackground() const { return m_background; }
inline bool isColors() const { return m_colors; }
inline bool isSyslog() const { return m_syslog; }
+ inline const char *algoName() const { return algoName(m_algorithm); }
inline const char *apiToken() const { return m_apiToken; }
inline const char *apiWorkerId() const { return m_apiWorkerId; }
inline const char *logFile() const { return m_logFile; }
diff --git a/src/workers/CpuThread.cpp b/src/workers/CpuThread.cpp
index ff3aaed73..91e98a149 100644
--- a/src/workers/CpuThread.cpp
+++ b/src/workers/CpuThread.cpp
@@ -21,18 +21,22 @@
* along with this program. If not, see .
*/
+#include
+
+#include "core/CommonConfig.h"
#include "rapidjson/document.h"
#include "workers/CpuThread.h"
-xmrig::CpuThread::CpuThread(size_t index, Algo algorithm, int multiway, int64_t affinity, int priority, bool softAES, bool prefetch) :
+xmrig::CpuThread::CpuThread(size_t index, Algo algorithm, AlgoVariant av, Multiway multiway, int64_t affinity, int priority, bool softAES, bool prefetch) :
m_algorithm(algorithm),
+ m_av(av),
m_prefetch(prefetch),
m_softAES(softAES),
- m_multiway(multiway),
m_priority(priority),
m_affinity(affinity),
+ m_multiway(multiway),
m_index(index)
{
}
@@ -45,7 +49,64 @@ xmrig::CpuThread::~CpuThread()
xmrig::CpuThread *xmrig::CpuThread::createFromAV(size_t index, Algo algorithm, AlgoVariant av, int64_t affinity, int priority)
{
- return new CpuThread(index, algorithm, 1, affinity, priority, false, false);
+ assert(av > AV_AUTO && av < AV_MAX);
+
+ Multiway multiway = SingleWay;
+ bool softAES = false;
+
+ switch (av) {
+ case AV_SINGLE_SOFT:
+ softAES = true;
+ break;
+
+ case AV_DOUBLE:
+ multiway = DoubleWay;
+ case AV_DOUBLE_SOFT:
+ softAES = true;
+ break;
+
+ case AV_TRIPLE:
+ multiway = TripleWay;
+ case AV_TRIPLE_SOFT:
+ softAES = true;
+ break;
+
+ case AV_QUAD:
+ multiway = QuadWay;
+ case AV_QUAD_SOFT:
+ softAES = true;
+ break;
+
+ case AV_PENTA:
+ multiway = PentaWay;
+ case AV_PENTA_SOFT:
+ softAES = true;
+ break;
+
+ default:
+ break;
+ }
+
+ int64_t cpuId = -1L;
+
+ if (affinity != -1L) {
+ size_t idx = 0;
+
+ for (size_t i = 0; i < 64; i++) {
+ if (!(affinity & (1ULL << i))) {
+ continue;
+ }
+
+ if (idx == index) {
+ cpuId = i;
+ break;
+ }
+
+ idx++;
+ }
+ }
+
+ return new CpuThread(index, algorithm, av, multiway, cpuId, priority, softAES, false);
}
@@ -56,11 +117,11 @@ rapidjson::Value xmrig::CpuThread::toAPI(rapidjson::Document &doc) const
auto &allocator = doc.GetAllocator();
obj.AddMember("type", "cpu", allocator);
- obj.AddMember("algo", algorithm(), allocator);
+ obj.AddMember("algo", rapidjson::StringRef(CommonConfig::algoName(algorithm())), allocator);
+ obj.AddMember("av", m_av, allocator);
obj.AddMember("low_power_mode", multiway(), allocator);
obj.AddMember("affine_to_cpu", affinity(), allocator);
obj.AddMember("priority", priority(), allocator);
- obj.AddMember("prefetch", isPrefetch(), allocator);
obj.AddMember("soft_aes", isSoftAES(), allocator);
return obj;
diff --git a/src/workers/CpuThread.h b/src/workers/CpuThread.h
index 93ef50d59..2b2144237 100644
--- a/src/workers/CpuThread.h
+++ b/src/workers/CpuThread.h
@@ -35,7 +35,15 @@ namespace xmrig {
class CpuThread : public IThread
{
public:
- CpuThread(size_t index, Algo algorithm, int multiway, int64_t affinity, int priority, bool softAES, bool prefetch);
+ enum Multiway {
+ SingleWay,
+ DoubleWay,
+ TripleWay,
+ QuadWay,
+ PentaWay
+ };
+
+ CpuThread(size_t index, Algo algorithm, AlgoVariant av, Multiway multiway, int64_t affinity, int priority, bool softAES, bool prefetch);
~CpuThread();
static CpuThread *createFromAV(size_t index, Algo algorithm, AlgoVariant av, int64_t affinity, int priority);
@@ -56,11 +64,12 @@ public:
private:
const Algo m_algorithm;
+ const AlgoVariant m_av;
const bool m_prefetch;
const bool m_softAES;
- const int m_multiway;
const int m_priority;
const int64_t m_affinity;
+ const Multiway m_multiway;
const size_t m_index;
};
diff --git a/src/xmrig.h b/src/xmrig.h
index 805b7ceba..eba72bb4e 100644
--- a/src/xmrig.h
+++ b/src/xmrig.h
@@ -36,18 +36,22 @@ enum Algo {
};
+//--av=1 For CPUs with hardware AES.
+//--av=2 Lower power mode (double hash) of 1.
+//--av=3 Software AES implementation.
+//--av=4 Lower power mode (double hash) of 3.
enum AlgoVariant {
- AV_AUTO,
- AV_SINGLE,
- AV_DOUBLE,
- AV_SINGLE_SOFT,
- AV_DOUBLE_SOFT,
- AV_TRIPLE,
- AV_QUAD,
- AV_PENTA,
- AV_TRIPLE_SOFT,
- AV_QUAD_SOFT,
- AV_PENTA_SOFT,
+ AV_AUTO, // --av=0 Automatic mode.
+ AV_SINGLE, // --av=1 Single hash mode
+ AV_DOUBLE, // --av=2 Double hash mode
+ AV_SINGLE_SOFT, // --av=3 Single hash mode (Software AES)
+ AV_DOUBLE_SOFT, // --av=4 Double hash mode (Software AES)
+ AV_TRIPLE, // --av=5 Triple hash mode
+ AV_QUAD, // --av=6 Quard hash mode
+ AV_PENTA, // --av=7 Penta hash mode
+ AV_TRIPLE_SOFT, // --av=8 Triple hash mode (Software AES)
+ AV_QUAD_SOFT, // --av=9 Quard hash mode (Software AES)
+ AV_PENTA_SOFT, // --av=10 Penta hash mode (Software AES)
AV_MAX
};