Disallow direct use of HwlocCpuInfo class.

This commit is contained in:
XMRig 2023-06-07 00:32:09 +07:00
parent a2ae17b4c4
commit c7e541d84f
No known key found for this signature in database
GPG key ID: 446A53638BE94409
11 changed files with 61 additions and 85 deletions

View file

@ -1,7 +1,7 @@
/* XMRig
* Copyright (c) 2017-2019 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 XMRig <support@xmrig.com>
* Copyright (c) 2018-2023 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2023 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
@ -72,11 +72,10 @@ protected:
# endif
}
protected:
Arch m_arch = ARCH_UNKNOWN;
bool m_jccErratum = false;
char m_brand[64 + 6]{};
size_t m_threads;
size_t m_threads = 0;
std::vector<int32_t> m_units;
Vendor m_vendor = VENDOR_UNKNOWN;
@ -94,7 +93,7 @@ private:
};
} /* namespace xmrig */
} // namespace xmrig
#endif /* XMRIG_BASICCPUINFO_H */
#endif // XMRIG_BASICCPUINFO_H

View file

@ -47,9 +47,6 @@ static inline int hwloc_obj_type_is_cache(hwloc_obj_type_t type)
namespace xmrig {
uint32_t HwlocCpuInfo::m_features = 0;
template <typename func>
static inline void findCache(hwloc_obj_t obj, unsigned min, unsigned max, func lambda)
{
@ -172,10 +169,6 @@ xmrig::HwlocCpuInfo::HwlocCpuInfo()
m_packages = countByType(m_topology, HWLOC_OBJ_PACKAGE);
if (m_nodes > 1) {
if (hwloc_topology_get_support(m_topology)->membind->set_thisthread_membind) {
m_features |= SET_THISTHREAD_MEMBIND;
}
m_nodeset.reserve(m_nodes);
hwloc_obj_t node = nullptr;

View file

@ -21,12 +21,9 @@
#include "backend/cpu/platform/BasicCpuInfo.h"
#include "base/tools/Object.h"
using hwloc_const_bitmap_t = const struct hwloc_bitmap_s *;
using hwloc_obj_t = struct hwloc_obj *;
using hwloc_topology_t = struct hwloc_topology *;
using hwloc_obj_t = struct hwloc_obj *;
namespace xmrig {
@ -37,39 +34,27 @@ class HwlocCpuInfo : public BasicCpuInfo
public:
XMRIG_DISABLE_COPY_MOVE(HwlocCpuInfo)
enum Feature : uint32_t {
SET_THISTHREAD_MEMBIND = 1
};
HwlocCpuInfo();
~HwlocCpuInfo() override;
static inline bool hasFeature(Feature feature) { return m_features & feature; }
inline const std::vector<uint32_t> &nodeset() const { return m_nodeset; }
inline hwloc_topology_t topology() const { return m_topology; }
bool membind(hwloc_const_bitmap_t nodeset);
protected:
bool 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; }
inline size_t cores() const override { return m_cores; }
inline size_t L2() const override { return m_cache[2]; }
inline size_t L3() const override { return m_cache[3]; }
inline size_t nodes() const override { return m_nodes; }
inline size_t packages() const override { return m_packages; }
inline const char *backend() const override { return m_backend; }
inline const std::vector<uint32_t> &nodeset() const override { return m_nodeset; }
inline hwloc_topology_t topology() const override { return m_topology; }
inline size_t cores() const override { return m_cores; }
inline size_t L2() const override { return m_cache[2]; }
inline size_t L3() const override { return m_cache[3]; }
inline size_t nodes() const override { return m_nodes; }
inline size_t packages() const override { return m_packages; }
private:
CpuThreads allThreads(const Algorithm &algorithm, uint32_t limit) const;
void processTopLevelCache(hwloc_obj_t cache, const Algorithm &algorithm, CpuThreads &threads, size_t limit) const;
void setThreads(size_t threads);
static uint32_t m_features;
char m_backend[20] = { 0 };
hwloc_topology_t m_topology = nullptr;
size_t m_cache[5] = { 0 };
@ -80,7 +65,7 @@ private:
};
} /* namespace xmrig */
} // namespace xmrig
#endif /* XMRIG_HWLOCCPUINFO_H */
#endif // XMRIG_HWLOCCPUINFO_H