mirror of
https://github.com/xmrig/xmrig.git
synced 2024-11-18 10:01:06 +00:00
#1385 "max-threads-hint" option now also limit RandomX dataset initialization threads.
This commit is contained in:
parent
3a75f39935
commit
e9e747f0d1
8 changed files with 21 additions and 14 deletions
|
@ -61,6 +61,7 @@ public:
|
||||||
inline const String &argon2Impl() const { return m_argon2Impl; }
|
inline const String &argon2Impl() const { return m_argon2Impl; }
|
||||||
inline const Threads<CpuThreads> &threads() const { return m_threads; }
|
inline const Threads<CpuThreads> &threads() const { return m_threads; }
|
||||||
inline int priority() const { return m_priority; }
|
inline int priority() const { return m_priority; }
|
||||||
|
inline uint32_t limit() const { return m_limit; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void generate();
|
void generate();
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <string.h>
|
#include <cstring>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -262,7 +262,7 @@ xmrig::CpuThreads xmrig::HwlocCpuInfo::threads(const Algorithm &algorithm, uint3
|
||||||
|
|
||||||
void xmrig::HwlocCpuInfo::processTopLevelCache(hwloc_obj_t cache, const Algorithm &algorithm, CpuThreads &threads, size_t limit) const
|
void xmrig::HwlocCpuInfo::processTopLevelCache(hwloc_obj_t cache, const Algorithm &algorithm, CpuThreads &threads, size_t limit) const
|
||||||
{
|
{
|
||||||
constexpr size_t oneMiB = 1024u * 1024u;
|
constexpr size_t oneMiB = 1024U * 1024U;
|
||||||
|
|
||||||
size_t PUs = countByType(cache, HWLOC_OBJ_PU);
|
size_t PUs = countByType(cache, HWLOC_OBJ_PU);
|
||||||
if (PUs == 0) {
|
if (PUs == 0) {
|
||||||
|
|
|
@ -234,12 +234,7 @@ public:
|
||||||
|
|
||||||
|
|
||||||
# ifdef XMRIG_ALGO_RANDOMX
|
# ifdef XMRIG_ALGO_RANDOMX
|
||||||
inline bool initRX()
|
inline bool initRX() { return Rx::init(job, controller->config()->rx(), controller->config()->cpu()); }
|
||||||
{
|
|
||||||
const auto &cpu = controller->config()->cpu();
|
|
||||||
|
|
||||||
return Rx::init(job, controller->config()->rx(), cpu.isHugePages(), cpu.isOneGbPages(), cpu.priority());
|
|
||||||
}
|
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
#include "crypto/rx/Rx.h"
|
#include "crypto/rx/Rx.h"
|
||||||
#include "backend/common/Tags.h"
|
#include "backend/common/Tags.h"
|
||||||
|
#include "backend/cpu/CpuConfig.h"
|
||||||
#include "base/io/log/Log.h"
|
#include "base/io/log/Log.h"
|
||||||
#include "crypto/rx/RxConfig.h"
|
#include "crypto/rx/RxConfig.h"
|
||||||
#include "crypto/rx/RxQueue.h"
|
#include "crypto/rx/RxQueue.h"
|
||||||
|
@ -60,7 +61,7 @@ const char *xmrig::rx_tag()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool xmrig::Rx::init(const Job &job, const RxConfig &config, bool hugePages, bool oneGbPages, int priority)
|
bool xmrig::Rx::init(const Job &job, const RxConfig &config, const CpuConfig &cpu)
|
||||||
{
|
{
|
||||||
if (job.algorithm().family() != Algorithm::RANDOM_X) {
|
if (job.algorithm().family() != Algorithm::RANDOM_X) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -70,7 +71,7 @@ bool xmrig::Rx::init(const Job &job, const RxConfig &config, bool hugePages, boo
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
d_ptr->queue.enqueue(job, config.nodeset(), config.threads(), hugePages, oneGbPages, config.mode(), priority);
|
d_ptr->queue.enqueue(job, config.nodeset(), config.threads(cpu.limit()), cpu.isHugePages(), cpu.isOneGbPages(), config.mode(), cpu.priority());
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ namespace xmrig
|
||||||
|
|
||||||
|
|
||||||
class Algorithm;
|
class Algorithm;
|
||||||
|
class CpuConfig;
|
||||||
class IRxListener;
|
class IRxListener;
|
||||||
class Job;
|
class Job;
|
||||||
class RxConfig;
|
class RxConfig;
|
||||||
|
@ -46,7 +47,7 @@ class RxDataset;
|
||||||
class Rx
|
class Rx
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static bool init(const Job &job, const RxConfig &config, bool hugePages, bool oneGbPages, int priority);
|
static bool init(const Job &job, const RxConfig &config, const CpuConfig &cpu);
|
||||||
static bool isReady(const Job &job);
|
static bool isReady(const Job &job);
|
||||||
static RxDataset *dataset(const Job &job, uint32_t nodeId);
|
static RxDataset *dataset(const Job &job, uint32_t nodeId);
|
||||||
static std::pair<uint32_t, uint32_t> hugePages();
|
static std::pair<uint32_t, uint32_t> hugePages();
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
@ -52,9 +53,17 @@ const char *xmrig::RxConfig::modeName() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32_t xmrig::RxConfig::threads() const
|
uint32_t xmrig::RxConfig::threads(uint32_t limit) const
|
||||||
{
|
{
|
||||||
return m_threads < 1 ? static_cast<uint32_t>(Cpu::info()->threads()) : static_cast<uint32_t>(m_threads);
|
if (m_threads > 0) {
|
||||||
|
return m_threads;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (limit < 100) {
|
||||||
|
return std::max(static_cast<uint32_t>(round(Cpu::info()->threads() * (limit / 100.0))), 1U);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Cpu::info()->threads();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ public:
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
const char *modeName() const;
|
const char *modeName() const;
|
||||||
uint32_t threads() const;
|
uint32_t threads(uint32_t limit = 100) const;
|
||||||
|
|
||||||
inline Mode mode() const { return m_mode; }
|
inline Mode mode() const { return m_mode; }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue