mirror of
https://github.com/xmrig/xmrig.git
synced 2025-12-26 14:02:53 -05:00
Merge branch 'beta' of https://github.com/xmrig/xmrig
This commit is contained in:
@@ -39,7 +39,7 @@
|
||||
inline static const char *format(double h, char *buf, size_t size)
|
||||
{
|
||||
if (std::isnormal(h)) {
|
||||
snprintf(buf, size, "%03.1f", h);
|
||||
snprintf(buf, size, (h < 100.0) ? "%04.2f" : "%03.1f", h);
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -23,8 +23,8 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef XMRIG_TAGS_H
|
||||
#define XMRIG_TAGS_H
|
||||
#ifndef XMRIG_BACKEND_TAGS_H
|
||||
#define XMRIG_BACKEND_TAGS_H
|
||||
|
||||
|
||||
#include <cstdint>
|
||||
@@ -35,7 +35,6 @@ namespace xmrig {
|
||||
|
||||
const char *backend_tag(uint32_t backend);
|
||||
const char *cpu_tag();
|
||||
const char *net_tag();
|
||||
|
||||
|
||||
#ifdef XMRIG_FEATURE_OPENCL
|
||||
@@ -48,7 +47,6 @@ const char *cuda_tag();
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifdef XMRIG_ALGO_RANDOMX
|
||||
const char *rx_tag();
|
||||
#endif
|
||||
@@ -57,4 +55,4 @@ const char *rx_tag();
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
#endif /* XMRIG_TAGS_H */
|
||||
#endif /* XMRIG_BACKEND_TAGS_H */
|
||||
|
||||
@@ -42,10 +42,11 @@ class Worker : public IWorker
|
||||
public:
|
||||
Worker(size_t id, int64_t affinity, int priority);
|
||||
|
||||
inline const VirtualMemory *memory() const override { return nullptr; }
|
||||
inline size_t id() const override { return m_id; }
|
||||
inline uint64_t hashCount() const override { return m_hashCount.load(std::memory_order_relaxed); }
|
||||
inline uint64_t timestamp() const override { return m_timestamp.load(std::memory_order_relaxed); }
|
||||
inline const VirtualMemory *memory() const override { return nullptr; }
|
||||
inline size_t id() const override { return m_id; }
|
||||
inline uint64_t hashCount() const override { return m_hashCount.load(std::memory_order_relaxed); }
|
||||
inline uint64_t timestamp() const override { return m_timestamp.load(std::memory_order_relaxed); }
|
||||
inline void jobEarlyNotification(const Job&) override {}
|
||||
|
||||
protected:
|
||||
void storeStats();
|
||||
|
||||
@@ -41,7 +41,7 @@ class WorkerJob
|
||||
{
|
||||
public:
|
||||
inline const Job ¤tJob() const { return m_jobs[index()]; }
|
||||
inline uint32_t *nonce(size_t i = 0) { return reinterpret_cast<uint32_t*>(blob() + (i * currentJob().size()) + 39); }
|
||||
inline uint32_t *nonce(size_t i = 0) { return reinterpret_cast<uint32_t*>(blob() + (i * currentJob().size()) + nonceOffset()); }
|
||||
inline uint64_t sequence() const { return m_sequence; }
|
||||
inline uint8_t *blob() { return m_blobs[index()]; }
|
||||
inline uint8_t index() const { return m_index; }
|
||||
@@ -88,6 +88,9 @@ public:
|
||||
|
||||
|
||||
private:
|
||||
inline int32_t nonceOffset() const { return currentJob().nonceOffset(); }
|
||||
inline size_t nonceSize() const { return currentJob().nonceSize(); }
|
||||
|
||||
inline void save(const Job &job, uint32_t reserveCount, Nonce::Backend backend)
|
||||
{
|
||||
m_index = job.index();
|
||||
@@ -115,7 +118,7 @@ private:
|
||||
template<>
|
||||
inline uint32_t *xmrig::WorkerJob<1>::nonce(size_t)
|
||||
{
|
||||
return reinterpret_cast<uint32_t*>(blob() + 39);
|
||||
return reinterpret_cast<uint32_t*>(blob() + nonceOffset());
|
||||
}
|
||||
|
||||
|
||||
@@ -125,11 +128,22 @@ inline bool xmrig::WorkerJob<1>::nextRound(uint32_t rounds, uint32_t roundSize)
|
||||
bool ok = true;
|
||||
m_rounds[index()]++;
|
||||
|
||||
uint32_t* n = nonce();
|
||||
const uint32_t prev_nonce = *n;
|
||||
|
||||
if ((m_rounds[index()] % rounds) == 0) {
|
||||
*nonce() = Nonce::next(index(), *nonce(), rounds * roundSize, currentJob().isNicehash(), &ok);
|
||||
*n = Nonce::next(index(), *n, rounds * roundSize, currentJob().isNicehash(), &ok);
|
||||
}
|
||||
else {
|
||||
*nonce() += roundSize;
|
||||
*n += roundSize;
|
||||
}
|
||||
|
||||
// Increment higher 32 bits of a 64-bit nonce when lower 32 bits overflow
|
||||
if (!currentJob().isNicehash() && (nonceSize() == sizeof(uint64_t)) && (*n < prev_nonce)) {
|
||||
++n[1];
|
||||
|
||||
Job& job = m_jobs[index()];
|
||||
memcpy(job.blob(), blob(), job.size());
|
||||
}
|
||||
|
||||
return ok;
|
||||
|
||||
@@ -47,6 +47,7 @@ namespace xmrig {
|
||||
|
||||
class Hashrate;
|
||||
class WorkersPrivate;
|
||||
class Job;
|
||||
|
||||
|
||||
template<class T>
|
||||
@@ -63,6 +64,7 @@ public:
|
||||
void start(const std::vector<T> &data);
|
||||
void stop();
|
||||
void tick(uint64_t ticks);
|
||||
void jobEarlyNotification(const Job&);
|
||||
|
||||
private:
|
||||
static IWorker *create(Thread<T> *handle);
|
||||
@@ -73,6 +75,17 @@ private:
|
||||
};
|
||||
|
||||
|
||||
template<class T>
|
||||
void xmrig::Workers<T>::jobEarlyNotification(const Job& job)
|
||||
{
|
||||
for (Thread<T>* t : m_workers) {
|
||||
if (t->worker()) {
|
||||
t->worker()->jobEarlyNotification(job);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
IWorker *Workers<CpuLaunchData>::create(Thread<CpuLaunchData> *handle);
|
||||
extern template class Workers<CpuLaunchData>;
|
||||
|
||||
@@ -34,6 +34,7 @@ namespace xmrig {
|
||||
|
||||
|
||||
class VirtualMemory;
|
||||
class Job;
|
||||
|
||||
|
||||
class IWorker
|
||||
@@ -48,6 +49,7 @@ public:
|
||||
virtual uint64_t hashCount() const = 0;
|
||||
virtual uint64_t timestamp() const = 0;
|
||||
virtual void start() = 0;
|
||||
virtual void jobEarlyNotification(const Job&) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user