Fixed thread limit
This commit is contained in:
parent
57e38f070a
commit
822dfe5aef
1 changed files with 14 additions and 11 deletions
|
@ -222,9 +222,12 @@ const char *xmrig::BasicCpuInfo::backend() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
xmrig::CpuThreads xmrig::BasicCpuInfo::threads(const Algorithm &algorithm, uint32_t) const
|
xmrig::CpuThreads xmrig::BasicCpuInfo::threads(const Algorithm &algorithm, uint32_t limit) const
|
||||||
{
|
{
|
||||||
const size_t count = std::thread::hardware_concurrency();
|
const uint32_t count = std::thread::hardware_concurrency();
|
||||||
|
const uint32_t count_limit = std::max(static_cast<uint32_t>(count * (limit / 100.0f)), 1U);
|
||||||
|
const uint32_t count_limit2 = std::max(count_limit / 2, 1U);
|
||||||
|
const uint32_t count_limit4 = std::max(count_limit / 4, 1U);
|
||||||
|
|
||||||
if (count == 1) {
|
if (count == 1) {
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -232,42 +235,42 @@ xmrig::CpuThreads xmrig::BasicCpuInfo::threads(const Algorithm &algorithm, uint3
|
||||||
|
|
||||||
# ifdef XMRIG_ALGO_CN_LITE
|
# ifdef XMRIG_ALGO_CN_LITE
|
||||||
if (algorithm.family() == Algorithm::CN_LITE) {
|
if (algorithm.family() == Algorithm::CN_LITE) {
|
||||||
return CpuThreads(count, 1);
|
return CpuThreads(count_limit, 1);
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifdef XMRIG_ALGO_CN_PICO
|
# ifdef XMRIG_ALGO_CN_PICO
|
||||||
if (algorithm.family() == Algorithm::CN_PICO) {
|
if (algorithm.family() == Algorithm::CN_PICO) {
|
||||||
return CpuThreads(count, 2);
|
return CpuThreads(count_limit, 2);
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifdef XMRIG_ALGO_CN_HEAVY
|
# ifdef XMRIG_ALGO_CN_HEAVY
|
||||||
if (algorithm.family() == Algorithm::CN_HEAVY) {
|
if (algorithm.family() == Algorithm::CN_HEAVY) {
|
||||||
return CpuThreads(std::max<size_t>(count / 4, 1), 1);
|
return CpuThreads(count_limit4, 1);
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifdef XMRIG_ALGO_RANDOMX
|
# ifdef XMRIG_ALGO_RANDOMX
|
||||||
if (algorithm.family() == Algorithm::RANDOM_X) {
|
if (algorithm.family() == Algorithm::RANDOM_X) {
|
||||||
if (algorithm == Algorithm::RX_WOW) {
|
if (algorithm == Algorithm::RX_WOW) {
|
||||||
return count;
|
return count_limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::max<size_t>(count / 2, 1);
|
return count_limit2;
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifdef XMRIG_ALGO_ARGON2
|
# ifdef XMRIG_ALGO_ARGON2
|
||||||
if (algorithm.family() == Algorithm::ARGON2) {
|
if (algorithm.family() == Algorithm::ARGON2) {
|
||||||
return count;
|
return count_limit;
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifdef XMRIG_ALGO_ASTROBWT
|
# ifdef XMRIG_ALGO_ASTROBWT
|
||||||
if (algorithm.family() == Algorithm::ASTROBWT) {
|
if (algorithm.family() == Algorithm::ASTROBWT) {
|
||||||
CpuThreads threads;
|
CpuThreads threads;
|
||||||
for (size_t i = 0; i < count; ++i) {
|
for (size_t i = 0; i < count_limit; ++i) {
|
||||||
threads.add(i, 0);
|
threads.add(i, 0);
|
||||||
}
|
}
|
||||||
return threads;
|
return threads;
|
||||||
|
@ -276,11 +279,11 @@ xmrig::CpuThreads xmrig::BasicCpuInfo::threads(const Algorithm &algorithm, uint3
|
||||||
|
|
||||||
# ifdef XMRIG_ALGO_CN_GPU
|
# ifdef XMRIG_ALGO_CN_GPU
|
||||||
if (algorithm == Algorithm::CN_GPU) {
|
if (algorithm == Algorithm::CN_GPU) {
|
||||||
return count;
|
return count_limit;
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
return CpuThreads(std::max<size_t>(count / 2, 1), 1);
|
return CpuThreads(count_limit2, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue