mirror of
https://github.com/xmrig/xmrig.git
synced 2026-01-14 12:02:45 -05:00
Compare commits
6 Commits
8f7abc5c91
...
b9d6b7a165
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b9d6b7a165 | ||
|
|
98c775703e | ||
|
|
8da49f2650 | ||
|
|
4570187459 | ||
|
|
748365d6e3 | ||
|
|
14128cbdb4 |
@@ -1,6 +1,6 @@
|
||||
/* XMRig
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2024 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2024 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
|
||||
@@ -126,11 +126,6 @@ size_t inline generate<Algorithm::RANDOM_X>(Threads<CpuThreads> &threads, uint32
|
||||
count += threads.move(Algorithm::kRX_WOW, std::move(wow));
|
||||
}
|
||||
|
||||
if (!threads.isExist(Algorithm::RX_YADA)) {
|
||||
auto yada = cpuInfo->threads(Algorithm::RX_YADA, limit);
|
||||
count += threads.move(Algorithm::kRX_YADA, std::move(yada));
|
||||
}
|
||||
|
||||
count += generate(Algorithm::kRX, threads, Algorithm::RX_0, limit);
|
||||
|
||||
return count;
|
||||
|
||||
@@ -29,6 +29,10 @@
|
||||
#ifdef XMRIG_FEATURE_HWLOC
|
||||
using hwloc_const_bitmap_t = const struct hwloc_bitmap_s *;
|
||||
using hwloc_topology_t = struct hwloc_topology *;
|
||||
#define MEMBIND_SUCCESS 1
|
||||
#define MEMBIND_FAIL_SUPP -1
|
||||
#define MEMBIND_FAIL_NODE -2
|
||||
#define MEMBIND_FAIL_BIND -3
|
||||
#endif
|
||||
|
||||
|
||||
@@ -52,7 +56,8 @@ public:
|
||||
ARCH_ZEN_PLUS,
|
||||
ARCH_ZEN2,
|
||||
ARCH_ZEN3,
|
||||
ARCH_ZEN4
|
||||
ARCH_ZEN4,
|
||||
ARCH_ZEN5
|
||||
};
|
||||
|
||||
enum MsrMod : uint32_t {
|
||||
@@ -60,12 +65,13 @@ public:
|
||||
MSR_MOD_RYZEN_17H,
|
||||
MSR_MOD_RYZEN_19H,
|
||||
MSR_MOD_RYZEN_19H_ZEN4,
|
||||
MSR_MOD_RYZEN_1AH_ZEN5,
|
||||
MSR_MOD_INTEL,
|
||||
MSR_MOD_CUSTOM,
|
||||
MSR_MOD_MAX
|
||||
};
|
||||
|
||||
# define MSR_NAMES_LIST "none", "ryzen_17h", "ryzen_19h", "ryzen_19h_zen4", "intel", "custom"
|
||||
# define MSR_NAMES_LIST "none", "ryzen_17h", "ryzen_19h", "ryzen_19h_zen4", "ryzen_1Ah_zen5", "intel", "custom"
|
||||
|
||||
enum Flag : uint32_t {
|
||||
FLAG_AES,
|
||||
@@ -124,7 +130,7 @@ public:
|
||||
virtual uint32_t model() const = 0;
|
||||
|
||||
# ifdef XMRIG_FEATURE_HWLOC
|
||||
virtual bool membind(hwloc_const_bitmap_t nodeset) = 0;
|
||||
virtual int8_t membind(hwloc_const_bitmap_t nodeset) = 0;
|
||||
virtual const std::vector<uint32_t> &nodeset() const = 0;
|
||||
virtual hwloc_topology_t topology() const = 0;
|
||||
# endif
|
||||
|
||||
@@ -64,7 +64,7 @@ static_assert(kCpuFlagsSize == ICpuInfo::FLAG_MAX, "kCpuFlagsSize and FLAG_MAX m
|
||||
|
||||
|
||||
#ifdef XMRIG_FEATURE_MSR
|
||||
constexpr size_t kMsrArraySize = 6;
|
||||
constexpr size_t kMsrArraySize = 7;
|
||||
static const std::array<const char *, kMsrArraySize> msrNames = { MSR_NAMES_LIST };
|
||||
static_assert(kMsrArraySize == ICpuInfo::MSR_MOD_MAX, "kMsrArraySize and MSR_MOD_MAX mismatch");
|
||||
#endif
|
||||
@@ -260,6 +260,11 @@ xmrig::BasicCpuInfo::BasicCpuInfo() :
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x1a:
|
||||
m_arch = ARCH_ZEN5;
|
||||
m_msrMod = MSR_MOD_RYZEN_1AH_ZEN5;
|
||||
break;
|
||||
|
||||
default:
|
||||
m_msrMod = MSR_MOD_NONE;
|
||||
break;
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <errno.h>
|
||||
#include <hwloc.h>
|
||||
|
||||
|
||||
@@ -191,16 +192,25 @@ xmrig::HwlocCpuInfo::~HwlocCpuInfo()
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::HwlocCpuInfo::membind(hwloc_const_bitmap_t nodeset)
|
||||
int8_t xmrig::HwlocCpuInfo::membind(hwloc_const_bitmap_t nodeset)
|
||||
{
|
||||
if (!hwloc_topology_get_support(m_topology)->membind->set_thisthread_membind) {
|
||||
return false;
|
||||
return MEMBIND_FAIL_SUPP;
|
||||
}
|
||||
|
||||
# if HWLOC_API_VERSION >= 0x20000
|
||||
return hwloc_set_membind(m_topology, nodeset, HWLOC_MEMBIND_BIND, HWLOC_MEMBIND_THREAD | HWLOC_MEMBIND_BYNODESET) >= 0;
|
||||
int rv = hwloc_set_membind(m_topology, nodeset, HWLOC_MEMBIND_BIND, HWLOC_MEMBIND_THREAD | HWLOC_MEMBIND_BYNODESET);
|
||||
int error = errno;
|
||||
|
||||
if (rv < 0) {
|
||||
LOG_WARN("hwloc_set_membind() error: \"%s\"\n", strerror(error));
|
||||
return MEMBIND_FAIL_BIND;
|
||||
}
|
||||
|
||||
return MEMBIND_SUCCESS;
|
||||
# else
|
||||
return hwloc_set_membind_nodeset(m_topology, nodeset, HWLOC_MEMBIND_BIND, HWLOC_MEMBIND_THREAD) >= 0;
|
||||
return (hwloc_set_membind_nodeset(m_topology, nodeset, HWLOC_MEMBIND_BIND, HWLOC_MEMBIND_THREAD) >= 0)
|
||||
? MEMBIND_SUCCESS : MEMBIND_FAIL_BIND;
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
~HwlocCpuInfo() override;
|
||||
|
||||
protected:
|
||||
bool membind(hwloc_const_bitmap_t nodeset) override;
|
||||
int8_t membind(hwloc_const_bitmap_t nodeset) override;
|
||||
CpuThreads threads(const Algorithm &algorithm, uint32_t limit) const override;
|
||||
|
||||
inline const char *backend() const override { return m_backend; }
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2019 Howard Chu <https://github.com/hyc>
|
||||
* Copyright 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2024 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2024 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
|
||||
@@ -24,11 +24,9 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
||||
|
||||
#include "base/net/stratum/Job.h"
|
||||
#include "base/tools/Alignment.h"
|
||||
#include "base/tools/Buffer.h"
|
||||
@@ -112,26 +110,36 @@ bool xmrig::Job::setSeedHash(const char *hash)
|
||||
|
||||
bool xmrig::Job::setTarget(const char *target)
|
||||
{
|
||||
if (!target) {
|
||||
static auto parse = [](const char *target, const Algorithm &algorithm) -> uint64_t {
|
||||
if (!target) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (algorithm == Algorithm::RX_YADA) {
|
||||
return strtoull(target, nullptr, 16);
|
||||
}
|
||||
|
||||
const auto raw = Cvt::fromHex(target, strlen(target));
|
||||
|
||||
switch (raw.size()) {
|
||||
case 4:
|
||||
return 0xFFFFFFFFFFFFFFFFULL / (0xFFFFFFFFULL / uint64_t(*reinterpret_cast<const uint32_t *>(raw.data())));
|
||||
|
||||
case 8:
|
||||
return *reinterpret_cast<const uint64_t *>(raw.data());
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
if ((m_target = parse(target, algorithm())) == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto raw = Cvt::fromHex(target, strlen(target));
|
||||
const size_t size = raw.size();
|
||||
if (algorithm() == Algorithm::RX_YADA) {
|
||||
m_target = strtoull(target, nullptr, 16);
|
||||
}
|
||||
else {
|
||||
if (size == 4) {
|
||||
m_target = 0xFFFFFFFFFFFFFFFFULL / (0xFFFFFFFFULL / uint64_t(*reinterpret_cast<const uint32_t *>(raw.data())));
|
||||
}
|
||||
else if (size == 8) {
|
||||
m_target = *reinterpret_cast<const uint64_t *>(raw.data());
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
m_diff = toDiff(m_target);
|
||||
|
||||
# ifdef XMRIG_PROXY_PROJECT
|
||||
assert(sizeof(m_rawTarget) > (size * 2));
|
||||
@@ -140,7 +148,6 @@ bool xmrig::Job::setTarget(const char *target)
|
||||
memcpy(m_rawTarget, target, std::min(size * 2, sizeof(m_rawTarget)));
|
||||
# endif
|
||||
|
||||
m_diff = toDiff(m_target);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -177,14 +184,22 @@ void xmrig::Job::setSigKey(const char *sig_key)
|
||||
|
||||
int32_t xmrig::Job::nonceOffset() const
|
||||
{
|
||||
auto f = algorithm().family();
|
||||
if (f == Algorithm::KAWPOW) return 32;
|
||||
if (f == Algorithm::GHOSTRIDER) return 76;
|
||||
switch (algorithm().family()) {
|
||||
case Algorithm::KAWPOW:
|
||||
return 32;
|
||||
|
||||
auto id = algorithm().id();
|
||||
if (id == Algorithm::RX_YADA) return 147;
|
||||
case Algorithm::GHOSTRIDER:
|
||||
return 76;
|
||||
|
||||
return 39;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (algorithm() == Algorithm::RX_YADA) {
|
||||
return 147;
|
||||
}
|
||||
|
||||
return 39;
|
||||
}
|
||||
|
||||
uint32_t xmrig::Job::getNumTransactions() const
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2019 Howard Chu <https://github.com/hyc>
|
||||
* Copyright 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2024 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2024 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
|
||||
@@ -27,11 +27,9 @@
|
||||
#ifndef XMRIG_JOB_H
|
||||
#define XMRIG_JOB_H
|
||||
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
|
||||
#include "base/crypto/Algorithm.h"
|
||||
#include "base/tools/Buffer.h"
|
||||
#include "base/tools/String.h"
|
||||
@@ -111,7 +109,7 @@ public:
|
||||
|
||||
inline bool operator!=(const Job &other) const { return !isEqual(other); }
|
||||
inline bool operator==(const Job &other) const { return isEqual(other); }
|
||||
inline Job &operator=(const Job &other) { copy(other); return *this; }
|
||||
inline Job &operator=(const Job &other) { if (this != &other) { copy(other); } return *this; }
|
||||
inline Job &operator=(Job &&other) noexcept { move(std::move(other)); return *this; }
|
||||
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
|
||||
@@ -34,8 +34,13 @@ uint32_t xmrig::VirtualMemory::bindToNUMANode(int64_t affinity)
|
||||
|
||||
auto pu = hwloc_get_pu_obj_by_os_index(Cpu::info()->topology(), static_cast<unsigned>(affinity));
|
||||
|
||||
if (pu == nullptr || !Cpu::info()->membind(pu->nodeset)) {
|
||||
LOG_WARN("CPU #%02" PRId64 " warning: \"can't bind memory\"", affinity);
|
||||
if (pu == nullptr) {
|
||||
LOG_WARN("CPU #%02" PRId64 " warning: \"can't bind memory: hwloc_get_pu_obj_by_os_index() failed\"", affinity);
|
||||
|
||||
return 0;
|
||||
}
|
||||
if (Cpu::info()->membind(pu->nodeset) < 0) {
|
||||
LOG_WARN("CPU #%02" PRId64 " warning: \"can't bind memory: Cpu::info()->membind() failed\"", affinity);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -266,6 +266,10 @@ namespace randomx {
|
||||
// AVX2 init is slower on Zen4
|
||||
initDatasetAVX2 = false;
|
||||
break;
|
||||
case xmrig::ICpuInfo::ARCH_ZEN5:
|
||||
// TODO: test it
|
||||
initDatasetAVX2 = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,13 +53,17 @@ static const std::array<const char *, RxConfig::ModeMax> modeNames = { "auto", "
|
||||
|
||||
|
||||
#ifdef XMRIG_FEATURE_MSR
|
||||
constexpr size_t kMsrArraySize = 6;
|
||||
constexpr size_t kMsrArraySize = 7;
|
||||
|
||||
static const std::array<MsrItems, kMsrArraySize> msrPresets = {
|
||||
MsrItems(),
|
||||
MsrItems{{ 0xC0011020, 0ULL }, { 0xC0011021, 0x40ULL, ~0x20ULL }, { 0xC0011022, 0x1510000ULL }, { 0xC001102b, 0x2000cc16ULL }},
|
||||
MsrItems{{ 0xC0011020, 0x0004480000000000ULL }, { 0xC0011021, 0x001c000200000040ULL, ~0x20ULL }, { 0xC0011022, 0xc000000401570000ULL }, { 0xC001102b, 0x2000cc10ULL }},
|
||||
MsrItems{{ 0xC0011020, 0x0004400000000000ULL }, { 0xC0011021, 0x0004000000000040ULL, ~0x20ULL }, { 0xC0011022, 0x8680000401570000ULL }, { 0xC001102b, 0x2040cc10ULL }},
|
||||
|
||||
// TODO: Tune it for Zen5 when it's available
|
||||
MsrItems{{ 0xC0011020, 0x0004400000000000ULL }, { 0xC0011021, 0x0004000000000040ULL, ~0x20ULL }, { 0xC0011022, 0x8680000401570000ULL }, { 0xC001102b, 0x2040cc10ULL }},
|
||||
|
||||
MsrItems{{ 0x1a4, 0xf }},
|
||||
MsrItems()
|
||||
};
|
||||
|
||||
@@ -42,20 +42,20 @@ constexpr size_t oneMiB = 1024 * 1024;
|
||||
static std::mutex mutex;
|
||||
|
||||
|
||||
static bool bindToNUMANode(uint32_t nodeId)
|
||||
static int8_t bindToNUMANode(uint32_t nodeId)
|
||||
{
|
||||
auto node = hwloc_get_numanode_obj_by_os_index(Cpu::info()->topology(), nodeId);
|
||||
if (!node) {
|
||||
return false;
|
||||
return MEMBIND_FAIL_NODE;
|
||||
}
|
||||
|
||||
if (Cpu::info()->membind(node->nodeset)) {
|
||||
if (Cpu::info()->membind(node->nodeset) > 0) {
|
||||
Platform::setThreadAffinity(static_cast<uint64_t>(hwloc_bitmap_first(node->cpuset)));
|
||||
|
||||
return true;
|
||||
return MEMBIND_SUCCESS;
|
||||
}
|
||||
|
||||
return false;
|
||||
return MEMBIND_FAIL_BIND;
|
||||
}
|
||||
|
||||
|
||||
@@ -210,10 +210,20 @@ private:
|
||||
static void allocate(RxNUMAStoragePrivate *d_ptr, uint32_t nodeId, bool hugePages, bool oneGbPages)
|
||||
{
|
||||
const uint64_t ts = Chrono::steadyMSecs();
|
||||
const int8_t br = bindToNUMANode(nodeId);
|
||||
|
||||
if (!bindToNUMANode(nodeId)) {
|
||||
printSkipped(nodeId, "can't bind memory");
|
||||
|
||||
if (br < 0) {
|
||||
switch (br) {
|
||||
case MEMBIND_FAIL_SUPP:
|
||||
printSkipped(nodeId, "can't bind memory: hwloc_topology_get_support() failed");
|
||||
break;
|
||||
case MEMBIND_FAIL_NODE:
|
||||
printSkipped(nodeId, "can't bind memory: hwloc_get_numanode_obj_by_os_index() failed");
|
||||
break;
|
||||
case MEMBIND_FAIL_BIND:
|
||||
printSkipped(nodeId, "can't bind memory: Cpu::info()->membind() failed");
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user