Added CMake option WITH_BENCHMARK.
This commit is contained in:
parent
ccebf6bb20
commit
a152d6be42
19 changed files with 245 additions and 121 deletions
|
@ -45,24 +45,30 @@ public:
|
|||
inline const VirtualMemory *memory() const override { return nullptr; }
|
||||
inline size_t id() const override { return m_id; }
|
||||
inline uint64_t rawHashes() const override { return m_count; }
|
||||
inline void jobEarlyNotification(const Job&) override {}
|
||||
|
||||
void getHashrateData(uint64_t& hashCount, uint64_t& timeStamp) const override;
|
||||
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
inline uint64_t benchData() const override { return m_benchData; }
|
||||
inline uint64_t benchDoneTime() const override { return m_benchDoneTime; }
|
||||
void getHashrateData(uint64_t& hashCount, uint64_t& timeStamp) const override;
|
||||
inline void jobEarlyNotification(const Job&) override {}
|
||||
# endif
|
||||
|
||||
protected:
|
||||
void storeStats();
|
||||
|
||||
const int64_t m_affinity;
|
||||
const size_t m_id;
|
||||
uint64_t m_hashCount[2] = {};
|
||||
uint64_t m_timestamp[2] = {};
|
||||
std::atomic<uint32_t> m_index = {};
|
||||
uint32_t m_node = 0;
|
||||
uint64_t m_count = 0;
|
||||
std::atomic<uint32_t> m_index = {};
|
||||
uint32_t m_node = 0;
|
||||
uint64_t m_count = 0;
|
||||
uint64_t m_hashCount[2] = {};
|
||||
uint64_t m_timestamp[2] = {};
|
||||
|
||||
uint64_t m_benchData = 0;
|
||||
uint64_t m_benchDoneTime = 0;
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
uint64_t m_benchData = 0;
|
||||
uint64_t m_benchDoneTime = 0;
|
||||
# endif
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -67,9 +67,11 @@ public:
|
|||
Hashrate *hashrate = nullptr;
|
||||
IBackend *backend = nullptr;
|
||||
|
||||
uint32_t bench = 0;
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
Algorithm benchAlgo = Algorithm::RX_0;
|
||||
uint32_t bench = 0;
|
||||
uint64_t startTime = 0;
|
||||
# endif
|
||||
};
|
||||
|
||||
|
||||
|
@ -108,10 +110,12 @@ void xmrig::Workers<T>::setBackend(IBackend *backend)
|
|||
template<class T>
|
||||
void xmrig::Workers<T>::start(const std::vector<T> &data)
|
||||
{
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
if (!data.empty()) {
|
||||
d_ptr->bench = data.front().miner->job().bench();
|
||||
d_ptr->benchAlgo = data.front().miner->job().algorithm();
|
||||
d_ptr->bench = data.front().miner->job().bench();
|
||||
d_ptr->benchAlgo = data.front().algorithm;
|
||||
}
|
||||
# endif
|
||||
|
||||
for (const T &item : data) {
|
||||
m_workers.push_back(new Thread<T>(d_ptr->backend, m_workers.size(), item));
|
||||
|
@ -123,12 +127,17 @@ void xmrig::Workers<T>::start(const std::vector<T> &data)
|
|||
for (Thread<T> *worker : m_workers) {
|
||||
worker->start(Workers<T>::onReady);
|
||||
|
||||
if (!d_ptr->bench) {
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
if (!d_ptr->bench)
|
||||
# endif
|
||||
{
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(20));
|
||||
}
|
||||
}
|
||||
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
d_ptr->startTime = Chrono::steadyMSecs();
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -170,21 +179,22 @@ bool xmrig::Workers<T>::tick(uint64_t)
|
|||
return true;
|
||||
}
|
||||
|
||||
uint64_t timeStamp = Chrono::steadyMSecs();
|
||||
|
||||
bool totalAvailable = true;
|
||||
uint64_t ts = Chrono::steadyMSecs();
|
||||
bool totalAvailable = true;
|
||||
uint64_t totalHashCount = 0;
|
||||
|
||||
uint32_t benchDone = 0;
|
||||
uint64_t benchData = 0;
|
||||
uint64_t benchDoneTime = 0;
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
uint32_t benchDone = 0;
|
||||
uint64_t benchData = 0;
|
||||
uint64_t benchDoneTime = 0;
|
||||
# endif
|
||||
|
||||
for (Thread<T> *handle : m_workers) {
|
||||
IWorker* worker = handle->worker();
|
||||
if (worker) {
|
||||
uint64_t hashCount;
|
||||
getHashrateData<T>(worker, hashCount, timeStamp);
|
||||
d_ptr->hashrate->add(handle->id() + 1, hashCount, timeStamp);
|
||||
getHashrateData<T>(worker, hashCount, ts);
|
||||
d_ptr->hashrate->add(handle->id() + 1, hashCount, ts);
|
||||
|
||||
const uint64_t n = worker->rawHashes();
|
||||
if (n == 0) {
|
||||
|
@ -192,6 +202,7 @@ bool xmrig::Workers<T>::tick(uint64_t)
|
|||
}
|
||||
totalHashCount += n;
|
||||
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
if (d_ptr->bench && worker->benchDoneTime()) {
|
||||
++benchDone;
|
||||
benchData ^= worker->benchData();
|
||||
|
@ -199,6 +210,7 @@ bool xmrig::Workers<T>::tick(uint64_t)
|
|||
benchDoneTime = worker->benchDoneTime();
|
||||
}
|
||||
}
|
||||
# endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -206,6 +218,7 @@ bool xmrig::Workers<T>::tick(uint64_t)
|
|||
d_ptr->hashrate->add(0, totalHashCount, Chrono::steadyMSecs());
|
||||
}
|
||||
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
if (d_ptr->bench) {
|
||||
Pool::benchProgress = std::min<uint32_t>(static_cast<uint32_t>((totalHashCount * 100U) / d_ptr->bench), 100U);
|
||||
|
||||
|
@ -232,6 +245,7 @@ bool xmrig::Workers<T>::tick(uint64_t)
|
|||
return false;
|
||||
}
|
||||
}
|
||||
# endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -47,11 +47,14 @@ public:
|
|||
virtual size_t id() const = 0;
|
||||
virtual size_t intensity() const = 0;
|
||||
virtual uint64_t rawHashes() const = 0;
|
||||
virtual uint64_t benchData() const = 0;
|
||||
virtual uint64_t benchDoneTime() const = 0;
|
||||
virtual void getHashrateData(uint64_t&, uint64_t&) const = 0;
|
||||
virtual void start() = 0;
|
||||
virtual void jobEarlyNotification(const Job&) = 0;
|
||||
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
virtual uint64_t benchData() const = 0;
|
||||
virtual uint64_t benchDoneTime() const = 0;
|
||||
# endif
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -60,10 +60,16 @@ static constexpr uint32_t kReserveCount = 32768;
|
|||
template<size_t N>
|
||||
inline bool nextRound(WorkerJob<N> &job)
|
||||
{
|
||||
const Job& curJob = job.currentJob();
|
||||
const uint32_t bench = curJob.bench();
|
||||
if (!job.nextRound(bench ? 1 : kReserveCount, 1)) {
|
||||
JobResults::done(curJob);
|
||||
const auto ¤tJob = 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;
|
||||
}
|
||||
|
@ -270,6 +276,7 @@ void xmrig::CpuWorker<N>::start()
|
|||
for (size_t i = 0; i < N; ++i) {
|
||||
const uint64_t value = *reinterpret_cast<uint64_t*>(m_hash + (i * 32) + 24);
|
||||
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
if (job.bench()) {
|
||||
if (current_job_nonces[i] < job.bench()) {
|
||||
m_benchData ^= value;
|
||||
|
@ -279,7 +286,9 @@ void xmrig::CpuWorker<N>::start()
|
|||
return;
|
||||
}
|
||||
}
|
||||
else if (value < job.target()) {
|
||||
else
|
||||
# endif
|
||||
if (value < job.target()) {
|
||||
JobResults::submit(job, current_job_nonces[i], m_hash + (i * 32));
|
||||
}
|
||||
}
|
||||
|
@ -376,8 +385,15 @@ void xmrig::CpuWorker<N>::consumeJob()
|
|||
return;
|
||||
}
|
||||
|
||||
const uint32_t bench = m_miner->job().bench();
|
||||
m_job.add(m_miner->job(), bench ? 1 : kReserveCount, Nonce::CPU);
|
||||
auto job = m_miner->job();
|
||||
|
||||
# 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
|
||||
if (m_job.currentJob().algorithm().family() == Algorithm::RANDOM_X) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue