Move "1gb-pages" option to "randomx" object.

This commit is contained in:
XMRig 2019-12-09 21:42:40 +07:00
parent 558c524e2a
commit 3edaebb4cf
No known key found for this signature in database
GPG key ID: 446A53638BE94409
8 changed files with 46 additions and 26 deletions

View file

@ -39,6 +39,11 @@
#include "version.h" #include "version.h"
#ifdef XMRIG_ALGO_RANDOMX
# include "crypto/rx/RxConfig.h"
#endif
namespace xmrig { namespace xmrig {
@ -64,11 +69,17 @@ static void print_memory(Config *config)
# ifdef XMRIG_OS_WIN # ifdef XMRIG_OS_WIN
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") "%s", 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")); "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 # else
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") "%s", "HUGE PAGES", config->cpu().isHugePages() ? GREEN_BOLD("supported") : RED_BOLD("disabled")); 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", 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 # endif
} }

View file

@ -34,7 +34,6 @@ namespace xmrig {
static const char *kEnabled = "enabled"; static const char *kEnabled = "enabled";
static const char *kHugePages = "huge-pages"; static const char *kHugePages = "huge-pages";
static const char *kOneGbPages = "1gb-pages";
static const char *kHwAes = "hw-aes"; static const char *kHwAes = "hw-aes";
static const char *kMaxThreadsHint = "max-threads-hint"; static const char *kMaxThreadsHint = "max-threads-hint";
static const char *kMemoryPool = "memory-pool"; 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(kEnabled), m_enabled, allocator);
obj.AddMember(StringRef(kHugePages), m_hugePages, 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(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(kPriority), priority() != -1 ? Value(priority()) : Value(kNullType), allocator);
obj.AddMember(StringRef(kMemoryPool), m_memoryPool < 1 ? Value(m_memoryPool < 0) : Value(m_memoryPool), 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()) { if (value.IsObject()) {
m_enabled = Json::getBool(value, kEnabled, m_enabled); m_enabled = Json::getBool(value, kEnabled, m_enabled);
m_hugePages = Json::getBool(value, kHugePages, m_hugePages); 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_limit = Json::getUint(value, kMaxThreadsHint, m_limit);
m_yield = Json::getBool(value, kYield, m_yield); m_yield = Json::getBool(value, kYield, m_yield);

View file

@ -54,7 +54,6 @@ public:
inline bool isEnabled() const { return m_enabled; } inline bool isEnabled() const { return m_enabled; }
inline bool isHugePages() const { return m_hugePages; } inline bool isHugePages() const { return m_hugePages; }
inline bool isOneGbPages() const { return m_oneGbPages; }
inline bool isShouldSave() const { return m_shouldSave; } inline bool isShouldSave() const { return m_shouldSave; }
inline bool isYield() const { return m_yield; } inline bool isYield() const { return m_yield; }
inline const Assembly &assembly() const { return m_assembly; } inline const Assembly &assembly() const { return m_assembly; }
@ -74,7 +73,6 @@ private:
Assembly m_assembly; Assembly m_assembly;
bool m_enabled = true; bool m_enabled = true;
bool m_hugePages = true; bool m_hugePages = true;
bool m_oneGbPages = false;
bool m_shouldSave = false; bool m_shouldSave = false;
bool m_yield = true; bool m_yield = true;
int m_memoryPool = 0; int m_memoryPool = 0;

View file

@ -17,12 +17,12 @@
"randomx": { "randomx": {
"init": -1, "init": -1,
"mode": "auto", "mode": "auto",
"1gb-pages": false,
"numa": true "numa": true
}, },
"cpu": { "cpu": {
"enabled": true, "enabled": true,
"huge-pages": true, "huge-pages": true,
"1gb-pages": false,
"hw-aes": null, "hw-aes": null,
"priority": null, "priority": null,
"memory-pool": false, "memory-pool": false,

View file

@ -71,7 +71,7 @@ bool xmrig::Rx::init(const Job &job, const RxConfig &config, const CpuConfig &cp
return true; 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; return false;
} }

View file

@ -57,14 +57,16 @@ public:
const char *modeName() const; const char *modeName() const;
uint32_t threads(uint32_t limit = 100) 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: private:
Mode readMode(const rapidjson::Value &value) const; Mode readMode(const rapidjson::Value &value) const;
bool m_numa = true; bool m_numa = true;
int m_threads = -1; bool m_oneGbPages = false;
Mode m_mode = AutoMode; int m_threads = -1;
Mode m_mode = AutoMode;
# ifdef XMRIG_FEATURE_HWLOC # ifdef XMRIG_FEATURE_HWLOC
std::vector<uint32_t> m_nodeset; std::vector<uint32_t> m_nodeset;

View file

@ -30,8 +30,9 @@
namespace xmrig { namespace xmrig {
static const char *kInit = "init"; static const char *kInit = "init";
static const char *kMode = "mode"; 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(); auto &allocator = doc.GetAllocator();
Value obj(kObjectType); Value obj(kObjectType);
obj.AddMember(StringRef(kInit), m_threads, allocator); obj.AddMember(StringRef(kInit), m_threads, allocator);
obj.AddMember(StringRef(kMode), StringRef(modeName()), allocator); obj.AddMember(StringRef(kMode), StringRef(modeName()), allocator);
obj.AddMember(StringRef(kOneGbPages), m_oneGbPages, allocator);
return obj; return obj;
} }
@ -52,8 +54,12 @@ rapidjson::Value xmrig::RxConfig::toJSON(rapidjson::Document &doc) const
bool xmrig::RxConfig::read(const rapidjson::Value &value) bool xmrig::RxConfig::read(const rapidjson::Value &value)
{ {
if (value.IsObject()) { if (value.IsObject()) {
m_threads = Json::getInt(value, kInit, m_threads); m_threads = Json::getInt(value, kInit, m_threads);
m_mode = readMode(Json::getValue(value, kMode)); m_mode = readMode(Json::getValue(value, kMode));
# ifdef XMRIG_OS_LINUX
m_oneGbPages = Json::getBool(value, kOneGbPages, m_oneGbPages);
# endif
return true; return true;
} }

View file

@ -32,9 +32,10 @@
namespace xmrig { namespace xmrig {
static const char *kInit = "init"; static const char *kInit = "init";
static const char *kMode = "mode"; static const char *kMode = "mode";
static const char *kNUMA = "numa"; 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); Value obj(kObjectType);
obj.AddMember(StringRef(kInit), m_threads, allocator); obj.AddMember(StringRef(kInit), m_threads, allocator);
obj.AddMember(StringRef(kMode), StringRef(modeName()), allocator); obj.AddMember(StringRef(kMode), StringRef(modeName()), allocator);
obj.AddMember(StringRef(kOneGbPages), m_oneGbPages, allocator);
if (!m_nodeset.empty()) { if (!m_nodeset.empty()) {
Value numa(kArrayType); Value numa(kArrayType);
@ -69,8 +71,12 @@ rapidjson::Value xmrig::RxConfig::toJSON(rapidjson::Document &doc) const
bool xmrig::RxConfig::read(const rapidjson::Value &value) bool xmrig::RxConfig::read(const rapidjson::Value &value)
{ {
if (value.IsObject()) { if (value.IsObject()) {
m_threads = Json::getInt(value, kInit, m_threads); m_threads = Json::getInt(value, kInit, m_threads);
m_mode = readMode(Json::getValue(value, kMode)); m_mode = readMode(Json::getValue(value, kMode));
# ifdef XMRIG_OS_LINUX
m_oneGbPages = Json::getBool(value, kOneGbPages, m_oneGbPages);
# endif
if (m_mode == LightMode) { if (m_mode == LightMode) {
m_numa = false; m_numa = false;