mirror of
https://github.com/xmrig/xmrig.git
synced 2024-12-23 12:09:22 +00:00
Added "randomx" object to config.
This commit is contained in:
parent
9df9275120
commit
d10527036e
8 changed files with 159 additions and 10 deletions
|
@ -182,6 +182,8 @@ if (WITH_RANDOMX)
|
||||||
src/crypto/rx/RxAlgo.h
|
src/crypto/rx/RxAlgo.h
|
||||||
src/crypto/rx/RxCache.cpp
|
src/crypto/rx/RxCache.cpp
|
||||||
src/crypto/rx/RxCache.h
|
src/crypto/rx/RxCache.h
|
||||||
|
src/crypto/rx/RxConfig.cpp
|
||||||
|
src/crypto/rx/RxConfig.h
|
||||||
src/crypto/rx/RxDataset.cpp
|
src/crypto/rx/RxDataset.cpp
|
||||||
src/crypto/rx/RxDataset.h
|
src/crypto/rx/RxDataset.h
|
||||||
src/crypto/rx/RxVm.cpp
|
src/crypto/rx/RxVm.cpp
|
||||||
|
|
|
@ -35,7 +35,6 @@ static const char *kCn = "cn";
|
||||||
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 *kHwAes = "hw-aes";
|
static const char *kHwAes = "hw-aes";
|
||||||
static const char *kInitThreads = "init-threads";
|
|
||||||
static const char *kPriority = "priority";
|
static const char *kPriority = "priority";
|
||||||
|
|
||||||
#ifdef XMRIG_FEATURE_ASM
|
#ifdef XMRIG_FEATURE_ASM
|
||||||
|
@ -90,7 +89,6 @@ rapidjson::Value xmrig::CpuConfig::toJSON(rapidjson::Document &doc) const
|
||||||
obj.AddMember(StringRef(kHugePages), m_hugePages, allocator);
|
obj.AddMember(StringRef(kHugePages), m_hugePages, 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(kInitThreads), m_initThreads, allocator);
|
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_ASM
|
# ifdef XMRIG_FEATURE_ASM
|
||||||
obj.AddMember(StringRef(kAsm), m_assembly.toJSON(), allocator);
|
obj.AddMember(StringRef(kAsm), m_assembly.toJSON(), allocator);
|
||||||
|
@ -126,7 +124,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_initThreads = Json::getInt(value, kInitThreads, m_initThreads);
|
|
||||||
|
|
||||||
setAesMode(Json::getValue(value, kHwAes));
|
setAesMode(Json::getValue(value, kHwAes));
|
||||||
setPriority(Json::getInt(value, kPriority, -1));
|
setPriority(Json::getInt(value, kPriority, -1));
|
||||||
|
|
|
@ -56,7 +56,6 @@ public:
|
||||||
inline bool isShouldSave() const { return m_shouldSave; }
|
inline bool isShouldSave() const { return m_shouldSave; }
|
||||||
inline const Assembly &assembly() const { return m_assembly; }
|
inline const Assembly &assembly() const { return m_assembly; }
|
||||||
inline const Threads<CpuThread> &threads() const { return m_threads; }
|
inline const Threads<CpuThread> &threads() const { return m_threads; }
|
||||||
inline int initThreads() const { return m_initThreads; }
|
|
||||||
inline int priority() const { return m_priority; }
|
inline int priority() const { return m_priority; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -70,7 +69,6 @@ private:
|
||||||
bool m_enabled = true;
|
bool m_enabled = true;
|
||||||
bool m_hugePages = true;
|
bool m_hugePages = true;
|
||||||
bool m_shouldSave = false;
|
bool m_shouldSave = false;
|
||||||
int m_initThreads = -1;
|
|
||||||
int m_priority = -1;
|
int m_priority = -1;
|
||||||
Threads<CpuThread> m_threads;
|
Threads<CpuThread> m_threads;
|
||||||
};
|
};
|
||||||
|
|
|
@ -365,8 +365,11 @@ void xmrig::Miner::setJob(const Job &job, bool donate)
|
||||||
}
|
}
|
||||||
|
|
||||||
# ifdef XMRIG_ALGO_RANDOMX
|
# ifdef XMRIG_ALGO_RANDOMX
|
||||||
const CpuConfig &cpu = d_ptr->controller->config()->cpu();
|
Rx::init(job,
|
||||||
Rx::init(job, cpu.initThreads(), cpu.isHugePages(), true);
|
d_ptr->controller->config()->rx().threads(),
|
||||||
|
d_ptr->controller->config()->cpu().isHugePages(),
|
||||||
|
d_ptr->controller->config()->rx().isNUMA()
|
||||||
|
);
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
uv_rwlock_wrunlock(&d_ptr->rwlock);
|
uv_rwlock_wrunlock(&d_ptr->rwlock);
|
||||||
|
|
|
@ -38,6 +38,14 @@
|
||||||
#include "rapidjson/prettywriter.h"
|
#include "rapidjson/prettywriter.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace xmrig {
|
||||||
|
|
||||||
|
static const char *kCPU = "cpu";
|
||||||
|
static const char *kRandomX = "randomx";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
xmrig::Config::Config() : BaseConfig()
|
xmrig::Config::Config() : BaseConfig()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -49,7 +57,14 @@ bool xmrig::Config::read(const IJsonReader &reader, const char *fileName)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_cpu.read(reader.getValue("cpu"));
|
m_cpu.read(reader.getValue(kCPU));
|
||||||
|
|
||||||
|
# ifdef XMRIG_ALGO_RANDOMX
|
||||||
|
if (!m_rx.read(reader.getValue(kRandomX))) {
|
||||||
|
printf("upgrade\n");
|
||||||
|
m_upgrade = true;
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -68,13 +83,18 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const
|
||||||
api.AddMember("worker-id", m_apiWorkerId.toJSON(), allocator);
|
api.AddMember("worker-id", m_apiWorkerId.toJSON(), allocator);
|
||||||
|
|
||||||
doc.AddMember("api", api, allocator);
|
doc.AddMember("api", api, allocator);
|
||||||
|
doc.AddMember("http", m_http.toJSON(doc), allocator);
|
||||||
doc.AddMember("autosave", isAutoSave(), allocator);
|
doc.AddMember("autosave", isAutoSave(), allocator);
|
||||||
doc.AddMember("background", isBackground(), allocator);
|
doc.AddMember("background", isBackground(), allocator);
|
||||||
doc.AddMember("colors", Log::colors, allocator);
|
doc.AddMember("colors", Log::colors, allocator);
|
||||||
doc.AddMember("cpu", m_cpu.toJSON(doc), allocator);
|
|
||||||
|
# ifdef XMRIG_ALGO_RANDOMX
|
||||||
|
doc.AddMember(StringRef(kRandomX), m_rx.toJSON(doc), allocator);
|
||||||
|
# endif
|
||||||
|
|
||||||
|
doc.AddMember(StringRef(kCPU), m_cpu.toJSON(doc), allocator);
|
||||||
doc.AddMember("donate-level", m_pools.donateLevel(), allocator);
|
doc.AddMember("donate-level", m_pools.donateLevel(), allocator);
|
||||||
doc.AddMember("donate-over-proxy", m_pools.proxyDonate(), allocator);
|
doc.AddMember("donate-over-proxy", m_pools.proxyDonate(), allocator);
|
||||||
doc.AddMember("http", m_http.toJSON(doc), allocator);
|
|
||||||
doc.AddMember("log-file", m_logFile.toJSON(), allocator);
|
doc.AddMember("log-file", m_logFile.toJSON(), allocator);
|
||||||
doc.AddMember("pools", m_pools.toJSON(doc), allocator);
|
doc.AddMember("pools", m_pools.toJSON(doc), allocator);
|
||||||
doc.AddMember("print-time", printTime(), allocator);
|
doc.AddMember("print-time", printTime(), allocator);
|
||||||
|
|
|
@ -34,6 +34,11 @@
|
||||||
#include "rapidjson/fwd.h"
|
#include "rapidjson/fwd.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef XMRIG_ALGO_RANDOMX
|
||||||
|
# include "crypto/rx/RxConfig.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
namespace xmrig {
|
namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
|
@ -51,9 +56,17 @@ public:
|
||||||
inline bool isShouldSave() const { return (m_shouldSave || m_upgrade || m_cpu.isShouldSave()) && isAutoSave(); }
|
inline bool isShouldSave() const { return (m_shouldSave || m_upgrade || m_cpu.isShouldSave()) && isAutoSave(); }
|
||||||
inline const CpuConfig &cpu() const { return m_cpu; }
|
inline const CpuConfig &cpu() const { return m_cpu; }
|
||||||
|
|
||||||
|
# ifdef XMRIG_ALGO_RANDOMX
|
||||||
|
inline const RxConfig &rx() const { return m_rx; }
|
||||||
|
# endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_shouldSave = false;
|
bool m_shouldSave = false;
|
||||||
CpuConfig m_cpu;
|
CpuConfig m_cpu;
|
||||||
|
|
||||||
|
# ifdef XMRIG_ALGO_RANDOMX
|
||||||
|
RxConfig m_rx;
|
||||||
|
# endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
63
src/crypto/rx/RxConfig.cpp
Normal file
63
src/crypto/rx/RxConfig.cpp
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
/* XMRig
|
||||||
|
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||||
|
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||||
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
|
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2019 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
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "base/io/json/Json.h"
|
||||||
|
#include "crypto/rx/RxConfig.h"
|
||||||
|
#include "rapidjson/document.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace xmrig {
|
||||||
|
|
||||||
|
static const char *kInit = "init";
|
||||||
|
static const char *kNUMA = "numa";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
rapidjson::Value xmrig::RxConfig::toJSON(rapidjson::Document &doc) const
|
||||||
|
{
|
||||||
|
using namespace rapidjson;
|
||||||
|
auto &allocator = doc.GetAllocator();
|
||||||
|
|
||||||
|
Value obj(kObjectType);
|
||||||
|
|
||||||
|
obj.AddMember(StringRef(kInit), m_threads, allocator);
|
||||||
|
obj.AddMember(StringRef(kNUMA), m_numa, allocator);
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool xmrig::RxConfig::read(const rapidjson::Value &value)
|
||||||
|
{
|
||||||
|
if (value.IsObject()) {
|
||||||
|
m_numa = Json::getBool(value, kNUMA, m_numa);
|
||||||
|
m_threads = Json::getInt(value, kInit, m_threads);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
53
src/crypto/rx/RxConfig.h
Normal file
53
src/crypto/rx/RxConfig.h
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
/* XMRig
|
||||||
|
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||||
|
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||||
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
|
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2019 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
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef XMRIG_RXCONFIG_H
|
||||||
|
#define XMRIG_RXCONFIG_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "rapidjson/fwd.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
|
class RxConfig
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
bool read(const rapidjson::Value &value);
|
||||||
|
rapidjson::Value toJSON(rapidjson::Document &doc) const;
|
||||||
|
|
||||||
|
inline bool isNUMA() const { return m_numa; }
|
||||||
|
inline int threads() const { return m_threads; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_numa = true;
|
||||||
|
int m_threads = -1;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} /* namespace xmrig */
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* XMRIG_RXCONFIG_H */
|
Loading…
Reference in a new issue