From 3edaebb4cf1593b16562c630a76372db1bc8c2bd Mon Sep 17 00:00:00 2001 From: XMRig Date: Mon, 9 Dec 2019 21:42:40 +0700 Subject: [PATCH] Move "1gb-pages" option to "randomx" object. --- src/Summary.cpp | 15 +++++++++++++-- src/backend/cpu/CpuConfig.cpp | 3 --- src/backend/cpu/CpuConfig.h | 2 -- src/config.json | 2 +- src/crypto/rx/Rx.cpp | 2 +- src/crypto/rx/RxConfig.h | 10 ++++++---- src/crypto/rx/RxConfig_basic.cpp | 18 ++++++++++++------ src/crypto/rx/RxConfig_hwloc.cpp | 20 +++++++++++++------- 8 files changed, 46 insertions(+), 26 deletions(-) diff --git a/src/Summary.cpp b/src/Summary.cpp index 020eca61f..695138d12 100644 --- a/src/Summary.cpp +++ b/src/Summary.cpp @@ -39,6 +39,11 @@ #include "version.h" +#ifdef XMRIG_ALGO_RANDOMX +# include "crypto/rx/RxConfig.h" +#endif + + namespace xmrig { @@ -64,11 +69,17 @@ static void print_memory(Config *config) # ifdef XMRIG_OS_WIN Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") "%s", "HUGE PAGES", config->cpu().isHugePages() ? (VirtualMemory::isHugepagesAvailable() ? GREEN_BOLD("permission granted") : RED_BOLD("unavailable")) : RED_BOLD("disabled")); - Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") "%s", "1GB PAGES", YELLOW_BOLD("unavailable")); # else Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") "%s", "HUGE PAGES", config->cpu().isHugePages() ? GREEN_BOLD("supported") : RED_BOLD("disabled")); +# endif + +# ifdef XMRIG_ALGO_RANDOMX +# ifdef XMRIG_OS_LINUX Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") "%s", - "1GB PAGES", (VirtualMemory::isOneGbPagesAvailable() ? (config->cpu().isOneGbPages() ? GREEN_BOLD("supported") : YELLOW_BOLD("disabled")) : YELLOW_BOLD("unavailable"))); + "1GB PAGES", (VirtualMemory::isOneGbPagesAvailable() ? (config->rx().isOneGbPages() ? GREEN_BOLD("supported") : YELLOW_BOLD("disabled")) : YELLOW_BOLD("unavailable"))); +# else + Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") "%s", "1GB PAGES", YELLOW_BOLD("unavailable")); +# endif # endif } diff --git a/src/backend/cpu/CpuConfig.cpp b/src/backend/cpu/CpuConfig.cpp index fb95f942e..a9e10338c 100644 --- a/src/backend/cpu/CpuConfig.cpp +++ b/src/backend/cpu/CpuConfig.cpp @@ -34,7 +34,6 @@ namespace xmrig { static const char *kEnabled = "enabled"; static const char *kHugePages = "huge-pages"; -static const char *kOneGbPages = "1gb-pages"; static const char *kHwAes = "hw-aes"; static const char *kMaxThreadsHint = "max-threads-hint"; static const char *kMemoryPool = "memory-pool"; @@ -69,7 +68,6 @@ rapidjson::Value xmrig::CpuConfig::toJSON(rapidjson::Document &doc) const obj.AddMember(StringRef(kEnabled), m_enabled, allocator); obj.AddMember(StringRef(kHugePages), m_hugePages, allocator); - obj.AddMember(StringRef(kOneGbPages), m_oneGbPages, allocator); obj.AddMember(StringRef(kHwAes), m_aes == AES_AUTO ? Value(kNullType) : Value(m_aes == AES_HW), allocator); obj.AddMember(StringRef(kPriority), priority() != -1 ? Value(priority()) : Value(kNullType), allocator); obj.AddMember(StringRef(kMemoryPool), m_memoryPool < 1 ? Value(m_memoryPool < 0) : Value(m_memoryPool), allocator); @@ -123,7 +121,6 @@ void xmrig::CpuConfig::read(const rapidjson::Value &value) if (value.IsObject()) { m_enabled = Json::getBool(value, kEnabled, m_enabled); m_hugePages = Json::getBool(value, kHugePages, m_hugePages); - m_oneGbPages = Json::getBool(value, kOneGbPages, m_oneGbPages); m_limit = Json::getUint(value, kMaxThreadsHint, m_limit); m_yield = Json::getBool(value, kYield, m_yield); diff --git a/src/backend/cpu/CpuConfig.h b/src/backend/cpu/CpuConfig.h index 035a1673d..a9c408069 100644 --- a/src/backend/cpu/CpuConfig.h +++ b/src/backend/cpu/CpuConfig.h @@ -54,7 +54,6 @@ public: inline bool isEnabled() const { return m_enabled; } inline bool isHugePages() const { return m_hugePages; } - inline bool isOneGbPages() const { return m_oneGbPages; } inline bool isShouldSave() const { return m_shouldSave; } inline bool isYield() const { return m_yield; } inline const Assembly &assembly() const { return m_assembly; } @@ -74,7 +73,6 @@ private: Assembly m_assembly; bool m_enabled = true; bool m_hugePages = true; - bool m_oneGbPages = false; bool m_shouldSave = false; bool m_yield = true; int m_memoryPool = 0; diff --git a/src/config.json b/src/config.json index dd64f407d..ea2e4e15d 100644 --- a/src/config.json +++ b/src/config.json @@ -17,12 +17,12 @@ "randomx": { "init": -1, "mode": "auto", + "1gb-pages": false, "numa": true }, "cpu": { "enabled": true, "huge-pages": true, - "1gb-pages": false, "hw-aes": null, "priority": null, "memory-pool": false, diff --git a/src/crypto/rx/Rx.cpp b/src/crypto/rx/Rx.cpp index 369b0aacf..c311e5331 100644 --- a/src/crypto/rx/Rx.cpp +++ b/src/crypto/rx/Rx.cpp @@ -71,7 +71,7 @@ bool xmrig::Rx::init(const Job &job, const RxConfig &config, const CpuConfig &cp return true; } - d_ptr->queue.enqueue(job, config.nodeset(), config.threads(cpu.limit()), cpu.isHugePages(), cpu.isOneGbPages(), config.mode(), cpu.priority()); + d_ptr->queue.enqueue(job, config.nodeset(), config.threads(cpu.limit()), cpu.isHugePages(), config.isOneGbPages(), config.mode(), cpu.priority()); return false; } diff --git a/src/crypto/rx/RxConfig.h b/src/crypto/rx/RxConfig.h index e3381fec6..90beb4e82 100644 --- a/src/crypto/rx/RxConfig.h +++ b/src/crypto/rx/RxConfig.h @@ -57,14 +57,16 @@ public: const char *modeName() const; uint32_t threads(uint32_t limit = 100) const; - inline Mode mode() const { return m_mode; } + inline bool isOneGbPages() const { return m_oneGbPages; } + inline Mode mode() const { return m_mode; } private: Mode readMode(const rapidjson::Value &value) const; - bool m_numa = true; - int m_threads = -1; - Mode m_mode = AutoMode; + bool m_numa = true; + bool m_oneGbPages = false; + int m_threads = -1; + Mode m_mode = AutoMode; # ifdef XMRIG_FEATURE_HWLOC std::vector m_nodeset; diff --git a/src/crypto/rx/RxConfig_basic.cpp b/src/crypto/rx/RxConfig_basic.cpp index 1311b2206..bf2a2c8f3 100644 --- a/src/crypto/rx/RxConfig_basic.cpp +++ b/src/crypto/rx/RxConfig_basic.cpp @@ -30,8 +30,9 @@ namespace xmrig { -static const char *kInit = "init"; -static const char *kMode = "mode"; +static const char *kInit = "init"; +static const char *kMode = "mode"; +static const char *kOneGbPages = "1gb-pages"; } @@ -42,8 +43,9 @@ rapidjson::Value xmrig::RxConfig::toJSON(rapidjson::Document &doc) const auto &allocator = doc.GetAllocator(); Value obj(kObjectType); - obj.AddMember(StringRef(kInit), m_threads, allocator); - obj.AddMember(StringRef(kMode), StringRef(modeName()), allocator); + obj.AddMember(StringRef(kInit), m_threads, allocator); + obj.AddMember(StringRef(kMode), StringRef(modeName()), allocator); + obj.AddMember(StringRef(kOneGbPages), m_oneGbPages, allocator); return obj; } @@ -52,8 +54,12 @@ rapidjson::Value xmrig::RxConfig::toJSON(rapidjson::Document &doc) const bool xmrig::RxConfig::read(const rapidjson::Value &value) { if (value.IsObject()) { - m_threads = Json::getInt(value, kInit, m_threads); - m_mode = readMode(Json::getValue(value, kMode)); + m_threads = Json::getInt(value, kInit, m_threads); + m_mode = readMode(Json::getValue(value, kMode)); + +# ifdef XMRIG_OS_LINUX + m_oneGbPages = Json::getBool(value, kOneGbPages, m_oneGbPages); +# endif return true; } diff --git a/src/crypto/rx/RxConfig_hwloc.cpp b/src/crypto/rx/RxConfig_hwloc.cpp index 4fc57fb60..91104ef4e 100644 --- a/src/crypto/rx/RxConfig_hwloc.cpp +++ b/src/crypto/rx/RxConfig_hwloc.cpp @@ -32,9 +32,10 @@ namespace xmrig { -static const char *kInit = "init"; -static const char *kMode = "mode"; -static const char *kNUMA = "numa"; +static const char *kInit = "init"; +static const char *kMode = "mode"; +static const char *kNUMA = "numa"; +static const char *kOneGbPages = "1gb-pages"; } @@ -46,8 +47,9 @@ rapidjson::Value xmrig::RxConfig::toJSON(rapidjson::Document &doc) const Value obj(kObjectType); - obj.AddMember(StringRef(kInit), m_threads, allocator); - obj.AddMember(StringRef(kMode), StringRef(modeName()), allocator); + obj.AddMember(StringRef(kInit), m_threads, allocator); + obj.AddMember(StringRef(kMode), StringRef(modeName()), allocator); + obj.AddMember(StringRef(kOneGbPages), m_oneGbPages, allocator); if (!m_nodeset.empty()) { Value numa(kArrayType); @@ -69,8 +71,12 @@ rapidjson::Value xmrig::RxConfig::toJSON(rapidjson::Document &doc) const bool xmrig::RxConfig::read(const rapidjson::Value &value) { if (value.IsObject()) { - m_threads = Json::getInt(value, kInit, m_threads); - m_mode = readMode(Json::getValue(value, kMode)); + m_threads = Json::getInt(value, kInit, m_threads); + m_mode = readMode(Json::getValue(value, kMode)); + +# ifdef XMRIG_OS_LINUX + m_oneGbPages = Json::getBool(value, kOneGbPages, m_oneGbPages); +# endif if (m_mode == LightMode) { m_numa = false;