1
0
mirror of https://github.com/xmrig/xmrig.git synced 2025-12-24 13:32:46 -05:00
This commit is contained in:
Tony Butler
2024-11-03 18:25:44 +01:00
committed by GitHub
5 changed files with 45 additions and 16 deletions

View File

@@ -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
@@ -126,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

View File

@@ -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
}

View File

@@ -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; }