mirror of
https://github.com/xmrig/xmrig.git
synced 2025-03-23 23:58:53 +00:00
Merge pull request #1886 from cohcho/fix_cpu_stats
CPU: use raw counter
This commit is contained in:
commit
eb8cf3ee5a
3 changed files with 25 additions and 13 deletions
|
@ -160,6 +160,29 @@ void xmrig::Workers<T>::tick(uint64_t)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<>
|
||||||
|
void xmrig::Workers<xmrig::CpuLaunchData>::tick(uint64_t)
|
||||||
|
{
|
||||||
|
if (!d_ptr->hashrate) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const uint64_t timestamp = Chrono::steadyMSecs();
|
||||||
|
uint64_t totalHashCount = 0;
|
||||||
|
for (Thread<CpuLaunchData> *handle : m_workers) {
|
||||||
|
if (handle->worker()) {
|
||||||
|
const uint64_t hashCount = handle->worker()->rawHashes();
|
||||||
|
d_ptr->hashrate->add(handle->id() + 1, hashCount, timestamp);
|
||||||
|
totalHashCount += hashCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (totalHashCount > 0) {
|
||||||
|
d_ptr->hashrate->add(0, totalHashCount, timestamp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
xmrig::IWorker *xmrig::Workers<T>::create(Thread<T> *)
|
xmrig::IWorker *xmrig::Workers<T>::create(Thread<T> *)
|
||||||
{
|
{
|
||||||
|
|
|
@ -88,6 +88,8 @@ void xmrig::Workers<T>::jobEarlyNotification(const Job& job)
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
IWorker *Workers<CpuLaunchData>::create(Thread<CpuLaunchData> *handle);
|
IWorker *Workers<CpuLaunchData>::create(Thread<CpuLaunchData> *handle);
|
||||||
|
template<>
|
||||||
|
void Workers<CpuLaunchData>::tick(uint64_t);
|
||||||
extern template class Workers<CpuLaunchData>;
|
extern template class Workers<CpuLaunchData>;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -211,25 +211,12 @@ void xmrig::CpuWorker<N>::start()
|
||||||
consumeJob();
|
consumeJob();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t storeStatsMask = 7;
|
|
||||||
|
|
||||||
# ifdef XMRIG_ALGO_RANDOMX
|
# ifdef XMRIG_ALGO_RANDOMX
|
||||||
bool first = true;
|
bool first = true;
|
||||||
alignas(16) uint64_t tempHash[8] = {};
|
alignas(16) uint64_t tempHash[8] = {};
|
||||||
|
|
||||||
// RandomX is faster, we don't need to store stats so often
|
|
||||||
# ifndef XMRIG_ARM
|
|
||||||
if (m_job.currentJob().algorithm().family() == Algorithm::RANDOM_X) {
|
|
||||||
storeStatsMask = 63;
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
while (!Nonce::isOutdated(Nonce::CPU, m_job.sequence())) {
|
while (!Nonce::isOutdated(Nonce::CPU, m_job.sequence())) {
|
||||||
if ((m_count & storeStatsMask) == 0) {
|
|
||||||
storeStats();
|
|
||||||
}
|
|
||||||
|
|
||||||
const Job &job = m_job.currentJob();
|
const Job &job = m_job.currentJob();
|
||||||
|
|
||||||
if (job.algorithm().l3() != m_algorithm.l3()) {
|
if (job.algorithm().l3() != m_algorithm.l3()) {
|
||||||
|
|
Loading…
Reference in a new issue