mirror of
https://github.com/xmrig/xmrig.git
synced 2024-12-23 12:09:22 +00:00
Cleanup
This commit is contained in:
parent
109c088e8a
commit
1acd88ed39
15 changed files with 135 additions and 101 deletions
|
@ -47,11 +47,6 @@ const char *cuda_tag();
|
|||
#endif
|
||||
|
||||
|
||||
#ifdef XMRIG_ALGO_RANDOMX
|
||||
const char *rx_tag();
|
||||
#endif
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include "backend/cpu/CpuThreads.h"
|
||||
#include "base/crypto/Algorithm.h"
|
||||
#include "base/tools/Object.h"
|
||||
#include "crypto/common/Assembly.h"
|
||||
|
||||
|
||||
|
@ -37,6 +38,8 @@ namespace xmrig {
|
|||
class ICpuInfo
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE(ICpuInfo)
|
||||
|
||||
enum Vendor : uint32_t {
|
||||
VENDOR_UNKNOWN,
|
||||
VENDOR_INTEL,
|
||||
|
@ -66,6 +69,7 @@ public:
|
|||
FLAG_MAX
|
||||
};
|
||||
|
||||
ICpuInfo() = default;
|
||||
virtual ~ICpuInfo() = default;
|
||||
|
||||
# if defined(__x86_64__) || defined(_M_AMD64) || defined (__arm64__) || defined (__aarch64__)
|
||||
|
|
|
@ -135,6 +135,12 @@ static AlgoName const algorithm_names[] = {
|
|||
} /* namespace xmrig */
|
||||
|
||||
|
||||
xmrig::Algorithm::Algorithm(const rapidjson::Value &value) :
|
||||
m_id(parse(value.GetString()))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
rapidjson::Value xmrig::Algorithm::toJSON() const
|
||||
{
|
||||
using namespace rapidjson;
|
||||
|
@ -143,6 +149,12 @@ rapidjson::Value xmrig::Algorithm::toJSON() const
|
|||
}
|
||||
|
||||
|
||||
rapidjson::Value xmrig::Algorithm::toJSON(rapidjson::Document &) const
|
||||
{
|
||||
return toJSON();
|
||||
}
|
||||
|
||||
|
||||
size_t xmrig::Algorithm::l2() const
|
||||
{
|
||||
# ifdef XMRIG_ALGO_RANDOMX
|
||||
|
|
|
@ -92,6 +92,7 @@ public:
|
|||
inline Algorithm() = default;
|
||||
inline Algorithm(const char *algo) : m_id(parse(algo)) {}
|
||||
inline Algorithm(Id id) : m_id(id) {}
|
||||
Algorithm(const rapidjson::Value &value);
|
||||
|
||||
inline bool isCN() const { auto f = family(); return f == CN || f == CN_LITE || f == CN_HEAVY || f == CN_PICO; }
|
||||
inline bool isEqual(const Algorithm &other) const { return m_id == other.m_id; }
|
||||
|
@ -108,6 +109,7 @@ public:
|
|||
inline operator Algorithm::Id() const { return m_id; }
|
||||
|
||||
rapidjson::Value toJSON() const;
|
||||
rapidjson::Value toJSON(rapidjson::Document &doc) const;
|
||||
size_t l2() const;
|
||||
size_t l3() const;
|
||||
uint32_t maxIntensity() const;
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
#include "backend/cpu/CpuConfig.h"
|
||||
#include "backend/cpu/CpuThreads.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/io/log/Tags.h"
|
||||
#include "crypto/rx/RxConfig.h"
|
||||
#include "crypto/rx/RxQueue.h"
|
||||
|
||||
|
@ -58,48 +57,6 @@ public:
|
|||
} // namespace xmrig
|
||||
|
||||
|
||||
const char *xmrig::rx_tag()
|
||||
{
|
||||
return Tags::randomx();
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::Rx::init(const Job &job, const RxConfig &config, const CpuConfig &cpu)
|
||||
{
|
||||
if (job.algorithm().family() != Algorithm::RANDOM_X) {
|
||||
if (msrInitialized) {
|
||||
msrDestroy();
|
||||
msrInitialized = false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isReady(job)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!msrInitialized) {
|
||||
msrInit(config, cpu.threads().get(job.algorithm()).data());
|
||||
msrInitialized = true;
|
||||
}
|
||||
|
||||
if (!osInitialized) {
|
||||
setupMainLoopExceptionFrame();
|
||||
osInitialized = true;
|
||||
}
|
||||
|
||||
d_ptr->queue.enqueue(job, config.nodeset(), config.threads(cpu.limit()), cpu.isHugePages(), config.isOneGbPages(), config.mode(), cpu.priority());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::Rx::isReady(const Job &job)
|
||||
{
|
||||
return d_ptr->queue.isReady(job);
|
||||
}
|
||||
|
||||
|
||||
xmrig::HugePagesInfo xmrig::Rx::hugePages()
|
||||
{
|
||||
return d_ptr->queue.hugePages();
|
||||
|
@ -130,6 +87,45 @@ void xmrig::Rx::init(IRxListener *listener)
|
|||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
bool xmrig::Rx::init(const T &seed, const RxConfig &config, const CpuConfig &cpu)
|
||||
{
|
||||
if (seed.algorithm().family() != Algorithm::RANDOM_X) {
|
||||
if (msrInitialized) {
|
||||
msrDestroy();
|
||||
msrInitialized = false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isReady(seed)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!msrInitialized) {
|
||||
msrInit(config, cpu.threads().get(seed.algorithm()).data());
|
||||
msrInitialized = true;
|
||||
}
|
||||
|
||||
if (!osInitialized) {
|
||||
setupMainLoopExceptionFrame();
|
||||
osInitialized = true;
|
||||
}
|
||||
|
||||
d_ptr->queue.enqueue(seed, config.nodeset(), config.threads(cpu.limit()), cpu.isHugePages(), config.isOneGbPages(), config.mode(), cpu.priority());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
bool xmrig::Rx::isReady(const T &seed)
|
||||
{
|
||||
return d_ptr->queue.isReady(seed);
|
||||
}
|
||||
|
||||
|
||||
#ifndef XMRIG_FEATURE_MSR
|
||||
void xmrig::Rx::msrInit(const RxConfig &, const std::vector<CpuThread> &)
|
||||
{
|
||||
|
@ -147,3 +143,15 @@ void xmrig::Rx::setupMainLoopExceptionFrame()
|
|||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
template bool Rx::init(const RxSeed &seed, const RxConfig &config, const CpuConfig &cpu);
|
||||
template bool Rx::isReady(const RxSeed &seed);
|
||||
template bool Rx::init(const Job &seed, const RxConfig &config, const CpuConfig &cpu);
|
||||
template bool Rx::isReady(const Job &seed);
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
* Copyright 2017-2019 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018-2019 tevador <tevador@gmail.com>
|
||||
* 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
|
||||
|
@ -52,12 +52,12 @@ class RxDataset;
|
|||
class Rx
|
||||
{
|
||||
public:
|
||||
static bool init(const Job &job, const RxConfig &config, const CpuConfig &cpu);
|
||||
static bool isReady(const Job &job);
|
||||
static HugePagesInfo hugePages();
|
||||
static RxDataset *dataset(const Job &job, uint32_t nodeId);
|
||||
static void destroy();
|
||||
static void init(IRxListener *listener);
|
||||
template<typename T> static bool init(const T &seed, const RxConfig &config, const CpuConfig &cpu);
|
||||
template<typename T> static bool isReady(const T &seed);
|
||||
|
||||
# ifdef XMRIG_FIX_RYZEN
|
||||
static void setMainLoopBounds(const std::pair<const void*, const void*>& bounds);
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
* Copyright 2017-2019 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018-2019 tevador <tevador@gmail.com>
|
||||
* 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
|
||||
|
@ -28,6 +28,7 @@
|
|||
#include "crypto/rx/RxBasicStorage.h"
|
||||
#include "backend/common/Tags.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/io/log/Tags.h"
|
||||
#include "base/tools/Chrono.h"
|
||||
#include "base/tools/Object.h"
|
||||
#include "crypto/rx/RxAlgo.h"
|
||||
|
@ -75,7 +76,7 @@ public:
|
|||
if (!m_dataset->cache()->get()) {
|
||||
deleteDataset();
|
||||
|
||||
LOG_INFO("%s" RED_BOLD("failed to allocate RandomX memory") BLACK_BOLD(" (%" PRIu64 " ms)"), rx_tag(), Chrono::steadyMSecs() - ts);
|
||||
LOG_INFO("%s" RED_BOLD("failed to allocate RandomX memory") BLACK_BOLD(" (%" PRIu64 " ms)"), Tags::randomx(), Chrono::steadyMSecs() - ts);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -93,7 +94,7 @@ public:
|
|||
m_ready = m_dataset->init(m_seed.data(), threads, priority);
|
||||
|
||||
if (m_ready) {
|
||||
LOG_INFO("%s" GREEN_BOLD("dataset ready") BLACK_BOLD(" (%" PRIu64 " ms)"), rx_tag(), Chrono::steadyMSecs() - ts);
|
||||
LOG_INFO("%s" GREEN_BOLD("dataset ready") BLACK_BOLD(" (%" PRIu64 " ms)"), Tags::randomx(), Chrono::steadyMSecs() - ts);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,7 +106,7 @@ private:
|
|||
const auto pages = m_dataset->hugePages();
|
||||
|
||||
LOG_INFO("%s" GREEN_BOLD("allocated") CYAN_BOLD(" %zu MB") BLACK_BOLD(" (%zu+%zu)") " huge pages %s%1.0f%% %u/%u" CLEAR " %sJIT" BLACK_BOLD(" (%" PRIu64 " ms)"),
|
||||
rx_tag(),
|
||||
Tags::randomx(),
|
||||
pages.size / oneMiB,
|
||||
RxDataset::maxSize() / oneMiB,
|
||||
RxCache::maxSize() / oneMiB,
|
||||
|
@ -118,7 +119,7 @@ private:
|
|||
);
|
||||
}
|
||||
else {
|
||||
LOG_WARN(CLEAR "%s" YELLOW_BOLD_S "failed to allocate RandomX dataset, switching to slow mode" BLACK_BOLD(" (%" PRIu64 " ms)"), rx_tag(), Chrono::steadyMSecs() - ts);
|
||||
LOG_WARN(CLEAR "%s" YELLOW_BOLD_S "failed to allocate RandomX dataset, switching to slow mode" BLACK_BOLD(" (%" PRIu64 " ms)"), Tags::randomx(), Chrono::steadyMSecs() - ts);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
* Copyright 2017-2019 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018-2019 tevador <tevador@gmail.com>
|
||||
* 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
|
||||
|
|
|
@ -26,8 +26,8 @@
|
|||
|
||||
|
||||
#include "crypto/rx/RxDataset.h"
|
||||
#include "backend/common/Tags.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/io/log/Tags.h"
|
||||
#include "base/kernel/Platform.h"
|
||||
#include "crypto/common/VirtualMemory.h"
|
||||
#include "crypto/rx/RxAlgo.h"
|
||||
|
@ -181,13 +181,13 @@ void xmrig::RxDataset::setRaw(const void *raw)
|
|||
void xmrig::RxDataset::allocate(bool hugePages, bool oneGbPages)
|
||||
{
|
||||
if (m_mode == RxConfig::LightMode) {
|
||||
LOG_ERR(CLEAR "%s" RED_BOLD_S "fast RandomX mode disabled by config", rx_tag());
|
||||
LOG_ERR(CLEAR "%s" RED_BOLD_S "fast RandomX mode disabled by config", Tags::randomx());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_mode == RxConfig::AutoMode && uv_get_total_memory() < (maxSize() + RxCache::maxSize())) {
|
||||
LOG_ERR(CLEAR "%s" RED_BOLD_S "not enough memory for RandomX dataset", rx_tag());
|
||||
LOG_ERR(CLEAR "%s" RED_BOLD_S "not enough memory for RandomX dataset", Tags::randomx());
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ void xmrig::RxDataset::allocate(bool hugePages, bool oneGbPages)
|
|||
|
||||
# ifdef XMRIG_OS_LINUX
|
||||
if (oneGbPages && !isOneGbPages()) {
|
||||
LOG_ERR(CLEAR "%s" RED_BOLD_S "failed to allocate RandomX dataset using 1GB pages", rx_tag());
|
||||
LOG_ERR(CLEAR "%s" RED_BOLD_S "failed to allocate RandomX dataset using 1GB pages", Tags::randomx());
|
||||
}
|
||||
# endif
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
|
||||
#include "base/crypto/Algorithm.h"
|
||||
#include "base/tools/Buffer.h"
|
||||
#include "base/tools/Object.h"
|
||||
#include "crypto/common/HugePagesInfo.h"
|
||||
#include "crypto/randomx/configuration.h"
|
||||
|
@ -43,7 +44,6 @@ namespace xmrig
|
|||
{
|
||||
|
||||
|
||||
class Buffer;
|
||||
class RxCache;
|
||||
class VirtualMemory;
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
* Copyright 2017-2019 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018-2019 tevador <tevador@gmail.com>
|
||||
* 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
|
||||
|
@ -26,10 +26,10 @@
|
|||
|
||||
|
||||
#include "crypto/rx/RxNUMAStorage.h"
|
||||
#include "backend/common/Tags.h"
|
||||
#include "backend/cpu/Cpu.h"
|
||||
#include "backend/cpu/platform/HwlocCpuInfo.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/io/log/Tags.h"
|
||||
#include "base/kernel/Platform.h"
|
||||
#include "base/tools/Chrono.h"
|
||||
#include "base/tools/Object.h"
|
||||
|
@ -72,13 +72,13 @@ static bool bindToNUMANode(uint32_t nodeId)
|
|||
|
||||
static inline void printSkipped(uint32_t nodeId, const char *reason)
|
||||
{
|
||||
LOG_WARN("%s" CYAN_BOLD("#%u ") RED_BOLD("skipped") YELLOW(" (%s)"), rx_tag(), nodeId, reason);
|
||||
LOG_WARN("%s" CYAN_BOLD("#%u ") RED_BOLD("skipped") YELLOW(" (%s)"), Tags::randomx(), nodeId, reason);
|
||||
}
|
||||
|
||||
|
||||
static inline void printDatasetReady(uint32_t nodeId, uint64_t ts)
|
||||
{
|
||||
LOG_INFO("%s" CYAN_BOLD("#%u ") GREEN_BOLD("dataset ready") BLACK_BOLD(" (%" PRIu64 " ms)"), rx_tag(), nodeId, Chrono::steadyMSecs() - ts);
|
||||
LOG_INFO("%s" CYAN_BOLD("#%u ") GREEN_BOLD("dataset ready") BLACK_BOLD(" (%" PRIu64 " ms)"), Tags::randomx(), nodeId, Chrono::steadyMSecs() - ts);
|
||||
}
|
||||
|
||||
|
||||
|
@ -142,7 +142,7 @@ public:
|
|||
if (m_datasets.empty()) {
|
||||
m_datasets.insert({ m_nodeset.front(), new RxDataset(m_cache) });
|
||||
|
||||
LOG_WARN(CLEAR "%s" YELLOW_BOLD_S "failed to allocate RandomX datasets, switching to slow mode" BLACK_BOLD(" (%" PRIu64 " ms)"), rx_tag(), Chrono::steadyMSecs() - ts);
|
||||
LOG_WARN(CLEAR "%s" YELLOW_BOLD_S "failed to allocate RandomX datasets, switching to slow mode" BLACK_BOLD(" (%" PRIu64 " ms)"), Tags::randomx(), Chrono::steadyMSecs() - ts);
|
||||
}
|
||||
else {
|
||||
if (m_cache) {
|
||||
|
@ -246,7 +246,7 @@ private:
|
|||
if (!cache->get()) {
|
||||
delete cache;
|
||||
|
||||
LOG_INFO("%s" RED_BOLD("failed to allocate RandomX memory") BLACK_BOLD(" (%" PRIu64 " ms)"), rx_tag(), Chrono::steadyMSecs() - ts);
|
||||
LOG_INFO("%s" RED_BOLD("failed to allocate RandomX memory") BLACK_BOLD(" (%" PRIu64 " ms)"), Tags::randomx(), Chrono::steadyMSecs() - ts);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -272,7 +272,7 @@ private:
|
|||
const auto pages = dataset->hugePages();
|
||||
|
||||
LOG_INFO("%s" CYAN_BOLD("#%u ") GREEN_BOLD("allocated") CYAN_BOLD(" %zu MB") " huge pages %s%3.0f%%" CLEAR BLACK_BOLD(" (%" PRIu64 " ms)"),
|
||||
rx_tag(),
|
||||
Tags::randomx(),
|
||||
nodeId,
|
||||
pages.size / oneMiB,
|
||||
(pages.isFullyAllocated() ? GREEN_BOLD_S : RED_BOLD_S),
|
||||
|
@ -287,7 +287,7 @@ private:
|
|||
const auto pages = cache->hugePages();
|
||||
|
||||
LOG_INFO("%s" CYAN_BOLD("#%u ") GREEN_BOLD("allocated") CYAN_BOLD(" %4zu MB") " huge pages %s%3.0f%%" CLEAR " %sJIT" BLACK_BOLD(" (%" PRIu64 " ms)"),
|
||||
rx_tag(),
|
||||
Tags::randomx(),
|
||||
nodeId,
|
||||
cache->size() / oneMiB,
|
||||
(pages.isFullyAllocated() ? GREEN_BOLD_S : RED_BOLD_S),
|
||||
|
@ -303,7 +303,7 @@ private:
|
|||
auto pages = hugePages();
|
||||
|
||||
LOG_INFO("%s" CYAN_BOLD("-- ") GREEN_BOLD("allocated") CYAN_BOLD(" %4zu MB") " huge pages %s%3.0f%% %u/%u" CLEAR BLACK_BOLD(" (%" PRIu64 " ms)"),
|
||||
rx_tag(),
|
||||
Tags::randomx(),
|
||||
pages.size / oneMiB,
|
||||
(pages.isFullyAllocated() ? GREEN_BOLD_S : (pages.allocated == 0 ? RED_BOLD_S : YELLOW_BOLD_S)),
|
||||
pages.percent(),
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
* Copyright 2017-2019 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018-2019 tevador <tevador@gmail.com>
|
||||
* 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
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
* Copyright 2017-2019 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018-2019 tevador <tevador@gmail.com>
|
||||
* 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
|
||||
|
@ -26,11 +26,11 @@
|
|||
|
||||
|
||||
#include "crypto/rx/RxQueue.h"
|
||||
#include "backend/common/Tags.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "crypto/rx/RxBasicStorage.h"
|
||||
#include "base/tools/Handle.h"
|
||||
#include "backend/common/interfaces/IRxListener.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/io/log/Tags.h"
|
||||
#include "base/tools/Handle.h"
|
||||
#include "crypto/rx/RxBasicStorage.h"
|
||||
|
||||
|
||||
#ifdef XMRIG_FEATURE_HWLOC
|
||||
|
@ -66,14 +66,6 @@ xmrig::RxQueue::~RxQueue()
|
|||
}
|
||||
|
||||
|
||||
bool xmrig::RxQueue::isReady(const Job &job)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
|
||||
return isReadyUnsafe(job);
|
||||
}
|
||||
|
||||
|
||||
xmrig::RxDataset *xmrig::RxQueue::dataset(const Job &job, uint32_t nodeId)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
|
@ -94,6 +86,15 @@ xmrig::HugePagesInfo xmrig::RxQueue::hugePages()
|
|||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
bool xmrig::RxQueue::isReady(const T &seed)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
|
||||
return isReadyUnsafe(seed);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::RxQueue::enqueue(const RxSeed &seed, const std::vector<uint32_t> &nodeset, uint32_t threads, bool hugePages, bool oneGbPages, RxConfig::Mode mode, int priority)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
|
@ -124,9 +125,10 @@ void xmrig::RxQueue::enqueue(const RxSeed &seed, const std::vector<uint32_t> &no
|
|||
}
|
||||
|
||||
|
||||
bool xmrig::RxQueue::isReadyUnsafe(const Job &job) const
|
||||
template<typename T>
|
||||
bool xmrig::RxQueue::isReadyUnsafe(const T &seed) const
|
||||
{
|
||||
return m_storage != nullptr && m_storage->isAllocated() && m_state == STATE_IDLE && m_seed == job;
|
||||
return m_storage != nullptr && m_storage->isAllocated() && m_state == STATE_IDLE && m_seed == seed;
|
||||
}
|
||||
|
||||
|
||||
|
@ -149,7 +151,7 @@ void xmrig::RxQueue::backgroundInit()
|
|||
lock.unlock();
|
||||
|
||||
LOG_INFO("%s" MAGENTA_BOLD("init dataset%s") " algo " WHITE_BOLD("%s (") CYAN_BOLD("%u") WHITE_BOLD(" threads)") BLACK_BOLD(" seed %s..."),
|
||||
rx_tag(),
|
||||
Tags::randomx(),
|
||||
item.nodeset.size() > 1 ? "s" : "",
|
||||
item.seed.algorithm().shortName(),
|
||||
item.threads,
|
||||
|
@ -180,3 +182,13 @@ void xmrig::RxQueue::onReady()
|
|||
m_listener->onDatasetReady();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
template bool RxQueue::isReady(const Job &);
|
||||
template bool RxQueue::isReady(const RxSeed &);
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
* Copyright 2017-2019 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018-2019 tevador <tevador@gmail.com>
|
||||
* 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
|
||||
|
@ -82,9 +82,9 @@ public:
|
|||
RxQueue(IRxListener *listener);
|
||||
~RxQueue();
|
||||
|
||||
bool isReady(const Job &job);
|
||||
RxDataset *dataset(const Job &job, uint32_t nodeId);
|
||||
HugePagesInfo hugePages();
|
||||
RxDataset *dataset(const Job &job, uint32_t nodeId);
|
||||
template<typename T> bool isReady(const T &seed);
|
||||
void enqueue(const RxSeed &seed, const std::vector<uint32_t> &nodeset, uint32_t threads, bool hugePages, bool oneGbPages, RxConfig::Mode mode, int priority);
|
||||
|
||||
private:
|
||||
|
@ -94,7 +94,7 @@ private:
|
|||
STATE_SHUTDOWN
|
||||
};
|
||||
|
||||
bool isReadyUnsafe(const Job &job) const;
|
||||
template<typename T> bool isReadyUnsafe(const T &seed) const;
|
||||
void backgroundInit();
|
||||
void onReady();
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
* Copyright 2017-2019 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018-2019 tevador <tevador@gmail.com>
|
||||
* 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
|
||||
|
|
Loading…
Reference in a new issue