diff --git a/src/backend/common/Workers.cpp b/src/backend/common/Workers.cpp index 6a369c1b5..036bc8b66 100644 --- a/src/backend/common/Workers.cpp +++ b/src/backend/common/Workers.cpp @@ -163,36 +163,16 @@ void xmrig::Workers::onReady(void *arg) namespace xmrig { -#if defined (XMRIG_ALGO_RANDOMX) || defined (XMRIG_ALGO_CN_GPU) -static void printIntensityWarning(Thread *handle) -{ - LOG_WARN("CPU thread %zu warning: \"intensity %d not supported for %s algorithm\".", handle->index(), handle->config().intensity, handle->config().algorithm.shortName()); -} -#endif - - template<> xmrig::IWorker *xmrig::Workers::create(Thread *handle) { const int intensity = handle->config().intensity; -# if defined (XMRIG_ALGO_RANDOMX) || defined (XMRIG_ALGO_CN_GPU) - if (intensity > 1) { -# ifdef XMRIG_ALGO_RANDOMX - if (handle->config().algorithm.family() == Algorithm::RANDOM_X) { - printIntensityWarning(handle); +# if defined(XMRIG_ALGO_RANDOMX) || defined(XMRIG_ALGO_CN_GPU) + if (intensity > handle->config().algorithm.maxIntensity()) { + LOG_WARN("CPU thread %zu warning: \"intensity %d not supported for %s algorithm\".", handle->index(), handle->config().intensity, handle->config().algorithm.shortName()); - return new CpuWorker<1>(handle->index(), handle->config()); - } -# endif - -# ifdef XMRIG_ALGO_CN_GPU - if (handle->config().algorithm == Algorithm::CN_GPU) { - printIntensityWarning(handle); - - return new CpuWorker<1>(handle->index(), handle->config()); - } -# endif + return new CpuWorker<1>(handle->index(), handle->config()); } # endif diff --git a/src/crypto/common/Algorithm.cpp b/src/crypto/common/Algorithm.cpp index c7990052a..f0670b266 100644 --- a/src/crypto/common/Algorithm.cpp +++ b/src/crypto/common/Algorithm.cpp @@ -120,6 +120,24 @@ static AlgoName const algorithm_names[] = { } /* namespace xmrig */ +int xmrig::Algorithm::maxIntensity() const +{ +# ifdef XMRIG_ALGO_RANDOMX + if (family() == RANDOM_X) { + return 1; + } +# endif + +# ifdef XMRIG_ALGO_CN_GPU + if (m_id == CN_GPU) { + return 1; + } +# endif + + return 5; +} + + rapidjson::Value xmrig::Algorithm::toJSON() const { using namespace rapidjson; diff --git a/src/crypto/common/Algorithm.h b/src/crypto/common/Algorithm.h index b30a946bd..0b817bde2 100644 --- a/src/crypto/common/Algorithm.h +++ b/src/crypto/common/Algorithm.h @@ -102,6 +102,7 @@ public: inline bool operator==(const Algorithm &other) const { return isEqual(other); } inline operator Algorithm::Id() const { return m_id; } + int maxIntensity() const; rapidjson::Value toJSON() const; size_t memory() const;