Changed CPU threads format.
This commit is contained in:
parent
fd9039928b
commit
97192f224d
6 changed files with 68 additions and 52 deletions
|
@ -147,31 +147,32 @@ void xmrig::CpuConfig::read(const rapidjson::Value &value)
|
|||
|
||||
void xmrig::CpuConfig::generate()
|
||||
{
|
||||
m_shouldSave = true;
|
||||
m_shouldSave = true;
|
||||
ICpuInfo *cpu = Cpu::info();
|
||||
|
||||
m_threads.disable(Algorithm::CN_0);
|
||||
m_threads.move(kCn, Cpu::info()->threads(Algorithm::CN_0));
|
||||
m_threads.move(kCn, cpu->threads(Algorithm::CN_0));
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_GPU
|
||||
m_threads.move(kCnGPU, Cpu::info()->threads(Algorithm::CN_GPU));
|
||||
m_threads.move(kCnGPU, cpu->threads(Algorithm::CN_GPU));
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_LITE
|
||||
m_threads.disable(Algorithm::CN_LITE_0);
|
||||
m_threads.move(kCnLite, Cpu::info()->threads(Algorithm::CN_LITE_1));
|
||||
m_threads.move(kCnLite, cpu->threads(Algorithm::CN_LITE_1));
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_HEAVY
|
||||
m_threads.move(kCnHeavy, Cpu::info()->threads(Algorithm::CN_HEAVY_0));
|
||||
m_threads.move(kCnHeavy, cpu->threads(Algorithm::CN_HEAVY_0));
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_PICO
|
||||
m_threads.move(kCnPico, Cpu::info()->threads(Algorithm::CN_PICO_0));
|
||||
m_threads.move(kCnPico, cpu->threads(Algorithm::CN_PICO_0));
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_RANDOMX
|
||||
m_threads.move(kRx, Cpu::info()->threads(Algorithm::RX_0));
|
||||
m_threads.move(kRxWOW, Cpu::info()->threads(Algorithm::RX_WOW));
|
||||
m_threads.move(kRx, cpu->threads(Algorithm::RX_0));
|
||||
m_threads.move(kRxWOW, cpu->threads(Algorithm::RX_WOW));
|
||||
# endif
|
||||
}
|
||||
|
||||
|
|
|
@ -28,25 +28,14 @@
|
|||
#include "rapidjson/document.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
static const char *kAffinity = "affinity";
|
||||
static const char *kIntensity = "intensity";
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
xmrig::CpuThread::CpuThread(const rapidjson::Value &value)
|
||||
{
|
||||
if (value.IsObject()) {
|
||||
m_intensity = Json::getInt(value, kIntensity, -1);
|
||||
m_affinity = Json::getInt(value, kAffinity, -1);
|
||||
if (value.IsArray() && value.Size() >= 2) {
|
||||
m_intensity = value[0].GetInt();
|
||||
m_affinity = value[1].GetInt();
|
||||
}
|
||||
else if (value.IsInt()) {
|
||||
m_intensity = 1;
|
||||
m_intensity = -1;
|
||||
m_affinity = value.GetInt();
|
||||
}
|
||||
}
|
||||
|
@ -55,17 +44,15 @@ xmrig::CpuThread::CpuThread(const rapidjson::Value &value)
|
|||
rapidjson::Value xmrig::CpuThread::toJSON(rapidjson::Document &doc) const
|
||||
{
|
||||
using namespace rapidjson;
|
||||
|
||||
if (intensity() > 1) {
|
||||
auto &allocator = doc.GetAllocator();
|
||||
|
||||
Value obj(kObjectType);
|
||||
|
||||
obj.AddMember(StringRef(kIntensity), m_intensity, allocator);
|
||||
obj.AddMember(StringRef(kAffinity), m_affinity, allocator);
|
||||
|
||||
return obj;
|
||||
if (m_intensity == -1) {
|
||||
return Value(m_affinity);
|
||||
}
|
||||
|
||||
return Value(m_affinity);
|
||||
auto &allocator = doc.GetAllocator();
|
||||
|
||||
Value out(kArrayType);
|
||||
out.PushBack(m_intensity, allocator);
|
||||
out.PushBack(m_affinity, allocator);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
|
|
@ -35,13 +35,14 @@ namespace xmrig {
|
|||
class CpuThread
|
||||
{
|
||||
public:
|
||||
inline constexpr CpuThread(int intensity = 1, int64_t affinity = -1) : m_intensity(intensity), m_affinity(affinity) {}
|
||||
inline constexpr CpuThread() {}
|
||||
inline constexpr CpuThread(int64_t affinity, int intensity) : m_intensity(intensity), m_affinity(affinity) {}
|
||||
|
||||
CpuThread(const rapidjson::Value &value);
|
||||
|
||||
inline bool isEqual(const CpuThread &other) const { return other.m_affinity == m_affinity && other.m_intensity == m_intensity; }
|
||||
inline bool isValid() const { return m_intensity >= 1 && m_intensity <= 5; }
|
||||
inline int intensity() const { return m_intensity; }
|
||||
inline bool isValid() const { return m_intensity == -1 || (m_intensity >= 1 && m_intensity <= 5); }
|
||||
inline int intensity() const { return m_intensity == -1 ? 1 : m_intensity; }
|
||||
inline int64_t affinity() const { return m_affinity; }
|
||||
|
||||
inline bool operator!=(const CpuThread &other) const { return !isEqual(other); }
|
||||
|
|
|
@ -47,7 +47,7 @@ public:
|
|||
inline const std::vector<CpuThread> &data() const { return m_data; }
|
||||
inline size_t count() const { return m_data.size(); }
|
||||
inline void add(CpuThread &&thread) { m_data.push_back(thread); }
|
||||
inline void add(int64_t affinity, int intensity = 1) { add(CpuThread(intensity, affinity)); }
|
||||
inline void add(int64_t affinity, int intensity) { add(CpuThread(affinity, intensity)); }
|
||||
inline void reserve(size_t capacity) { m_data.reserve(capacity); }
|
||||
|
||||
rapidjson::Value toJSON(rapidjson::Document &doc) const;
|
||||
|
|
|
@ -250,6 +250,7 @@ void xmrig::HwlocCpuInfo::processTopLevelCache(hwloc_obj_t cache, const Algorith
|
|||
int L2_associativity = 0;
|
||||
size_t extra = 0;
|
||||
const size_t scratchpad = algorithm.memory();
|
||||
int intensity = algorithm.maxIntensity() == 1 ? -1 : 1;
|
||||
|
||||
if (cache->attr->cache.depth == 3 && isCacheExclusive(cache)) {
|
||||
for (size_t i = 0; i < cache->arity; ++i) {
|
||||
|
@ -286,7 +287,7 @@ void xmrig::HwlocCpuInfo::processTopLevelCache(hwloc_obj_t cache, const Algorith
|
|||
for (hwloc_obj_t core : cores) {
|
||||
const std::vector<hwloc_obj_t> units = findByType(core, HWLOC_OBJ_PU);
|
||||
for (hwloc_obj_t pu : units) {
|
||||
threads.add(pu->os_index);
|
||||
threads.add(pu->os_index, intensity);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -307,7 +308,7 @@ void xmrig::HwlocCpuInfo::processTopLevelCache(hwloc_obj_t cache, const Algorith
|
|||
PUs--;
|
||||
|
||||
allocated_pu = true;
|
||||
threads.add(units[pu_id]->os_index);
|
||||
threads.add(units[pu_id]->os_index, intensity);
|
||||
|
||||
if (cacheHashes == 0) {
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue