Removed m_bench field from Job class.
This commit is contained in:
parent
36b1523194
commit
7fc7b976bf
19 changed files with 44 additions and 68 deletions
|
@ -112,7 +112,7 @@ void xmrig::Workers<T>::start(const std::vector<T> &data)
|
||||||
{
|
{
|
||||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||||
if (!data.empty()) {
|
if (!data.empty()) {
|
||||||
d_ptr->bench = data.front().miner->job().bench();
|
d_ptr->bench = data.front().benchSize;
|
||||||
d_ptr->benchAlgo = data.front().algorithm;
|
d_ptr->benchAlgo = data.front().algorithm;
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
|
@ -335,7 +335,7 @@ void xmrig::CpuBackend::setJob(const Job &job)
|
||||||
|
|
||||||
const CpuConfig &cpu = d_ptr->controller->config()->cpu();
|
const CpuConfig &cpu = d_ptr->controller->config()->cpu();
|
||||||
|
|
||||||
std::vector<CpuLaunchData> threads = cpu.get(d_ptr->controller->miner(), job.algorithm());
|
std::vector<CpuLaunchData> threads = cpu.get(d_ptr->controller->miner(), job.algorithm(), d_ptr->controller->config()->pools().benchSize());
|
||||||
if (!d_ptr->threads.empty() && d_ptr->threads.size() == threads.size() && std::equal(d_ptr->threads.begin(), d_ptr->threads.end(), threads.begin())) {
|
if (!d_ptr->threads.empty() && d_ptr->threads.size() == threads.size() && std::equal(d_ptr->threads.begin(), d_ptr->threads.end(), threads.begin())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,7 +113,7 @@ size_t xmrig::CpuConfig::memPoolSize() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<xmrig::CpuLaunchData> xmrig::CpuConfig::get(const Miner *miner, const Algorithm &algorithm) const
|
std::vector<xmrig::CpuLaunchData> xmrig::CpuConfig::get(const Miner *miner, const Algorithm &algorithm, uint32_t benchSize) const
|
||||||
{
|
{
|
||||||
std::vector<CpuLaunchData> out;
|
std::vector<CpuLaunchData> out;
|
||||||
const CpuThreads &threads = m_threads.get(algorithm);
|
const CpuThreads &threads = m_threads.get(algorithm);
|
||||||
|
@ -125,7 +125,7 @@ std::vector<xmrig::CpuLaunchData> xmrig::CpuConfig::get(const Miner *miner, cons
|
||||||
out.reserve(threads.count());
|
out.reserve(threads.count());
|
||||||
|
|
||||||
for (const CpuThread &thread : threads.data()) {
|
for (const CpuThread &thread : threads.data()) {
|
||||||
out.emplace_back(miner, algorithm, *this, thread);
|
out.emplace_back(miner, algorithm, *this, thread, benchSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
|
|
|
@ -72,7 +72,7 @@ public:
|
||||||
bool isHwAES() const;
|
bool isHwAES() const;
|
||||||
rapidjson::Value toJSON(rapidjson::Document &doc) const;
|
rapidjson::Value toJSON(rapidjson::Document &doc) const;
|
||||||
size_t memPoolSize() const;
|
size_t memPoolSize() const;
|
||||||
std::vector<CpuLaunchData> get(const Miner *miner, const Algorithm &algorithm) const;
|
std::vector<CpuLaunchData> get(const Miner *miner, const Algorithm &algorithm, uint32_t benchSize) const;
|
||||||
void read(const rapidjson::Value &value);
|
void read(const rapidjson::Value &value);
|
||||||
|
|
||||||
inline bool isEnabled() const { return m_enabled; }
|
inline bool isEnabled() const { return m_enabled; }
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
|
||||||
xmrig::CpuLaunchData::CpuLaunchData(const Miner *miner, const Algorithm &algorithm, const CpuConfig &config, const CpuThread &thread) :
|
xmrig::CpuLaunchData::CpuLaunchData(const Miner *miner, const Algorithm &algorithm, const CpuConfig &config, const CpuThread &thread, uint32_t benchSize) :
|
||||||
algorithm(algorithm),
|
algorithm(algorithm),
|
||||||
assembly(config.assembly()),
|
assembly(config.assembly()),
|
||||||
astrobwtAVX2(config.astrobwtAVX2()),
|
astrobwtAVX2(config.astrobwtAVX2()),
|
||||||
|
@ -43,6 +43,7 @@ xmrig::CpuLaunchData::CpuLaunchData(const Miner *miner, const Algorithm &algorit
|
||||||
priority(config.priority()),
|
priority(config.priority()),
|
||||||
affinity(thread.affinity()),
|
affinity(thread.affinity()),
|
||||||
miner(miner),
|
miner(miner),
|
||||||
|
benchSize(benchSize),
|
||||||
intensity(std::min<uint32_t>(thread.intensity(), algorithm.maxIntensity()))
|
intensity(std::min<uint32_t>(thread.intensity(), algorithm.maxIntensity()))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ class Miner;
|
||||||
class CpuLaunchData
|
class CpuLaunchData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CpuLaunchData(const Miner *miner, const Algorithm &algorithm, const CpuConfig &config, const CpuThread &thread);
|
CpuLaunchData(const Miner *miner, const Algorithm &algorithm, const CpuConfig &config, const CpuThread &thread, uint32_t benchSize);
|
||||||
|
|
||||||
bool isEqual(const CpuLaunchData &other) const;
|
bool isEqual(const CpuLaunchData &other) const;
|
||||||
CnHash::AlgoVariant av() const;
|
CnHash::AlgoVariant av() const;
|
||||||
|
@ -66,6 +66,7 @@ public:
|
||||||
const int priority;
|
const int priority;
|
||||||
const int64_t affinity;
|
const int64_t affinity;
|
||||||
const Miner *miner;
|
const Miner *miner;
|
||||||
|
const uint32_t benchSize;
|
||||||
const uint32_t intensity;
|
const uint32_t intensity;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -58,18 +58,10 @@ static constexpr uint32_t kReserveCount = 32768;
|
||||||
|
|
||||||
|
|
||||||
template<size_t N>
|
template<size_t N>
|
||||||
inline bool nextRound(WorkerJob<N> &job)
|
inline bool nextRound(WorkerJob<N> &job, uint32_t benchSize)
|
||||||
{
|
{
|
||||||
const auto ¤tJob = job.currentJob();
|
if (!job.nextRound(benchSize ? 1 : kReserveCount, 1)) {
|
||||||
|
JobResults::done(job.currentJob());
|
||||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
|
||||||
const uint32_t rounds = currentJob.bench() ? 1 : kReserveCount;
|
|
||||||
# else
|
|
||||||
constexpr uint32_t rounds = kReserveCount;
|
|
||||||
# endif
|
|
||||||
|
|
||||||
if (!job.nextRound(rounds, 1)) {
|
|
||||||
JobResults::done(currentJob);
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -93,6 +85,7 @@ xmrig::CpuWorker<N>::CpuWorker(size_t id, const CpuLaunchData &data) :
|
||||||
m_av(data.av()),
|
m_av(data.av()),
|
||||||
m_astrobwtMaxSize(data.astrobwtMaxSize * 1000),
|
m_astrobwtMaxSize(data.astrobwtMaxSize * 1000),
|
||||||
m_miner(data.miner),
|
m_miner(data.miner),
|
||||||
|
m_benchSize(data.benchSize),
|
||||||
m_ctx()
|
m_ctx()
|
||||||
{
|
{
|
||||||
m_memory = new VirtualMemory(m_algorithm.l3() * N, data.hugePages, false, true, m_node);
|
m_memory = new VirtualMemory(m_algorithm.l3() * N, data.hugePages, false, true, m_node);
|
||||||
|
@ -247,7 +240,7 @@ void xmrig::CpuWorker<N>::start()
|
||||||
randomx_calculate_hash_first(m_vm, tempHash, m_job.blob(), job.size());
|
randomx_calculate_hash_first(m_vm, tempHash, m_job.blob(), job.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!nextRound(m_job)) {
|
if (!nextRound(m_job, m_benchSize)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,7 +260,7 @@ void xmrig::CpuWorker<N>::start()
|
||||||
fn(job.algorithm())(m_job.blob(), job.size(), m_hash, m_ctx, job.height());
|
fn(job.algorithm())(m_job.blob(), job.size(), m_hash, m_ctx, job.height());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!nextRound(m_job)) {
|
if (!nextRound(m_job, m_benchSize)) {
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -277,8 +270,8 @@ void xmrig::CpuWorker<N>::start()
|
||||||
const uint64_t value = *reinterpret_cast<uint64_t*>(m_hash + (i * 32) + 24);
|
const uint64_t value = *reinterpret_cast<uint64_t*>(m_hash + (i * 32) + 24);
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||||
if (job.bench()) {
|
if (m_benchSize) {
|
||||||
if (current_job_nonces[i] < job.bench()) {
|
if (current_job_nonces[i] < m_benchSize) {
|
||||||
m_benchData ^= value;
|
m_benchData ^= value;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -385,15 +378,7 @@ void xmrig::CpuWorker<N>::consumeJob()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto job = m_miner->job();
|
m_job.add(m_miner->job(), m_benchSize ? 1 : kReserveCount, Nonce::CPU);
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
|
||||||
const uint32_t rounds = job.bench() ? 1 : kReserveCount;
|
|
||||||
# else
|
|
||||||
constexpr uint32_t rounds = kReserveCount;
|
|
||||||
# endif
|
|
||||||
|
|
||||||
m_job.add(job, rounds, Nonce::CPU);
|
|
||||||
|
|
||||||
# ifdef XMRIG_ALGO_RANDOMX
|
# ifdef XMRIG_ALGO_RANDOMX
|
||||||
if (m_job.currentJob().algorithm().family() == Algorithm::RANDOM_X) {
|
if (m_job.currentJob().algorithm().family() == Algorithm::RANDOM_X) {
|
||||||
|
|
|
@ -73,6 +73,7 @@ private:
|
||||||
void allocateCnCtx();
|
void allocateCnCtx();
|
||||||
void consumeJob();
|
void consumeJob();
|
||||||
|
|
||||||
|
alignas(16) uint8_t m_hash[N * 32]{ 0 };
|
||||||
const Algorithm m_algorithm;
|
const Algorithm m_algorithm;
|
||||||
const Assembly m_assembly;
|
const Assembly m_assembly;
|
||||||
const bool m_astrobwtAVX2;
|
const bool m_astrobwtAVX2;
|
||||||
|
@ -81,8 +82,8 @@ private:
|
||||||
const CnHash::AlgoVariant m_av;
|
const CnHash::AlgoVariant m_av;
|
||||||
const int m_astrobwtMaxSize;
|
const int m_astrobwtMaxSize;
|
||||||
const Miner *m_miner;
|
const Miner *m_miner;
|
||||||
|
const uint32_t m_benchSize;
|
||||||
cryptonight_ctx *m_ctx[N];
|
cryptonight_ctx *m_ctx[N];
|
||||||
alignas(16) uint8_t m_hash[N * 32]{ 0 };
|
|
||||||
VirtualMemory *m_memory = nullptr;
|
VirtualMemory *m_memory = nullptr;
|
||||||
WorkerJob<N> m_job;
|
WorkerJob<N> m_job;
|
||||||
|
|
||||||
|
|
|
@ -30,9 +30,9 @@
|
||||||
|
|
||||||
xmrig::CudaLaunchData::CudaLaunchData(const Miner *miner, const Algorithm &algorithm, const CudaThread &thread, const CudaDevice &device) :
|
xmrig::CudaLaunchData::CudaLaunchData(const Miner *miner, const Algorithm &algorithm, const CudaThread &thread, const CudaDevice &device) :
|
||||||
algorithm(algorithm),
|
algorithm(algorithm),
|
||||||
miner(miner),
|
|
||||||
device(device),
|
device(device),
|
||||||
thread(thread)
|
thread(thread),
|
||||||
|
miner(miner)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,9 +54,10 @@ public:
|
||||||
static const char *tag();
|
static const char *tag();
|
||||||
|
|
||||||
const Algorithm algorithm;
|
const Algorithm algorithm;
|
||||||
const Miner *miner;
|
|
||||||
const CudaDevice &device;
|
const CudaDevice &device;
|
||||||
const CudaThread thread;
|
const CudaThread thread;
|
||||||
|
const Miner *miner;
|
||||||
|
const uint32_t benchSize = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,7 @@ public:
|
||||||
const OclDevice device;
|
const OclDevice device;
|
||||||
const OclPlatform platform;
|
const OclPlatform platform;
|
||||||
const OclThread thread;
|
const OclThread thread;
|
||||||
|
const uint32_t benchSize = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -174,10 +174,6 @@ void xmrig::Job::copy(const Job &other)
|
||||||
memcpy(m_rawBlob, other.m_rawBlob, sizeof(m_rawBlob));
|
memcpy(m_rawBlob, other.m_rawBlob, sizeof(m_rawBlob));
|
||||||
memcpy(m_rawTarget, other.m_rawTarget, sizeof(m_rawTarget));
|
memcpy(m_rawTarget, other.m_rawTarget, sizeof(m_rawTarget));
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
|
||||||
m_bench = other.m_bench;
|
|
||||||
# endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -209,8 +205,4 @@ void xmrig::Job::move(Job &&other)
|
||||||
memcpy(m_rawBlob, other.m_rawBlob, sizeof(m_rawBlob));
|
memcpy(m_rawBlob, other.m_rawBlob, sizeof(m_rawBlob));
|
||||||
memcpy(m_rawTarget, other.m_rawTarget, sizeof(m_rawTarget));
|
memcpy(m_rawTarget, other.m_rawTarget, sizeof(m_rawTarget));
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
|
||||||
m_bench = other.m_bench;
|
|
||||||
# endif
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,11 +111,6 @@ public:
|
||||||
inline Job &operator=(const Job &other) { copy(other); return *this; }
|
inline Job &operator=(const Job &other) { copy(other); return *this; }
|
||||||
inline Job &operator=(Job &&other) noexcept { move(std::move(other)); return *this; }
|
inline Job &operator=(Job &&other) noexcept { move(std::move(other)); return *this; }
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
|
||||||
inline uint32_t bench() const { return m_bench; }
|
|
||||||
inline void setBench(uint32_t bench) { m_bench = bench; }
|
|
||||||
# endif
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void copy(const Job &other);
|
void copy(const Job &other);
|
||||||
void move(Job &&other);
|
void move(Job &&other);
|
||||||
|
@ -140,10 +135,6 @@ private:
|
||||||
char m_rawTarget[24]{};
|
char m_rawTarget[24]{};
|
||||||
String m_rawSeedHash;
|
String m_rawSeedHash;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
|
||||||
uint32_t m_bench = 0;
|
|
||||||
# endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -59,5 +59,4 @@ void xmrig::NullClient::setPool(const Pool& pool)
|
||||||
}
|
}
|
||||||
|
|
||||||
m_job.setAlgorithm(m_pool.algorithm().id());
|
m_job.setAlgorithm(m_pool.algorithm().id());
|
||||||
m_job.setBench(m_pool.benchSize());
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,7 +113,7 @@ public:
|
||||||
inline void setUser(const String &user) { m_user = user; }
|
inline void setUser(const String &user) { m_user = user; }
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||||
inline uint64_t benchSize() const { return m_benchSize; }
|
inline uint32_t benchSize() const { return m_benchSize; }
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
inline bool operator!=(const Pool &other) const { return !isEqual(other); }
|
inline bool operator!=(const Pool &other) const { return !isEqual(other); }
|
||||||
|
|
|
@ -65,18 +65,6 @@ bool xmrig::Pools::isEqual(const Pools &other) const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int xmrig::Pools::donateLevel() const
|
|
||||||
{
|
|
||||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
|
||||||
if (m_data.size() == 1 && m_data.front().mode() == Pool::MODE_BENCHMARK) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
|
|
||||||
return m_donateLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
xmrig::IStrategy *xmrig::Pools::createStrategy(IStrategyListener *listener) const
|
xmrig::IStrategy *xmrig::Pools::createStrategy(IStrategyListener *listener) const
|
||||||
{
|
{
|
||||||
if (active() == 1) {
|
if (active() == 1) {
|
||||||
|
@ -153,6 +141,18 @@ void xmrig::Pools::load(const IJsonReader &reader)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t xmrig::Pools::benchSize() const
|
||||||
|
{
|
||||||
|
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||||
|
if (m_data.size() == 1 && m_data.front().mode() == Pool::MODE_BENCHMARK) {
|
||||||
|
return m_data.front().benchSize();
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void xmrig::Pools::print() const
|
void xmrig::Pools::print() const
|
||||||
{
|
{
|
||||||
size_t i = 1;
|
size_t i = 1;
|
||||||
|
|
|
@ -58,6 +58,7 @@ public:
|
||||||
Pools();
|
Pools();
|
||||||
|
|
||||||
inline const std::vector<Pool> &data() const { return m_data; }
|
inline const std::vector<Pool> &data() const { return m_data; }
|
||||||
|
inline int donateLevel() const { return benchSize() ? 0 : m_donateLevel; }
|
||||||
inline int retries() const { return m_retries; }
|
inline int retries() const { return m_retries; }
|
||||||
inline int retryPause() const { return m_retryPause; }
|
inline int retryPause() const { return m_retryPause; }
|
||||||
inline ProxyDonate proxyDonate() const { return m_proxyDonate; }
|
inline ProxyDonate proxyDonate() const { return m_proxyDonate; }
|
||||||
|
@ -66,10 +67,10 @@ public:
|
||||||
inline bool operator==(const Pools &other) const { return isEqual(other); }
|
inline bool operator==(const Pools &other) const { return isEqual(other); }
|
||||||
|
|
||||||
bool isEqual(const Pools &other) const;
|
bool isEqual(const Pools &other) const;
|
||||||
int donateLevel() const;
|
|
||||||
IStrategy *createStrategy(IStrategyListener *listener) const;
|
IStrategy *createStrategy(IStrategyListener *listener) const;
|
||||||
rapidjson::Value toJSON(rapidjson::Document &doc) const;
|
rapidjson::Value toJSON(rapidjson::Document &doc) const;
|
||||||
size_t active() const;
|
size_t active() const;
|
||||||
|
uint32_t benchSize() const;
|
||||||
void load(const IJsonReader &reader);
|
void load(const IJsonReader &reader);
|
||||||
void print() const;
|
void print() const;
|
||||||
|
|
||||||
|
|
|
@ -128,6 +128,8 @@ void xmrig::Network::onActive(IStrategy *strategy, IClient *client)
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||||
if (pool.mode() == Pool::MODE_BENCHMARK) {
|
if (pool.mode() == Pool::MODE_BENCHMARK) {
|
||||||
|
m_benchSize = pool.benchSize();
|
||||||
|
|
||||||
LOG_NOTICE("%s " MAGENTA_BOLD("start benchmark ") "hashes " CYAN_BOLD("%" PRIu64 "M") " algo " WHITE_BOLD("%s") " print_time " CYAN_BOLD("%us"),
|
LOG_NOTICE("%s " MAGENTA_BOLD("start benchmark ") "hashes " CYAN_BOLD("%" PRIu64 "M") " algo " WHITE_BOLD("%s") " print_time " CYAN_BOLD("%us"),
|
||||||
Tags::bench(),
|
Tags::bench(),
|
||||||
pool.benchSize() / 1000000,
|
pool.benchSize() / 1000000,
|
||||||
|
@ -270,7 +272,7 @@ void xmrig::Network::setJob(IClient *client, const Job &job, bool donate)
|
||||||
const char *scale = NetworkState::scaleDiff(diff);
|
const char *scale = NetworkState::scaleDiff(diff);
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||||
if (!job.bench())
|
if (!m_benchSize)
|
||||||
# endif
|
# endif
|
||||||
{
|
{
|
||||||
if (job.height()) {
|
if (job.height()) {
|
||||||
|
|
|
@ -92,6 +92,7 @@ private:
|
||||||
IStrategy *m_strategy = nullptr;
|
IStrategy *m_strategy = nullptr;
|
||||||
NetworkState *m_state = nullptr;
|
NetworkState *m_state = nullptr;
|
||||||
Timer *m_timer = nullptr;
|
Timer *m_timer = nullptr;
|
||||||
|
uint32_t m_benchSize = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue