From 1fbd6f6b168ea66da38b3518b830a08e3af79e26 Mon Sep 17 00:00:00 2001 From: psychocrypt Date: Thu, 28 Sep 2017 20:45:19 +0200 Subject: [PATCH] use runtime enable/disable flag for backends --- backend/BackendConnector.cpp | 38 +++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/backend/BackendConnector.cpp b/backend/BackendConnector.cpp index 0ef69f1..1013f79 100644 --- a/backend/BackendConnector.cpp +++ b/backend/BackendConnector.cpp @@ -45,6 +45,7 @@ #include "Plugin.hpp" #include "../Environment.hpp" #include "../console.h" +#include "../Params.hpp" namespace xmrstak { @@ -65,26 +66,35 @@ std::vector* BackendConnector::thread_starter(miner_work& pWork) std::vector* pvThreads = new std::vector; #ifndef CONF_NO_CUDA - Plugin nvidiaPlugin("NVIDIA", "xmrstak_cuda_backend"); - std::vector* nvidiaThreads = nvidiaPlugin.startBackend(static_cast(pvThreads->size()), pWork, Environment::inst()); - pvThreads->insert(std::end(*pvThreads), std::begin(*nvidiaThreads), std::end(*nvidiaThreads)); - if(nvidiaThreads->size() == 0) - printer::inst()->print_msg(L0, "WARNING: backend NVIDIA disabled."); + if(Params::inst().useNVIDIA) + { + Plugin nvidiaPlugin("NVIDIA", "xmrstak_cuda_backend"); + std::vector* nvidiaThreads = nvidiaPlugin.startBackend(static_cast(pvThreads->size()), pWork, Environment::inst()); + pvThreads->insert(std::end(*pvThreads), std::begin(*nvidiaThreads), std::end(*nvidiaThreads)); + if(nvidiaThreads->size() == 0) + printer::inst()->print_msg(L0, "WARNING: backend NVIDIA disabled."); + } #endif #ifndef CONF_NO_OPENCL - Plugin amdPlugin("AMD", "xmrstak_opencl_backend"); - std::vector* amdThreads = amdPlugin.startBackend(static_cast(pvThreads->size()), pWork, Environment::inst()); - pvThreads->insert(std::end(*pvThreads), std::begin(*amdThreads), std::end(*amdThreads)); - if(amdThreads->size() == 0) - printer::inst()->print_msg(L0, "WARNING: backend AMD disabled."); + if(Params::inst().useAMD) + { + Plugin amdPlugin("AMD", "xmrstak_opencl_backend"); + std::vector* amdThreads = amdPlugin.startBackend(static_cast(pvThreads->size()), pWork, Environment::inst()); + pvThreads->insert(std::end(*pvThreads), std::begin(*amdThreads), std::end(*amdThreads)); + if(amdThreads->size() == 0) + printer::inst()->print_msg(L0, "WARNING: backend AMD disabled."); + } #endif #ifndef CONF_NO_CPU - auto cpuThreads = cpu::minethd::thread_starter(static_cast(pvThreads->size()), pWork); - pvThreads->insert(std::end(*pvThreads), std::begin(cpuThreads), std::end(cpuThreads)); - if(cpuThreads.size() == 0) - printer::inst()->print_msg(L0, "WARNING: backend CPU disabled."); + if(Params::inst().useCPU) + { + auto cpuThreads = cpu::minethd::thread_starter(static_cast(pvThreads->size()), pWork); + pvThreads->insert(std::end(*pvThreads), std::begin(cpuThreads), std::end(cpuThreads)); + if(cpuThreads.size() == 0) + printer::inst()->print_msg(L0, "WARNING: backend CPU disabled."); + } #endif GlobalStates::inst().iThreadCount = pvThreads->size();