From c13c62bf48e94b7f1a41a6268394e0fe20a070e3 Mon Sep 17 00:00:00 2001 From: XMRig Date: Mon, 29 Jul 2019 12:51:19 +0700 Subject: [PATCH 1/6] v2.99.3-evo --- src/version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/version.h b/src/version.h index 61621ad79..1d6f25915 100644 --- a/src/version.h +++ b/src/version.h @@ -28,7 +28,7 @@ #define APP_ID "xmrig" #define APP_NAME "XMRig" #define APP_DESC "XMRig CPU miner" -#define APP_VERSION "2.99.2-beta" +#define APP_VERSION "2.99.3-evo" #define APP_DOMAIN "xmrig.com" #define APP_SITE "www.xmrig.com" #define APP_COPYRIGHT "Copyright (C) 2016-2019 xmrig.com" @@ -36,7 +36,7 @@ #define APP_VER_MAJOR 2 #define APP_VER_MINOR 99 -#define APP_VER_PATCH 2 +#define APP_VER_PATCH 3 #ifdef _MSC_VER # if (_MSC_VER >= 1920) From 0ae1e5f1d41e71bd4d277b95b1284539cf06603e Mon Sep 17 00:00:00 2001 From: XMRig Date: Mon, 29 Jul 2019 15:06:46 +0700 Subject: [PATCH 2/6] Sync changes. --- src/api/Api.cpp | 14 ++++++++------ src/api/Api.h | 2 +- src/crypto/common/Algorithm.cpp | 15 +++++++++++++-- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/api/Api.cpp b/src/api/Api.cpp index 9151aa7ef..4c8e73230 100644 --- a/src/api/Api.cpp +++ b/src/api/Api.cpp @@ -40,7 +40,6 @@ #include "base/tools/Chrono.h" #include "core/config/Config.h" #include "core/Controller.h" -#include "crypto/common/Algorithm.h" #include "crypto/common/keccak.h" #include "version.h" @@ -54,8 +53,8 @@ xmrig::Api::Api(Base *base) : m_base(base), m_id(), m_workerId(), - m_httpd(nullptr), - m_timestamp(Chrono::steadyMSecs()) + m_timestamp(Chrono::currentMSecsSinceEpoch()), + m_httpd(nullptr) { base->addListener(this); @@ -120,7 +119,7 @@ void xmrig::Api::exec(IApiRequest &request) request.accept(); request.reply().AddMember("id", StringRef(m_id), allocator); request.reply().AddMember("worker_id", StringRef(m_workerId), allocator); - request.reply().AddMember("uptime", (Chrono::steadyMSecs() - m_timestamp) / 1000, allocator); + request.reply().AddMember("uptime", (Chrono::currentMSecsSinceEpoch() - m_timestamp) / 1000, allocator); Value features(kArrayType); # ifdef XMRIG_FEATURE_API @@ -135,6 +134,9 @@ void xmrig::Api::exec(IApiRequest &request) # ifdef XMRIG_FEATURE_LIBCPUID features.PushBack("cpuid", allocator); # endif +# ifdef XMRIG_FEATURE_HWLOC + features.PushBack("hwloc", allocator); +# endif # ifdef XMRIG_FEATURE_TLS features.PushBack("tls", allocator); # endif @@ -181,8 +183,8 @@ void xmrig::Api::genId(const String &id) memcpy(input + sizeof(uint16_t), interfaces[i].phys_addr, addrSize); memcpy(input + sizeof(uint16_t) + addrSize, APP_KIND, strlen(APP_KIND)); - xmrig::keccak(input, inSize, hash); - xmrig::Buffer::toHex(hash, 8, m_id); + keccak(input, inSize, hash); + Buffer::toHex(hash, 8, m_id); delete [] input; break; diff --git a/src/api/Api.h b/src/api/Api.h index f2ed39269..334609c95 100644 --- a/src/api/Api.h +++ b/src/api/Api.h @@ -69,9 +69,9 @@ private: Base *m_base; char m_id[32]; char m_workerId[128]; + const uint64_t m_timestamp; Httpd *m_httpd; std::vector m_listeners; - uint64_t m_timestamp; }; diff --git a/src/crypto/common/Algorithm.cpp b/src/crypto/common/Algorithm.cpp index 2c259d321..c7990052a 100644 --- a/src/crypto/common/Algorithm.cpp +++ b/src/crypto/common/Algorithm.cpp @@ -32,7 +32,6 @@ #include "crypto/cn/CnAlgo.h" #include "crypto/common/Algorithm.h" -#include "crypto/rx/RxAlgo.h" #include "rapidjson/document.h" @@ -140,7 +139,19 @@ size_t xmrig::Algorithm::memory() const # ifdef XMRIG_ALGO_RANDOMX if (f == RANDOM_X) { - return RxAlgo::l3(m_id); + constexpr size_t oneMiB = 0x100000; + + switch (m_id) { + case RX_0: + case RX_LOKI: + return oneMiB * 2; + + case RX_WOW: + return oneMiB; + + default: + break; + } } # endif From 6b3b1c3fc412981e51892bafd62b3dc4c1f87e7d Mon Sep 17 00:00:00 2001 From: XMRig Date: Mon, 29 Jul 2019 19:24:53 +0700 Subject: [PATCH 3/6] #1082 Fixed hwloc autoconfig with AMD FX CPUs. --- src/backend/cpu/platform/HwlocCpuInfo.cpp | 28 +++++++++++++---------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/backend/cpu/platform/HwlocCpuInfo.cpp b/src/backend/cpu/platform/HwlocCpuInfo.cpp index eee59a3a4..48a17f234 100644 --- a/src/backend/cpu/platform/HwlocCpuInfo.cpp +++ b/src/backend/cpu/platform/HwlocCpuInfo.cpp @@ -84,6 +84,15 @@ static inline void findByType(hwloc_obj_t obj, hwloc_obj_type_t type, func lambd } +static inline std::vector findByType(hwloc_obj_t obj, hwloc_obj_type_t type) +{ + std::vector out; + findByType(obj, type, [&out](hwloc_obj_t found) { out.emplace_back(found); }); + + return out; +} + + static inline size_t countByType(hwloc_topology_t topology, hwloc_obj_type_t type) { const int count = hwloc_get_nbobjs_by_type(topology, type); @@ -132,8 +141,7 @@ xmrig::HwlocCpuInfo::HwlocCpuInfo() : BasicCpuInfo(), } # endif - std::vector packages; - findByType(hwloc_get_root_obj(m_topology), HWLOC_OBJ_PACKAGE, [&packages](hwloc_obj_t found) { packages.emplace_back(found); }); + const std::vector packages = findByType(hwloc_get_root_obj(m_topology), HWLOC_OBJ_PACKAGE); if (packages.size()) { const char *value = hwloc_obj_get_info_by_name(packages[0], "CPUModel"); if (value) { @@ -249,14 +257,9 @@ void xmrig::HwlocCpuInfo::processTopLevelCache(hwloc_obj_t cache, const Algorith if (cacheHashes >= PUs) { for (hwloc_obj_t core : cores) { - if (core->arity == 0) { - continue; - } - - for (unsigned i = 0; i < core->arity; ++i) { - if (core->children[i]->type == HWLOC_OBJ_PU) { - threads.push_back(CpuThread(1, core->children[i]->os_index)); - } + const std::vector units = findByType(core, HWLOC_OBJ_PU); + for (hwloc_obj_t pu : units) { + threads.push_back(CpuThread(1, pu->os_index)); } } @@ -268,7 +271,8 @@ void xmrig::HwlocCpuInfo::processTopLevelCache(hwloc_obj_t cache, const Algorith bool allocated_pu = false; for (hwloc_obj_t core : cores) { - if (core->arity <= pu_id || core->children[pu_id]->type != HWLOC_OBJ_PU) { + const std::vector units = findByType(core, HWLOC_OBJ_PU); + if (units.size() <= pu_id) { continue; } @@ -276,7 +280,7 @@ void xmrig::HwlocCpuInfo::processTopLevelCache(hwloc_obj_t cache, const Algorith PUs--; allocated_pu = true; - threads.push_back(CpuThread(1, core->children[pu_id]->os_index)); + threads.push_back(CpuThread(1, units[pu_id]->os_index)); if (cacheHashes == 0) { break; From bd739d217b9be4aacca1a4d5537ba6d60a57992c Mon Sep 17 00:00:00 2001 From: XMRig Date: Tue, 30 Jul 2019 09:06:50 +0700 Subject: [PATCH 4/6] Added command line option --export-topology. --- src/base/kernel/Entry.cpp | 46 ++++++++++++++++++++++++++++++++++++++- src/base/kernel/Entry.h | 3 ++- src/core/config/usage.h | 4 ++++ 3 files changed, 51 insertions(+), 2 deletions(-) diff --git a/src/base/kernel/Entry.cpp b/src/base/kernel/Entry.cpp index da225e40c..f9e97c2d7 100644 --- a/src/base/kernel/Entry.cpp +++ b/src/base/kernel/Entry.cpp @@ -41,6 +41,9 @@ #include "version.h" +namespace xmrig { + + static int showVersion() { printf(APP_NAME " " APP_VERSION "\n built on " __DATE__ @@ -92,6 +95,36 @@ static int showVersion() } +#ifdef XMRIG_FEATURE_HWLOC +static int exportTopology(const Process &process) +{ + const String path = process.location(Process::ExeLocation, "topology.xml"); + + hwloc_topology_t topology; + hwloc_topology_init(&topology); + hwloc_topology_load(topology); + +# if HWLOC_API_VERSION >= 0x20000 + if (hwloc_topology_export_xml(topology, path, 0) == -1) { +# else + if (hwloc_topology_export_xml(topology, path) == -1) { +# endif + printf("failed to export hwloc topology.\n"); + } + else { + printf("hwloc topology successfully exported to \"%s\"\n", path.data()); + } + + hwloc_topology_destroy(topology); + + return 0; +} +#endif + + +} // namespace xmrig + + xmrig::Entry::Id xmrig::Entry::get(const Process &process) { const Arguments &args = process.arguments(); @@ -103,11 +136,17 @@ xmrig::Entry::Id xmrig::Entry::get(const Process &process) return Version; } +# ifdef XMRIG_FEATURE_HWLOC + if (args.hasArg("--export-topology")) { + return Topo; + } +# endif + return Default; } -int xmrig::Entry::exec(const Process &, Id id) +int xmrig::Entry::exec(const Process &process, Id id) { switch (id) { case Usage: @@ -117,6 +156,11 @@ int xmrig::Entry::exec(const Process &, Id id) case Version: return showVersion(); +# ifdef XMRIG_FEATURE_HWLOC + case Topo: + return exportTopology(process); +# endif + default: break; } diff --git a/src/base/kernel/Entry.h b/src/base/kernel/Entry.h index 0208ecdb2..c0bde080d 100644 --- a/src/base/kernel/Entry.h +++ b/src/base/kernel/Entry.h @@ -38,7 +38,8 @@ public: enum Id { Default, Usage, - Version + Version, + Topo }; static Id get(const Process &process); diff --git a/src/core/config/usage.h b/src/core/config/usage.h index 275a58f9f..b41ec6db8 100644 --- a/src/core/config/usage.h +++ b/src/core/config/usage.h @@ -113,6 +113,10 @@ Options:\n\ --randomx-init=N threads count to initialize RandomX dataset\n\ --randomx-no-numa disable NUMA support for RandomX\n" #endif +#ifdef XMRIG_FEATURE_HWLOC +"\ + --export-topology export hwloc topology to a XML file and exit\n" +#endif "\ --dry-run test configuration and exit\n\ -h, --help display this help and exit\n\ From aabf183462d4a19c1dbb93447f54afea31d2a2cc Mon Sep 17 00:00:00 2001 From: XMRig Date: Tue, 30 Jul 2019 09:17:54 +0700 Subject: [PATCH 5/6] Added fallback to basic auto configuration. --- src/backend/cpu/platform/HwlocCpuInfo.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/backend/cpu/platform/HwlocCpuInfo.cpp b/src/backend/cpu/platform/HwlocCpuInfo.cpp index 48a17f234..98f559890 100644 --- a/src/backend/cpu/platform/HwlocCpuInfo.cpp +++ b/src/backend/cpu/platform/HwlocCpuInfo.cpp @@ -33,6 +33,7 @@ #include "backend/cpu/platform/HwlocCpuInfo.h" +#include "base/io/log/Log.h" namespace xmrig { @@ -201,6 +202,12 @@ xmrig::CpuThreads xmrig::HwlocCpuInfo::threads(const Algorithm &algorithm) const processTopLevelCache(cache, algorithm, threads); } + if (threads.empty()) { + LOG_WARN("hwloc auto configuration for algorithm \"%s\" failed.", algorithm.shortName()); + + return BasicCpuInfo::threads(algorithm); + } + return threads; } From 5a88ed7eadcf732eaf5b322b98be6a6e140550f5 Mon Sep 17 00:00:00 2001 From: xmrig Date: Tue, 30 Jul 2019 09:25:39 +0700 Subject: [PATCH 6/6] Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a480f8dc..c1cab4a99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# v2.99.3-beta +- [#1082](https://github.com/xmrig/xmrig/issues/1082) Fixed hwloc auto configuration on AMD FX CPUs. +- Added command line option `--export-topology` for export hwloc topology to a XML file. + # v2.99.2-beta - [#1077](https://github.com/xmrig/xmrig/issues/1077) Added NUMA support via **hwloc**. - Fixed miner freeze when switch between RandomX variants.