mirror of
https://github.com/xmrig/xmrig.git
synced 2024-12-23 12:09:22 +00:00
Added option "init-threads".
This commit is contained in:
parent
2876702ea2
commit
4a32494060
4 changed files with 31 additions and 7 deletions
|
@ -29,12 +29,18 @@
|
|||
#include "rapidjson/document.h"
|
||||
|
||||
|
||||
#ifdef XMRIG_ALGO_RANDOMX
|
||||
# include "crypto/rx/Rx.h"
|
||||
#endif
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
static const char *kCn = "cn";
|
||||
static const char *kEnabled = "enabled";
|
||||
static const char *kHugePages = "huge-pages";
|
||||
static const char *kHwAes = "hw-aes";
|
||||
static const char *kInitThreads = "init-threads";
|
||||
static const char *kPriority = "priority";
|
||||
|
||||
#ifdef XMRIG_FEATURE_ASM
|
||||
|
@ -89,6 +95,7 @@ rapidjson::Value xmrig::CpuConfig::toJSON(rapidjson::Document &doc) const
|
|||
obj.AddMember(StringRef(kHugePages), m_hugePages, allocator);
|
||||
obj.AddMember(StringRef(kHwAes), m_aes == AES_AUTO ? Value(kNullType) : Value(m_aes == AES_HW), allocator);
|
||||
obj.AddMember(StringRef(kPriority), priority() != -1 ? Value(priority()) : Value(kNullType), allocator);
|
||||
obj.AddMember(StringRef(kInitThreads), m_initThreads, allocator);
|
||||
|
||||
# ifdef XMRIG_FEATURE_ASM
|
||||
obj.AddMember(StringRef(kAsm), m_assembly.toJSON(), allocator);
|
||||
|
@ -122,8 +129,9 @@ std::vector<xmrig::CpuLaunchData> xmrig::CpuConfig::get(const Miner *miner, cons
|
|||
void xmrig::CpuConfig::read(const rapidjson::Value &value)
|
||||
{
|
||||
if (value.IsObject()) {
|
||||
m_enabled = Json::getBool(value, kEnabled, m_enabled);
|
||||
m_hugePages = Json::getBool(value, kHugePages, m_hugePages);
|
||||
m_enabled = Json::getBool(value, kEnabled, m_enabled);
|
||||
m_hugePages = Json::getBool(value, kHugePages, m_hugePages);
|
||||
m_initThreads = Json::getInt(value, kInitThreads, m_initThreads);
|
||||
|
||||
setAesMode(Json::getValue(value, kHwAes));
|
||||
setPriority(Json::getInt(value, kPriority, -1));
|
||||
|
@ -132,6 +140,10 @@ void xmrig::CpuConfig::read(const rapidjson::Value &value)
|
|||
m_assembly = Json::getValue(value, kAsm);
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_RANDOMX
|
||||
Rx::setInitThreads(m_initThreads);
|
||||
# endif
|
||||
|
||||
if (!m_threads.read(value)) {
|
||||
generate();
|
||||
}
|
||||
|
|
|
@ -69,6 +69,7 @@ private:
|
|||
bool m_enabled = true;
|
||||
bool m_hugePages = true;
|
||||
bool m_shouldSave = false;
|
||||
int m_initThreads = -1;
|
||||
int m_priority = -1;
|
||||
Threads<CpuThread> m_threads;
|
||||
};
|
||||
|
|
|
@ -61,8 +61,8 @@ public:
|
|||
inline void unlock() { uv_mutex_unlock(&mutex); }
|
||||
|
||||
|
||||
RxDataset *dataset = nullptr;
|
||||
uint32_t initThreads = std::thread::hardware_concurrency();
|
||||
int initThreads = -1;
|
||||
RxDataset *dataset = nullptr;
|
||||
uv_mutex_t mutex;
|
||||
};
|
||||
|
||||
|
@ -121,13 +121,15 @@ xmrig::RxDataset *xmrig::Rx::dataset(const uint8_t *seed, const Algorithm &algor
|
|||
}
|
||||
|
||||
if (!d_ptr->dataset->isReady(seed, algorithm)) {
|
||||
const uint64_t ts = Chrono::steadyMSecs();
|
||||
const uint64_t ts = Chrono::steadyMSecs();
|
||||
const uint32_t threads = d_ptr->initThreads < 1 ? static_cast<uint32_t>(Cpu::info()->threads())
|
||||
: static_cast<uint32_t>(d_ptr->initThreads);
|
||||
|
||||
if (d_ptr->dataset->get() != nullptr) {
|
||||
LOG_INFO("%s" MAGENTA_BOLD(" init dataset") " algo " WHITE_BOLD("%s (") CYAN_BOLD("%u") WHITE_BOLD(" threads)") BLACK_BOLD(" seed %s..."),
|
||||
tag,
|
||||
algorithm.shortName(),
|
||||
d_ptr->initThreads,
|
||||
threads,
|
||||
Buffer::toHex(seed, 8).data()
|
||||
);
|
||||
}
|
||||
|
@ -139,7 +141,7 @@ xmrig::RxDataset *xmrig::Rx::dataset(const uint8_t *seed, const Algorithm &algor
|
|||
);
|
||||
}
|
||||
|
||||
d_ptr->dataset->init(seed, algorithm, d_ptr->initThreads);
|
||||
d_ptr->dataset->init(seed, algorithm, threads);
|
||||
|
||||
LOG_INFO("%s" GREEN(" init done") BLACK_BOLD(" (%" PRIu64 " ms)"), tag, Chrono::steadyMSecs() - ts);
|
||||
}
|
||||
|
@ -151,6 +153,14 @@ xmrig::RxDataset *xmrig::Rx::dataset(const uint8_t *seed, const Algorithm &algor
|
|||
}
|
||||
|
||||
|
||||
void xmrig::Rx::setInitThreads(int count)
|
||||
{
|
||||
d_ptr->lock();
|
||||
d_ptr->initThreads = count;
|
||||
d_ptr->unlock();
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Rx::stop()
|
||||
{
|
||||
delete d_ptr;
|
||||
|
|
|
@ -44,6 +44,7 @@ class Rx
|
|||
public:
|
||||
static RxDataset *dataset();
|
||||
static RxDataset *dataset(const uint8_t *seed, const Algorithm &algorithm, bool hugePages = true);
|
||||
static void setInitThreads(int count);
|
||||
static void stop();
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue