Merged v4.3.0-beta

This commit is contained in:
MoneroOcean 2019-10-10 14:52:12 -07:00
commit fe76800fc8
101 changed files with 10318 additions and 7615 deletions

View file

@ -111,13 +111,13 @@ public:
return;
}
LOG_INFO("%s" GREEN_BOLD(" READY") " threads %s%zu/%zu (%zu)" CLEAR " huge pages %s%zu/%zu %1.0f%%" CLEAR " memory " CYAN_BOLD("%zu KB") BLACK_BOLD(" (%" PRIu64 " ms)"),
LOG_INFO("%s" GREEN_BOLD(" READY") " threads %s%zu/%zu (%zu)" CLEAR " huge pages %s%1.0f%% %zu/%zu" CLEAR " memory " CYAN_BOLD("%zu KB") BLACK_BOLD(" (%" PRIu64 " ms)"),
tag,
m_errors == 0 ? CYAN_BOLD_S : YELLOW_BOLD_S,
m_started, m_threads, m_ways,
(m_hugePages == m_pages ? GREEN_BOLD_S : (m_hugePages == 0 ? RED_BOLD_S : YELLOW_BOLD_S)),
m_hugePages, m_pages,
m_hugePages == 0 ? 0.0 : static_cast<double>(m_hugePages) / m_pages * 100.0,
m_hugePages, m_pages,
memory() / 1024,
Chrono::steadyMSecs() - m_ts
);

View file

@ -23,25 +23,27 @@
*/
#include "backend/cpu/Cpu.h"
#include "backend/cpu/CpuConfig.h"
#include "backend/cpu/CpuConfig_gen.h"
#include "backend/cpu/Cpu.h"
#include "base/io/json/Json.h"
#include "rapidjson/document.h"
namespace xmrig {
static const char *kCn = "cn";
static const char *kEnabled = "enabled";
static const char *kHugePages = "huge-pages";
static const char *kHwAes = "hw-aes";
static const char *kMaxThreadsHint = "max-threads-hint";
static const char *kMemoryPool = "memory-pool";
static const char *kPriority = "priority";
#ifdef XMRIG_FEATURE_ASM
static const char *kAsm = "asm";
#endif
<<<<<<< HEAD
#ifdef XMRIG_ALGO_CN_GPU
static const char *kCnGPU = "cn/gpu";
#endif
@ -64,8 +66,9 @@ static const char *kRxWOW = "rx/wow";
static const char *kDefyX = "defyx";
#endif
=======
>>>>>>> 72b7d934f615de1e17cf14453a8776e8ce0ad937
#ifdef XMRIG_ALGO_ARGON2
static const char *kArgon2 = "argon2";
static const char *kArgon2Impl = "argon2-impl";
#endif
@ -91,6 +94,7 @@ rapidjson::Value xmrig::CpuConfig::toJSON(rapidjson::Document &doc) const
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(kPriority), priority() != -1 ? Value(priority()) : Value(kNullType), allocator);
obj.AddMember(StringRef(kMemoryPool), m_memoryPool < 1 ? Value(m_memoryPool < 0) : Value(m_memoryPool), allocator);
if (m_threads.isEmpty()) {
obj.AddMember(StringRef(kMaxThreadsHint), m_limit, allocator);
@ -110,6 +114,12 @@ rapidjson::Value xmrig::CpuConfig::toJSON(rapidjson::Document &doc) const
}
size_t xmrig::CpuConfig::memPoolSize() const
{
return m_memoryPool < 0 ? Cpu::info()->threads() : m_memoryPool;
}
std::vector<xmrig::CpuLaunchData> xmrig::CpuConfig::get(const Miner *miner, const Algorithm &algorithm) const
{
std::vector<CpuLaunchData> out;
@ -129,7 +139,7 @@ std::vector<xmrig::CpuLaunchData> xmrig::CpuConfig::get(const Miner *miner, cons
}
void xmrig::CpuConfig::read(const rapidjson::Value &value, uint32_t version)
void xmrig::CpuConfig::read(const rapidjson::Value &value)
{
if (value.IsObject()) {
m_enabled = Json::getBool(value, kEnabled, m_enabled);
@ -138,6 +148,7 @@ void xmrig::CpuConfig::read(const rapidjson::Value &value, uint32_t version)
setAesMode(Json::getValue(value, kHwAes));
setPriority(Json::getInt(value, kPriority, -1));
setMemoryPool(Json::getValue(value, kMemoryPool));
# ifdef XMRIG_FEATURE_ASM
m_assembly = Json::getValue(value, kAsm);
@ -147,16 +158,14 @@ void xmrig::CpuConfig::read(const rapidjson::Value &value, uint32_t version)
m_argon2Impl = Json::getString(value, kArgon2Impl);
# endif
if (!m_threads.read(value)) {
generate();
}
m_threads.read(value);
if (version == 0) {
generateArgon2();
}
generate();
}
else if (value.IsBool() && value.IsFalse()) {
m_enabled = false;
else if (value.IsBool()) {
m_enabled = value.GetBool();
generate();
}
else {
generate();
@ -166,53 +175,40 @@ void xmrig::CpuConfig::read(const rapidjson::Value &value, uint32_t version)
void xmrig::CpuConfig::generate()
{
m_shouldSave = true;
ICpuInfo *cpu = Cpu::info();
if (!isEnabled() || m_threads.has("*")) {
return;
}
m_threads.disable(Algorithm::CN_0);
m_threads.move(kCn, cpu->threads(Algorithm::CN_0, m_limit));
size_t count = 0;
# ifdef XMRIG_ALGO_CN_GPU
m_threads.move(kCnGPU, cpu->threads(Algorithm::CN_GPU, m_limit));
# endif
count += xmrig::generate<Algorithm::CN>(m_threads, m_limit);
count += xmrig::generate<Algorithm::CN_LITE>(m_threads, m_limit);
count += xmrig::generate<Algorithm::CN_HEAVY>(m_threads, m_limit);
count += xmrig::generate<Algorithm::CN_PICO>(m_threads, m_limit);
count += xmrig::generate<Algorithm::RANDOM_X>(m_threads, m_limit);
count += xmrig::generate<Algorithm::ARGON2>(m_threads, m_limit);
# ifdef XMRIG_ALGO_CN_LITE
m_threads.disable(Algorithm::CN_LITE_0);
m_threads.move(kCnLite, cpu->threads(Algorithm::CN_LITE_1, m_limit));
# endif
# ifdef XMRIG_ALGO_CN_HEAVY
m_threads.move(kCnHeavy, cpu->threads(Algorithm::CN_HEAVY_0, m_limit));
# endif
# ifdef XMRIG_ALGO_CN_PICO
m_threads.move(kCnPico, cpu->threads(Algorithm::CN_PICO_0, m_limit));
# endif
# ifdef XMRIG_ALGO_RANDOMX
m_threads.move(kRx, cpu->threads(Algorithm::RX_0, m_limit));
m_threads.move(kRxWOW, cpu->threads(Algorithm::RX_WOW, m_limit));
m_threads.move(kDefyX, cpu->threads(Algorithm::DEFYX, m_limit));
# endif
generateArgon2();
m_shouldSave = count > 0;
}
void xmrig::CpuConfig::generateArgon2()
void xmrig::CpuConfig::setAesMode(const rapidjson::Value &value)
{
# ifdef XMRIG_ALGO_ARGON2
m_threads.move(kArgon2, Cpu::info()->threads(Algorithm::AR2_CHUKWA, m_limit));
# endif
}
void xmrig::CpuConfig::setAesMode(const rapidjson::Value &aesMode)
{
if (aesMode.IsBool()) {
m_aes = aesMode.GetBool() ? AES_HW : AES_SOFT;
if (value.IsBool()) {
m_aes = value.GetBool() ? AES_HW : AES_SOFT;
}
else {
m_aes = AES_AUTO;
}
}
void xmrig::CpuConfig::setMemoryPool(const rapidjson::Value &value)
{
if (value.IsBool()) {
m_memoryPool = value.GetBool() ? -1 : 0;
}
else if (value.IsInt()) {
m_memoryPool = value.GetInt();
}
}

View file

@ -48,8 +48,9 @@ public:
bool isHwAES() const;
rapidjson::Value toJSON(rapidjson::Document &doc) const;
size_t memPoolSize() const;
std::vector<CpuLaunchData> get(const Miner *miner, const Algorithm &algorithm) const;
void read(const rapidjson::Value &value, uint32_t version);
void read(const rapidjson::Value &value);
inline bool isEnabled() const { return m_enabled; }
inline bool isHugePages() const { return m_hugePages; }
@ -61,8 +62,8 @@ public:
private:
void generate();
void generateArgon2();
void setAesMode(const rapidjson::Value &aesMode);
void setAesMode(const rapidjson::Value &value);
void setMemoryPool(const rapidjson::Value &value);
inline void setPriority(int priority) { m_priority = (priority >= -1 && priority <= 5) ? priority : -1; }
@ -71,6 +72,7 @@ private:
bool m_enabled = true;
bool m_hugePages = true;
bool m_shouldSave = false;
int m_memoryPool = 0;
int m_priority = -1;
String m_argon2Impl;
Threads<CpuThreads> m_threads;

View file

@ -0,0 +1,149 @@
/* 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_CPUCONFIG_GEN_H
#define XMRIG_CPUCONFIG_GEN_H
#include "backend/common/Threads.h"
#include "backend/cpu/Cpu.h"
#include "backend/cpu/CpuThreads.h"
namespace xmrig {
static inline size_t generate(const char *key, Threads<CpuThreads> &threads, const Algorithm &algorithm, uint32_t limit)
{
if (threads.isExist(algorithm) || threads.has(key)) {
return 0;
}
return threads.move(key, Cpu::info()->threads(algorithm, limit));
}
template<Algorithm::Family FAMILY>
static inline size_t generate(Threads<CpuThreads> &, uint32_t) { return 0; }
template<>
size_t inline generate<Algorithm::CN>(Threads<CpuThreads> &threads, uint32_t limit)
{
size_t count = 0;
count += generate("cn", threads, Algorithm::CN_0, limit);
if (!threads.isExist(Algorithm::CN_0)) {
threads.disable(Algorithm::CN_0);
++count;
}
# ifdef XMRIG_ALGO_CN_GPU
count += generate("cn/gpu", threads, Algorithm::CN_GPU, limit);
# endif
return count;
}
#ifdef XMRIG_ALGO_CN_LITE
template<>
size_t inline generate<Algorithm::CN_LITE>(Threads<CpuThreads> &threads, uint32_t limit)
{
size_t count = 0;
count += generate("cn-lite", threads, Algorithm::CN_LITE_1, limit);
if (!threads.isExist(Algorithm::CN_LITE_0)) {
threads.disable(Algorithm::CN_LITE_0);
++count;
}
return count;
}
#endif
#ifdef XMRIG_ALGO_CN_HEAVY
template<>
size_t inline generate<Algorithm::CN_HEAVY>(Threads<CpuThreads> &threads, uint32_t limit)
{
return generate("cn-heavy", threads, Algorithm::CN_HEAVY_0, limit);
}
#endif
#ifdef XMRIG_ALGO_CN_PICO
template<>
size_t inline generate<Algorithm::CN_PICO>(Threads<CpuThreads> &threads, uint32_t limit)
{
return generate("cn-pico", threads, Algorithm::CN_PICO_0, limit);
}
#endif
#ifdef XMRIG_ALGO_RANDOMX
template<>
size_t inline generate<Algorithm::RANDOM_X>(Threads<CpuThreads> &threads, uint32_t limit)
{
size_t count = 0;
auto wow = Cpu::info()->threads(Algorithm::RX_WOW, limit);
if (!threads.isExist(Algorithm::RX_ARQ)) {
auto arq = Cpu::info()->threads(Algorithm::RX_ARQ, limit);
if (arq == wow) {
threads.setAlias(Algorithm::RX_ARQ, "rx/wow");
++count;
}
else {
count += threads.move("rx/arq", std::move(arq));
}
}
if (!threads.isExist(Algorithm::RX_WOW)) {
count += threads.move("rx/wow", std::move(wow));
}
count += generate("rx", threads, Algorithm::RX_0, limit);
return count;
}
#endif
#ifdef XMRIG_ALGO_ARGON2
template<>
size_t inline generate<Algorithm::ARGON2>(Threads<CpuThreads> &threads, uint32_t limit)
{
return generate("argon2", threads, Algorithm::AR2_CHUKWA, limit);
}
#endif
} /* namespace xmrig */
#endif /* XMRIG_CPUCONFIG_GEN_H */

View file

@ -120,6 +120,16 @@ xmrig::CpuThreads::CpuThreads(size_t count, uint32_t intensity)
}
bool xmrig::CpuThreads::isEqual(const CpuThreads &other) const
{
if (isEmpty() && other.isEmpty()) {
return true;
}
return count() == other.count() && std::equal(m_data.begin(), m_data.end(), other.m_data.begin());
}
rapidjson::Value xmrig::CpuThreads::toJSON(rapidjson::Document &doc) const
{
using namespace rapidjson;

View file

@ -38,7 +38,7 @@ namespace xmrig {
class CpuThreads
{
public:
inline CpuThreads() {}
inline CpuThreads() = default;
inline CpuThreads(size_t count) : m_data(count) {}
CpuThreads(const rapidjson::Value &value);
@ -51,6 +51,10 @@ public:
inline void add(int64_t affinity, uint32_t intensity) { add(CpuThread(affinity, intensity)); }
inline void reserve(size_t capacity) { m_data.reserve(capacity); }
inline bool operator!=(const CpuThreads &other) const { return !isEqual(other); }
inline bool operator==(const CpuThreads &other) const { return isEqual(other); }
bool isEqual(const CpuThreads &other) const;
rapidjson::Value toJSON(rapidjson::Document &doc) const;
private:

View file

@ -63,19 +63,19 @@ xmrig::CpuWorker<N>::CpuWorker(size_t id, const CpuLaunchData &data) :
m_miner(data.miner),
m_ctx()
{
m_memory = new VirtualMemory(m_algorithm.l3() * N, data.hugePages);
m_memory = new VirtualMemory(m_algorithm.l3() * N, data.hugePages, true, m_node);
}
template<size_t N>
xmrig::CpuWorker<N>::~CpuWorker()
{
CnCtx::release(m_ctx, N);
delete m_memory;
# ifdef XMRIG_ALGO_RANDOMX
delete m_vm;
# endif
CnCtx::release(m_ctx, N);
delete m_memory;
}

View file

@ -2,6 +2,7 @@ set(HEADERS_BACKEND_CPU
src/backend/cpu/Cpu.h
src/backend/cpu/CpuBackend.h
src/backend/cpu/CpuConfig.h
src/backend/cpu/CpuConfig_gen.h
src/backend/cpu/CpuLaunchData.cpp
src/backend/cpu/CpuThread.h
src/backend/cpu/CpuThreads.h

View file

@ -46,7 +46,6 @@
namespace xmrig {
std::vector<uint32_t> HwlocCpuInfo::m_nodeIndexes;
uint32_t HwlocCpuInfo::m_features = 0;
@ -185,11 +184,11 @@ xmrig::HwlocCpuInfo::HwlocCpuInfo()
m_features |= SET_THISTHREAD_MEMBIND;
}
m_nodeIndexes.reserve(m_nodes);
m_nodeset.reserve(m_nodes);
hwloc_obj_t node = nullptr;
while ((node = hwloc_get_next_obj_by_type(m_topology, HWLOC_OBJ_NUMANODE, node)) != nullptr) {
m_nodeIndexes.emplace_back(node->os_index);
m_nodeset.emplace_back(node->os_index);
}
}
}
@ -201,6 +200,20 @@ xmrig::HwlocCpuInfo::~HwlocCpuInfo()
}
bool xmrig::HwlocCpuInfo::membind(hwloc_const_bitmap_t nodeset)
{
if (!hwloc_topology_get_support(m_topology)->membind->set_thisthread_membind) {
return false;
}
# if HWLOC_API_VERSION >= 0x20000
return hwloc_set_membind(m_topology, nodeset, HWLOC_MEMBIND_BIND, HWLOC_MEMBIND_THREAD | HWLOC_MEMBIND_BYNODESET) >= 0;
# else
return hwloc_set_membind_nodeset(m_topology, nodeset, HWLOC_MEMBIND_BIND, HWLOC_MEMBIND_THREAD) >= 0;
# endif
}
xmrig::CpuThreads xmrig::HwlocCpuInfo::threads(const Algorithm &algorithm, uint32_t limit) const
{
if (L2() == 0 && L3() == 0) {

View file

@ -30,8 +30,9 @@
#include "base/tools/Object.h"
using hwloc_obj_t = struct hwloc_obj *;
using hwloc_topology_t = struct hwloc_topology *;
using hwloc_const_bitmap_t = const struct hwloc_bitmap_s *;
using hwloc_obj_t = struct hwloc_obj *;
using hwloc_topology_t = struct hwloc_topology *;
namespace xmrig {
@ -52,7 +53,11 @@ public:
~HwlocCpuInfo() override;
static inline bool has(Feature feature) { return m_features & feature; }
static inline const std::vector<uint32_t> &nodeIndexes() { return m_nodeIndexes; }
inline const std::vector<uint32_t> &nodeset() const { return m_nodeset; }
inline hwloc_topology_t topology() const { return m_topology; }
bool membind(hwloc_const_bitmap_t nodeset);
protected:
CpuThreads threads(const Algorithm &algorithm, uint32_t limit) const override;
@ -67,7 +72,7 @@ protected:
private:
void processTopLevelCache(hwloc_obj_t obj, const Algorithm &algorithm, CpuThreads &threads, size_t limit) const;
static std::vector<uint32_t> m_nodeIndexes;
static uint32_t m_features;
char m_backend[20] = { 0 };
@ -76,6 +81,7 @@ private:
size_t m_cores = 0;
size_t m_nodes = 0;
size_t m_packages = 0;
std::vector<uint32_t> m_nodeset;
};