Added reader for advanced threads.
This commit is contained in:
parent
9ce9147dad
commit
c44b299750
5 changed files with 101 additions and 18 deletions
|
@ -41,6 +41,7 @@ static char affinity_tmp[20] = { 0 };
|
|||
|
||||
|
||||
xmrig::Config::Config() : xmrig::CommonConfig(),
|
||||
m_aesMode(AES_AUTO),
|
||||
m_algoVariant(AV_AUTO),
|
||||
m_doubleHash(false),
|
||||
m_dryRun(false),
|
||||
|
@ -48,9 +49,7 @@ xmrig::Config::Config() : xmrig::CommonConfig(),
|
|||
m_safe(false),
|
||||
m_maxCpuUsage(75),
|
||||
m_printTime(60),
|
||||
m_priority(-1),
|
||||
m_affinity(-1L),
|
||||
m_threadsCount(0)
|
||||
m_priority(-1)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -162,18 +161,18 @@ bool xmrig::Config::adjust()
|
|||
m_doubleHash = true;
|
||||
}
|
||||
|
||||
if (!m_threadsCount) {
|
||||
m_threadsCount = Cpu::optimalThreadsCount(m_algorithm, m_doubleHash, m_maxCpuUsage);
|
||||
if (!m_threads.count) {
|
||||
m_threads.count = Cpu::optimalThreadsCount(m_algorithm, m_doubleHash, m_maxCpuUsage);
|
||||
}
|
||||
else if (m_safe) {
|
||||
const size_t count = Cpu::optimalThreadsCount(m_algorithm, m_doubleHash, m_maxCpuUsage);
|
||||
if (m_threadsCount > count) {
|
||||
m_threadsCount = count;
|
||||
if (m_threads.count > count) {
|
||||
m_threads.count = count;
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < m_threadsCount; ++i) {
|
||||
m_threads.push_back(CpuThread::createFromAV(i, m_algorithm, m_algoVariant, m_affinity, m_priority));
|
||||
for (size_t i = 0; i < m_threads.count; ++i) {
|
||||
m_threads.list.push_back(CpuThread::createFromAV(i, m_algorithm, m_algoVariant, m_threads.mask, m_priority));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -228,7 +227,7 @@ bool xmrig::Config::parseString(int key, const char *arg)
|
|||
|
||||
case xmrig::IConfig::ThreadsKey: /* --threads */
|
||||
if (strncmp(arg, "all", 3) == 0) {
|
||||
m_threadsCount = Cpu::threads();
|
||||
m_threads.count = Cpu::threads();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -257,7 +256,7 @@ bool xmrig::Config::parseUint64(int key, uint64_t arg)
|
|||
switch (key) {
|
||||
case xmrig::IConfig::CPUAffinityKey: /* --cpu-affinity */
|
||||
if (arg) {
|
||||
m_affinity = arg;
|
||||
m_threads.mask = arg;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -271,6 +270,23 @@ bool xmrig::Config::parseUint64(int key, uint64_t arg)
|
|||
|
||||
void xmrig::Config::parseJSON(const rapidjson::Document &doc)
|
||||
{
|
||||
const rapidjson::Value &threads = doc["threads"];
|
||||
|
||||
if (threads.IsArray()) {
|
||||
for (const rapidjson::Value &value : threads.GetArray()) {
|
||||
if (!value.IsObject()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (value.HasMember("low_power_mode")) {
|
||||
auto data = CpuThread::parse(value);
|
||||
|
||||
if (data.valid) {
|
||||
m_threads.cpu.push_back(std::move(data));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -279,7 +295,7 @@ bool xmrig::Config::parseInt(int key, int arg)
|
|||
switch (key) {
|
||||
case xmrig::IConfig::ThreadsKey: /* --threads */
|
||||
if (arg >= 0 && arg < 1024) {
|
||||
m_threadsCount = arg;
|
||||
m_threads.count = arg;
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "common/config/CommonConfig.h"
|
||||
#include "common/xmrig.h"
|
||||
#include "rapidjson/fwd.h"
|
||||
#include "workers/CpuThread.h"
|
||||
|
||||
|
||||
class Addr;
|
||||
|
@ -67,15 +68,16 @@ public:
|
|||
|
||||
void getJSON(rapidjson::Document &doc) const override;
|
||||
|
||||
inline AesMode aesMode() const { return m_aesMode; }
|
||||
inline AlgoVariant algoVariant() const { return m_algoVariant; }
|
||||
inline bool isDoubleHash() const { return m_doubleHash; }
|
||||
inline bool isDryRun() const { return m_dryRun; }
|
||||
inline bool isHugePages() const { return m_hugePages; }
|
||||
inline const std::vector<IThread *> &threads() const { return m_threads; }
|
||||
inline const std::vector<IThread *> &threads() const { return m_threads.list; }
|
||||
inline int printTime() const { return m_printTime; }
|
||||
inline int priority() const { return m_priority; }
|
||||
inline int threadsCount() const { return m_threadsCount; }
|
||||
inline int64_t affinity() const { return m_affinity; }
|
||||
inline int threadsCount() const { return m_threads.count; }
|
||||
inline int64_t affinity() const { return m_threads.mask; }
|
||||
|
||||
static Config *load(int argc, char **argv, IWatcherListener *listener);
|
||||
|
||||
|
@ -94,6 +96,19 @@ private:
|
|||
AlgoVariant getAlgoVariantLite() const;
|
||||
# endif
|
||||
|
||||
|
||||
struct Threads
|
||||
{
|
||||
inline Threads() : mask(-1L), count(0) {}
|
||||
|
||||
int64_t mask;
|
||||
size_t count;
|
||||
std::vector<CpuThread::Data> cpu;
|
||||
std::vector<IThread *> list;
|
||||
};
|
||||
|
||||
|
||||
AesMode m_aesMode;
|
||||
AlgoVariant m_algoVariant;
|
||||
bool m_doubleHash;
|
||||
bool m_dryRun;
|
||||
|
@ -102,9 +117,7 @@ private:
|
|||
int m_maxCpuUsage;
|
||||
int m_printTime;
|
||||
int m_priority;
|
||||
int64_t m_affinity;
|
||||
size_t m_threadsCount;
|
||||
std::vector<IThread *> m_threads;
|
||||
Threads m_threads;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue