mirror of
https://github.com/xmrig/xmrig.git
synced 2024-12-22 19:49:36 +00:00
Fixed compatibility with hwloc 1.11.
This commit is contained in:
parent
0378aa8df4
commit
554b60966b
3 changed files with 31 additions and 19 deletions
|
@ -1,6 +1,6 @@
|
||||||
/* XMRig
|
/* XMRig
|
||||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
* Copyright (c) 2018-2023 SChernykh <https://github.com/SChernykh>
|
||||||
* Copyright (c) 2016-2021 XMRig <support@xmrig.com>
|
* Copyright (c) 2016-2023 XMRig <support@xmrig.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -36,27 +36,25 @@
|
||||||
#include "base/io/log/Log.h"
|
#include "base/io/log/Log.h"
|
||||||
|
|
||||||
|
|
||||||
|
#if HWLOC_API_VERSION < 0x20000
|
||||||
|
static inline int hwloc_obj_type_is_cache(hwloc_obj_type_t type)
|
||||||
|
{
|
||||||
|
return type == HWLOC_OBJ_CACHE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
namespace xmrig {
|
namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
uint32_t HwlocCpuInfo::m_features = 0;
|
uint32_t HwlocCpuInfo::m_features = 0;
|
||||||
|
|
||||||
|
|
||||||
static inline bool isCacheObject(hwloc_obj_t obj)
|
|
||||||
{
|
|
||||||
# if HWLOC_API_VERSION >= 0x20000
|
|
||||||
return hwloc_obj_type_is_cache(obj->type);
|
|
||||||
# else
|
|
||||||
return obj->type == HWLOC_OBJ_CACHE;
|
|
||||||
# endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template <typename func>
|
template <typename func>
|
||||||
static inline void findCache(hwloc_obj_t obj, unsigned min, unsigned max, func lambda)
|
static inline void findCache(hwloc_obj_t obj, unsigned min, unsigned max, func lambda)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < obj->arity; i++) {
|
for (size_t i = 0; i < obj->arity; i++) {
|
||||||
if (isCacheObject(obj->children[i])) {
|
if (hwloc_obj_type_is_cache(obj->children[i]->type)) {
|
||||||
const unsigned depth = obj->children[i]->attr->cache.depth;
|
const unsigned depth = obj->children[i]->attr->cache.depth;
|
||||||
if (depth < min || depth > max) {
|
if (depth < min || depth > max) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -322,7 +320,7 @@ void xmrig::HwlocCpuInfo::processTopLevelCache(hwloc_obj_t cache, const Algorith
|
||||||
if (cache->attr->cache.depth == 3) {
|
if (cache->attr->cache.depth == 3) {
|
||||||
for (size_t i = 0; i < cache->arity; ++i) {
|
for (size_t i = 0; i < cache->arity; ++i) {
|
||||||
hwloc_obj_t l2 = cache->children[i];
|
hwloc_obj_t l2 = cache->children[i];
|
||||||
if (!isCacheObject(l2) || l2->attr == nullptr) {
|
if (!hwloc_obj_type_is_cache(l2->type) || l2->attr == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* XMRig
|
/* XMRig
|
||||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
* Copyright (c) 2018-2023 SChernykh <https://github.com/SChernykh>
|
||||||
* Copyright (c) 2016-2021 XMRig <support@xmrig.com>
|
* Copyright (c) 2016-2023 XMRig <support@xmrig.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -47,9 +47,13 @@
|
||||||
#include <uv.h>
|
#include <uv.h>
|
||||||
|
|
||||||
#ifdef XMRIG_FEATURE_HWLOC
|
#ifdef XMRIG_FEATURE_HWLOC
|
||||||
#include "base/kernel/Platform.h"
|
# include "base/kernel/Platform.h"
|
||||||
#include "backend/cpu/platform/HwlocCpuInfo.h"
|
# include "backend/cpu/platform/HwlocCpuInfo.h"
|
||||||
#include <hwloc.h>
|
# include <hwloc.h>
|
||||||
|
|
||||||
|
# if HWLOC_API_VERSION < 0x20000
|
||||||
|
# define HWLOC_OBJ_L3CACHE HWLOC_OBJ_CACHE
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(XMRIG_ARM)
|
#if defined(XMRIG_ARM)
|
||||||
|
@ -487,6 +491,12 @@ HelperThread* create_helper_thread(int64_t cpu_index, int priority, const std::v
|
||||||
bool is8MB = false;
|
bool is8MB = false;
|
||||||
|
|
||||||
findByType(root, HWLOC_OBJ_L3CACHE, [cpu_index, &is8MB](hwloc_obj_t obj) {
|
findByType(root, HWLOC_OBJ_L3CACHE, [cpu_index, &is8MB](hwloc_obj_t obj) {
|
||||||
|
# if HWLOC_API_VERSION < 0x20000
|
||||||
|
if (obj->attr->cache.depth != 3) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
if (!hwloc_bitmap_isset(obj->cpuset, cpu_index)) {
|
if (!hwloc_bitmap_isset(obj->cpuset, cpu_index)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -510,7 +520,11 @@ HelperThread* create_helper_thread(int64_t cpu_index, int priority, const std::v
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
# if HWLOC_API_VERSION >= 0x20000
|
||||||
for (auto obj_type : { HWLOC_OBJ_CORE, HWLOC_OBJ_L1CACHE, HWLOC_OBJ_L2CACHE, HWLOC_OBJ_L3CACHE }) {
|
for (auto obj_type : { HWLOC_OBJ_CORE, HWLOC_OBJ_L1CACHE, HWLOC_OBJ_L2CACHE, HWLOC_OBJ_L3CACHE }) {
|
||||||
|
# else
|
||||||
|
for (auto obj_type : { HWLOC_OBJ_CORE, HWLOC_OBJ_CACHE }) {
|
||||||
|
# endif
|
||||||
findByType(root, obj_type, [cpu_index, helper_cpu_set, main_threads_set](hwloc_obj_t obj) {
|
findByType(root, obj_type, [cpu_index, helper_cpu_set, main_threads_set](hwloc_obj_t obj) {
|
||||||
const hwloc_cpuset_t& s = obj->cpuset;
|
const hwloc_cpuset_t& s = obj->cpuset;
|
||||||
if (hwloc_bitmap_isset(s, cpu_index)) {
|
if (hwloc_bitmap_isset(s, cpu_index)) {
|
||||||
|
|
Loading…
Reference in a new issue