Added cmake option HWLOC_DEBUG.
This commit is contained in:
parent
107f378f7c
commit
2876702ea2
6 changed files with 53 additions and 19 deletions
|
@ -12,9 +12,11 @@ option(WITH_HTTP "HTTP protocol support (client/server)" ON)
|
||||||
option(WITH_DEBUG_LOG "Enable debug log output" OFF)
|
option(WITH_DEBUG_LOG "Enable debug log output" OFF)
|
||||||
option(WITH_TLS "Enable OpenSSL support" ON)
|
option(WITH_TLS "Enable OpenSSL support" ON)
|
||||||
option(WITH_ASM "Enable ASM PoW implementations" ON)
|
option(WITH_ASM "Enable ASM PoW implementations" ON)
|
||||||
|
option(WITH_EMBEDDED_CONFIG "Enable internal embedded JSON config" OFF)
|
||||||
|
|
||||||
option(BUILD_STATIC "Build static binary" OFF)
|
option(BUILD_STATIC "Build static binary" OFF)
|
||||||
option(ARM_TARGET "Force use specific ARM target 8 or 7" 0)
|
option(ARM_TARGET "Force use specific ARM target 8 or 7" 0)
|
||||||
option(WITH_EMBEDDED_CONFIG "Enable internal embedded JSON config" OFF)
|
option(HWLOC_DEBUG "Enable hwloc debug helpers and log" OFF)
|
||||||
|
|
||||||
|
|
||||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
|
||||||
|
|
|
@ -28,6 +28,10 @@ if (WITH_HWLOC)
|
||||||
remove_definitions(/DXMRIG_FEATURE_LIBCPUID)
|
remove_definitions(/DXMRIG_FEATURE_LIBCPUID)
|
||||||
add_definitions(/DXMRIG_FEATURE_HWLOC)
|
add_definitions(/DXMRIG_FEATURE_HWLOC)
|
||||||
|
|
||||||
|
if (HWLOC_DEBUG)
|
||||||
|
add_definitions(/DXMRIG_HWLOC_DEBUG)
|
||||||
|
endif()
|
||||||
|
|
||||||
set(CPUID_LIB "")
|
set(CPUID_LIB "")
|
||||||
set(SOURCES_CPUID
|
set(SOURCES_CPUID
|
||||||
src/backend/cpu/platform/BasicCpuInfo.cpp
|
src/backend/cpu/platform/BasicCpuInfo.cpp
|
||||||
|
|
|
@ -141,10 +141,10 @@ static inline bool has_avx2()
|
||||||
|
|
||||||
|
|
||||||
xmrig::BasicCpuInfo::BasicCpuInfo() :
|
xmrig::BasicCpuInfo::BasicCpuInfo() :
|
||||||
|
m_brand(),
|
||||||
m_threads(std::thread::hardware_concurrency()),
|
m_threads(std::thread::hardware_concurrency()),
|
||||||
m_assembly(Assembly::NONE),
|
m_assembly(Assembly::NONE),
|
||||||
m_aes(has_aes_ni()),
|
m_aes(has_aes_ni()),
|
||||||
m_brand(),
|
|
||||||
m_avx2(has_avx2())
|
m_avx2(has_avx2())
|
||||||
{
|
{
|
||||||
cpu_brand_string(m_brand);
|
cpu_brand_string(m_brand);
|
||||||
|
|
|
@ -53,12 +53,12 @@ protected:
|
||||||
inline size_t threads() const override { return m_threads; }
|
inline size_t threads() const override { return m_threads; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
char m_brand[64 + 6];
|
||||||
size_t m_threads;
|
size_t m_threads;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Assembly m_assembly;
|
Assembly m_assembly;
|
||||||
bool m_aes;
|
bool m_aes;
|
||||||
char m_brand[64 + 6];
|
|
||||||
const bool m_avx2;
|
const bool m_avx2;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef XMRIG_HWLOC_DEBUG
|
||||||
|
# include <uv.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <hwloc.h>
|
#include <hwloc.h>
|
||||||
|
|
||||||
|
|
||||||
|
@ -107,21 +113,46 @@ xmrig::HwlocCpuInfo::HwlocCpuInfo() : BasicCpuInfo(),
|
||||||
{
|
{
|
||||||
m_threads = 0;
|
m_threads = 0;
|
||||||
|
|
||||||
hwloc_topology_t topology;
|
hwloc_topology_init(&m_topology);
|
||||||
hwloc_topology_init(&topology);
|
hwloc_topology_load(m_topology);
|
||||||
hwloc_topology_load(topology);
|
|
||||||
|
|
||||||
hwloc_obj_t root = hwloc_get_root_obj(topology);
|
# ifdef XMRIG_HWLOC_DEBUG
|
||||||
|
# if defined(UV_VERSION_HEX) && UV_VERSION_HEX >= 0x010c00
|
||||||
|
{
|
||||||
|
char env[520] = { 0 };
|
||||||
|
size_t size = sizeof(env);
|
||||||
|
|
||||||
|
if (uv_os_getenv("HWLOC_XMLFILE", env, &size) == 0) {
|
||||||
|
printf("use HWLOC XML file: \"%s\"\n", env);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
|
std::vector<hwloc_obj_t> packages;
|
||||||
|
findByType(hwloc_get_root_obj(m_topology), HWLOC_OBJ_PACKAGE, [&packages](hwloc_obj_t found) { packages.emplace_back(found); });
|
||||||
|
if (packages.size()) {
|
||||||
|
const char *value = hwloc_obj_get_info_by_name(packages[0], "CPUModel");
|
||||||
|
if (value) {
|
||||||
|
strncpy(m_brand, value, 64);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
|
hwloc_obj_t root = hwloc_get_root_obj(m_topology);
|
||||||
snprintf(m_backend, sizeof m_backend, "hwloc/%s", hwloc_obj_get_info_by_name(root, "hwlocVersion"));
|
snprintf(m_backend, sizeof m_backend, "hwloc/%s", hwloc_obj_get_info_by_name(root, "hwlocVersion"));
|
||||||
|
|
||||||
findCache(root, 2, 3, [this](hwloc_obj_t found) { this->m_cache[found->attr->cache.depth] += found->attr->cache.size; });
|
findCache(root, 2, 3, [this](hwloc_obj_t found) { this->m_cache[found->attr->cache.depth] += found->attr->cache.size; });
|
||||||
|
|
||||||
m_threads = countByType(topology, HWLOC_OBJ_PU);
|
m_threads = countByType(m_topology, HWLOC_OBJ_PU);
|
||||||
m_cores = countByType(topology, HWLOC_OBJ_CORE);
|
m_cores = countByType(m_topology, HWLOC_OBJ_CORE);
|
||||||
m_nodes = countByType(topology, HWLOC_OBJ_NUMANODE);
|
m_nodes = std::max<size_t>(countByType(m_topology, HWLOC_OBJ_NUMANODE), 1);
|
||||||
m_packages = countByType(topology, HWLOC_OBJ_PACKAGE);
|
m_packages = countByType(m_topology, HWLOC_OBJ_PACKAGE);
|
||||||
|
}
|
||||||
|
|
||||||
hwloc_topology_destroy(topology);
|
|
||||||
|
xmrig::HwlocCpuInfo::~HwlocCpuInfo()
|
||||||
|
{
|
||||||
|
hwloc_topology_destroy(m_topology);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -131,10 +162,6 @@ xmrig::CpuThreads xmrig::HwlocCpuInfo::threads(const Algorithm &algorithm) const
|
||||||
return BasicCpuInfo::threads(algorithm);
|
return BasicCpuInfo::threads(algorithm);
|
||||||
}
|
}
|
||||||
|
|
||||||
hwloc_topology_t topology;
|
|
||||||
hwloc_topology_init(&topology);
|
|
||||||
hwloc_topology_load(topology);
|
|
||||||
|
|
||||||
const unsigned depth = L3() > 0 ? 3 : 2;
|
const unsigned depth = L3() > 0 ? 3 : 2;
|
||||||
|
|
||||||
CpuThreads threads;
|
CpuThreads threads;
|
||||||
|
@ -143,14 +170,12 @@ xmrig::CpuThreads xmrig::HwlocCpuInfo::threads(const Algorithm &algorithm) const
|
||||||
std::vector<hwloc_obj_t> caches;
|
std::vector<hwloc_obj_t> caches;
|
||||||
caches.reserve(16);
|
caches.reserve(16);
|
||||||
|
|
||||||
findCache(hwloc_get_root_obj(topology), depth, depth, [&caches](hwloc_obj_t found) { caches.emplace_back(found); });
|
findCache(hwloc_get_root_obj(m_topology), depth, depth, [&caches](hwloc_obj_t found) { caches.emplace_back(found); });
|
||||||
|
|
||||||
for (hwloc_obj_t cache : caches) {
|
for (hwloc_obj_t cache : caches) {
|
||||||
processTopLevelCache(cache, algorithm, threads);
|
processTopLevelCache(cache, algorithm, threads);
|
||||||
}
|
}
|
||||||
|
|
||||||
hwloc_topology_destroy(topology);
|
|
||||||
|
|
||||||
return threads;
|
return threads;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
|
|
||||||
typedef struct hwloc_obj *hwloc_obj_t;
|
typedef struct hwloc_obj *hwloc_obj_t;
|
||||||
|
typedef struct hwloc_topology *hwloc_topology_t;
|
||||||
|
|
||||||
|
|
||||||
namespace xmrig {
|
namespace xmrig {
|
||||||
|
@ -39,6 +40,7 @@ class HwlocCpuInfo : public BasicCpuInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
HwlocCpuInfo();
|
HwlocCpuInfo();
|
||||||
|
~HwlocCpuInfo() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CpuThreads threads(const Algorithm &algorithm) const override;
|
CpuThreads threads(const Algorithm &algorithm) const override;
|
||||||
|
@ -54,6 +56,7 @@ private:
|
||||||
void processTopLevelCache(hwloc_obj_t obj, const Algorithm &algorithm, CpuThreads &threads) const;
|
void processTopLevelCache(hwloc_obj_t obj, const Algorithm &algorithm, CpuThreads &threads) const;
|
||||||
|
|
||||||
char m_backend[20];
|
char m_backend[20];
|
||||||
|
hwloc_topology_t m_topology;
|
||||||
size_t m_cache[5];
|
size_t m_cache[5];
|
||||||
size_t m_cores = 0;
|
size_t m_cores = 0;
|
||||||
size_t m_nodes = 0;
|
size_t m_nodes = 0;
|
||||||
|
|
Loading…
Reference in a new issue