diff options
Diffstat (limited to 'xmrstak/backend/nvidia')
-rw-r--r-- | xmrstak/backend/nvidia/autoAdjust.hpp | 95 | ||||
-rw-r--r-- | xmrstak/backend/nvidia/minethd.cpp | 21 | ||||
-rw-r--r-- | xmrstak/backend/nvidia/minethd.hpp | 2 | ||||
-rw-r--r-- | xmrstak/backend/nvidia/nvcc_code/cryptonight.hpp | 2 |
4 files changed, 60 insertions, 60 deletions
diff --git a/xmrstak/backend/nvidia/autoAdjust.hpp b/xmrstak/backend/nvidia/autoAdjust.hpp index d36a46a..c6a7dca 100644 --- a/xmrstak/backend/nvidia/autoAdjust.hpp +++ b/xmrstak/backend/nvidia/autoAdjust.hpp @@ -24,58 +24,57 @@ class autoAdjust { public: - autoAdjust() - { - - } - - /** print the adjusted values if needed - * - * Routine exit the application and print the adjusted values if needed else - * nothing is happened. - */ - bool printConfig() - { + autoAdjust() + { + + } + + /** print the adjusted values if needed + * + * Routine exit the application and print the adjusted values if needed else + * nothing is happened. + */ + bool printConfig() + { int deviceCount = 0; - if(cuda_get_devicecount(&deviceCount) == 0) - return false; - // evaluate config parameter for if auto adjustment is needed - // evaluate config parameter for if auto adjustment is needed - for(int i = 0; i < deviceCount; i++) - { - - nvid_ctx ctx; - - ctx.device_id = i; - // -1 trigger auto adjustment - ctx.device_blocks = -1; - ctx.device_threads = -1; - - // set all evice option those marked as auto (-1) to a valid value + if(cuda_get_devicecount(&deviceCount) == 0) + return false; + // evaluate config parameter for if auto adjustment is needed + for(int i = 0; i < deviceCount; i++) + { + + nvid_ctx ctx; + + ctx.device_id = i; + // -1 trigger auto adjustment + ctx.device_blocks = -1; + ctx.device_threads = -1; + + // set all evice option those marked as auto (-1) to a valid value #ifndef _WIN32 - ctx.device_bfactor = 0; - ctx.device_bsleep = 0; + ctx.device_bfactor = 0; + ctx.device_bsleep = 0; #else - // windows pass, try to avoid that windows kills the miner if the gpu is blocked for 2 seconds - ctx.device_bfactor = 6; - ctx.device_bsleep = 25; + // windows pass, try to avoid that windows kills the miner if the gpu is blocked for 2 seconds + ctx.device_bfactor = 6; + ctx.device_bsleep = 25; #endif - if(cuda_get_deviceinfo(&ctx) == 0) - nvidCtxVec.push_back(ctx); - else - printer::inst()->print_msg(L0, "WARNING: NVIDIA setup failed for GPU %d.\n", i); + if(cuda_get_deviceinfo(&ctx) == 0) + nvidCtxVec.push_back(ctx); + else + printer::inst()->print_msg(L0, "WARNING: NVIDIA setup failed for GPU %d.\n", i); - } + } - generateThreadConfig(); - return true; + generateThreadConfig(); + return true; - } + } private: - - void generateThreadConfig() - { + + void generateThreadConfig() + { // load the template of the backend config into a char variable const char *tpl = #include "./config.tpl" @@ -86,8 +85,8 @@ private: constexpr size_t byte2mib = 1024u * 1024u; std::string conf; - for(auto& ctx : nvidCtxVec) - { + for(auto& ctx : nvidCtxVec) + { if(ctx.device_threads * ctx.device_blocks > 0) { conf += std::string(" // gpu: ") + ctx.name + " architecture: " + std::to_string(ctx.device_arch[0] * 10 + ctx.device_arch[1]) + "\n"; @@ -99,14 +98,14 @@ private: " \"affine_to_cpu\" : false,\n" + " },\n"; } - } + } configTpl.replace("GPUCONFIG",conf); configTpl.write(params::inst().configFileNVIDIA); printer::inst()->print_msg(L0, "NVIDIA: GPU configuration stored in file '%s'", params::inst().configFileNVIDIA.c_str()); - } + } - std::vector<nvid_ctx> nvidCtxVec; + std::vector<nvid_ctx> nvidCtxVec; }; } // namespace nvidia diff --git a/xmrstak/backend/nvidia/minethd.cpp b/xmrstak/backend/nvidia/minethd.cpp index 9dbd83e..9eab1c0 100644 --- a/xmrstak/backend/nvidia/minethd.cpp +++ b/xmrstak/backend/nvidia/minethd.cpp @@ -59,11 +59,11 @@ namespace nvidia { #ifdef WIN32 - HINSTANCE lib_handle; + HINSTANCE lib_handle; #else - void *lib_handle; + void *lib_handle; #endif - + minethd::minethd(miner_work& pWork, size_t iNo, const jconf::thd_cfg& cfg) { this->backendType = iBackend::NVIDIA; @@ -81,7 +81,7 @@ minethd::minethd(miner_work& pWork, size_t iNo, const jconf::thd_cfg& cfg) std::unique_lock<std::mutex> lck(thd_aff_set); std::future<void> order_guard = order_fix.get_future(); - + oWorkThd = std::thread(&minethd::work_main, this); order_guard.wait(); @@ -113,7 +113,7 @@ bool minethd::self_test() //if(!bResult) // printer::inst()->print_msg(L0, - // "Cryptonight hash self-test failed. This might be caused by bad compiler optimizations."); + // "Cryptonight hash self-test failed. This might be caused by bad compiler optimizations."); return bResult; } @@ -211,7 +211,7 @@ void minethd::work_main() std::unique_lock<std::mutex> lck(thd_aff_set); lck.release(); std::this_thread::yield(); - + uint64_t iCount = 0; cryptonight_ctx* cpu_ctx; cpu_ctx = cpu::minethd::minethd_alloc_ctx(); @@ -227,14 +227,15 @@ void minethd::work_main() } bool mineMonero = strcmp_i(::jconf::inst()->GetCurrency(), "monero"); - + while (bQuit == 0) { if (oWork.bStall) { - /* We are stalled here because the executor didn't find a job for us yet, - either because of network latency, or a socket problem. Since we are - raison d'etre of this software it us sensible to just wait until we have something*/ + /* We are stalled here because the executor didn't find a job for us yet, + * either because of network latency, or a socket problem. Since we are + * raison d'etre of this software it us sensible to just wait until we have something + */ while (globalStates::inst().iGlobalJobNo.load(std::memory_order_relaxed) == iJobNo) std::this_thread::sleep_for(std::chrono::milliseconds(100)); diff --git a/xmrstak/backend/nvidia/minethd.hpp b/xmrstak/backend/nvidia/minethd.hpp index ffcdab1..d13c868 100644 --- a/xmrstak/backend/nvidia/minethd.hpp +++ b/xmrstak/backend/nvidia/minethd.hpp @@ -30,7 +30,7 @@ public: private: typedef void (*cn_hash_fun)(const void*, size_t, void*, cryptonight_ctx*); - + minethd(miner_work& pWork, size_t iNo, const jconf::thd_cfg& cfg); void work_main(); diff --git a/xmrstak/backend/nvidia/nvcc_code/cryptonight.hpp b/xmrstak/backend/nvidia/nvcc_code/cryptonight.hpp index 0cfdaac..1b63379 100644 --- a/xmrstak/backend/nvidia/nvcc_code/cryptonight.hpp +++ b/xmrstak/backend/nvidia/nvcc_code/cryptonight.hpp @@ -12,7 +12,7 @@ typedef struct { int device_threads; int device_bfactor; int device_bsleep; - + uint32_t *d_input; uint32_t inputlen; uint32_t *d_result_count; |