Added class CpuThreads.

This commit is contained in:
XMRig 2019-08-07 16:13:23 +07:00
parent 0adab95ce4
commit 96fd7545d1
12 changed files with 160 additions and 58 deletions

View file

@ -182,23 +182,25 @@ const char *xmrig::BasicCpuInfo::backend() const
xmrig::CpuThreads xmrig::BasicCpuInfo::threads(const Algorithm &algorithm) const
{
if (threads() == 1) {
return CpuThreads(1);
const size_t count = std::thread::hardware_concurrency();
if (count == 1) {
return 1;
}
# ifdef XMRIG_ALGO_CN_GPU
if (algorithm == Algorithm::CN_GPU) {
return CpuThreads(threads());
return count;
}
# endif
if (algorithm.family() == Algorithm::CN_LITE || algorithm.family() == Algorithm::CN_PICO) {
return CpuThreads(threads());
return count;
}
if (algorithm.family() == Algorithm::CN_HEAVY) {
return CpuThreads(std::max<size_t>(threads() / 4, 1));
return std::max<size_t>(count / 4, 1);
}
return CpuThreads(std::max<size_t>(threads() / 2, 1));
return std::max<size_t>(count / 2, 1);
}

View file

@ -222,7 +222,7 @@ xmrig::CpuThreads xmrig::HwlocCpuInfo::threads(const Algorithm &algorithm) const
processTopLevelCache(cache, algorithm, threads);
}
if (threads.empty()) {
if (threads.isEmpty()) {
LOG_WARN("hwloc auto configuration for algorithm \"%s\" failed.", algorithm.shortName());
return BasicCpuInfo::threads(algorithm);
@ -286,7 +286,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.push_back(CpuThread(1, pu->os_index));
threads.add(pu->os_index);
}
}
@ -307,7 +307,7 @@ void xmrig::HwlocCpuInfo::processTopLevelCache(hwloc_obj_t cache, const Algorith
PUs--;
allocated_pu = true;
threads.push_back(CpuThread(1, units[pu_id]->os_index));
threads.add(units[pu_id]->os_index);
if (cacheHashes == 0) {
break;