From d8d24bb4c8064f6fd24fcb79c7af4106a0e6e4af Mon Sep 17 00:00:00 2001 From: psychocrypt Date: Fri, 29 Mar 2019 21:11:31 +0100 Subject: [PATCH 1/4] fix simple start Simple starts requires always user interactions if config.txt and pools.txt is not available. This PR asked the user only on the first advanced option if he/she preferse the simple start or an advanced mode. If all parameter are already defined via command line options than the question will never be shown. --- xmrstak/cli/cli-miner.cpp | 64 ++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 27 deletions(-) diff --git a/xmrstak/cli/cli-miner.cpp b/xmrstak/cli/cli-miner.cpp index a53a4ba9b..cc4b1b3d9 100644 --- a/xmrstak/cli/cli-miner.cpp +++ b/xmrstak/cli/cli-miner.cpp @@ -195,7 +195,14 @@ inline void prompt_once(bool& prompted) } } -void do_guided_pool_config(const bool use_simple_start) +inline bool use_simple_start() +{ + // ask this question only once + static bool simple_start = read_yes_no("\nUse simple setup method? (Y/n)", "Y"); + return simple_start; +} + +void do_guided_pool_config() { using namespace xmrstak; @@ -261,19 +268,22 @@ void do_guided_pool_config(const bool use_simple_start) } auto& rigid = params::inst().poolRigid; - if(!use_simple_start && rigid.empty() && !params::inst().userSetRigid) + if(rigid.empty() && !params::inst().userSetRigid) { - prompt_once(prompted); - - if(!stdin_flushed) + if(!use_simple_start()) { - // clear everything from stdin to allow an empty rigid - std::cin.clear(); - std::cin.ignore(INT_MAX, '\n'); - } + prompt_once(prompted); - std::cout << "- Rig identifier for pool-side statistics (needs pool support). Can be empty:" << std::endl; - getline(std::cin, rigid); + if(!stdin_flushed) + { + // clear everything from stdin to allow an empty rigid + std::cin.clear(); + std::cin.ignore(INT_MAX, '\n'); + } + + std::cout << "- Rig identifier for pool-side statistics (needs pool support). Can be empty:" << std::endl; + getline(std::cin, rigid); + } } bool tls = params::inst().poolUseTls; @@ -289,15 +299,19 @@ void do_guided_pool_config(const bool use_simple_start) #endif bool nicehash = params::inst().nicehashMode; - if(!use_simple_start && !userSetPool) + if(!userSetPool) { - prompt_once(prompted); - nicehash = read_yes_no("- Do you want to use nicehash on this pool? (y/N)", "N"); + if(!use_simple_start()) + { + prompt_once(prompted); + nicehash = read_yes_no("- Do you want to use nicehash on this pool? (y/N)", "N"); + } } bool multipool = false; - if(!use_simple_start && !userSetPool) - multipool = read_yes_no("- Do you want to use multiple pools? (y/N)", "N"); + if(!userSetPool) + if(!use_simple_start()) + multipool = read_yes_no("- Do you want to use multiple pools? (y/N)", "N"); int64_t pool_weight = 1; if(multipool) @@ -335,7 +349,7 @@ void do_guided_pool_config(const bool use_simple_start) std::cout << "Pool configuration stored in file '" << params::inst().configFilePools << "'" << std::endl; } -void do_guided_config(const bool use_simple_start) +void do_guided_config() { using namespace xmrstak; @@ -353,7 +367,7 @@ void do_guided_config(const bool use_simple_start) { http_port = params::httpd_port_disabled; #ifndef CONF_NO_HTTPD - if(!use_simple_start) + if(!use_simple_start()) { prompt_once(prompted); @@ -737,17 +751,13 @@ int main(int argc, char* argv[]) bool hasConfigFile = configEditor::file_exist(params::inst().configFile); bool hasPoolConfig = configEditor::file_exist(params::inst().configFilePools); - if(!hasConfigFile || !hasPoolConfig) - { - bool use_simple_start = read_yes_no("\nUse simple setup method? (Y/n)", "Y"); + // check if we need a guided start + if(!hasConfigFile) + do_guided_config(); - // check if we need a guided start - if(!hasConfigFile) - do_guided_config(use_simple_start); + if(!hasPoolConfig) + do_guided_pool_config(); - if(!hasPoolConfig) - do_guided_pool_config(use_simple_start); - } if(!jconf::inst()->parse_config(params::inst().configFile.c_str(), params::inst().configFilePools.c_str())) { win_exit(); From 50c7bb3627021b35d97a0caad752984490eb405d Mon Sep 17 00:00:00 2001 From: psychocrypt Date: Fri, 29 Mar 2019 23:43:20 +0100 Subject: [PATCH 2/4] avoid hash rate drop during dev pool mining Since the dev pool is sometimes using another POW than the user pool the hash date can strongly increase or decrease. In a case of a hash rate drop a monitoring software could trigger a wrong miner restart. - use the hash rate calculated during the user pool mining to interpulate the number of hashes during the dev pool mining so that the statistics stay constant. --- xmrstak/backend/amd/minethd.cpp | 6 +----- xmrstak/backend/cpu/minethd.cpp | 6 +++--- xmrstak/backend/iBackend.hpp | 24 ++++++++++++++++++++++++ xmrstak/backend/nvidia/minethd.cpp | 8 +------- 4 files changed, 29 insertions(+), 15 deletions(-) diff --git a/xmrstak/backend/amd/minethd.cpp b/xmrstak/backend/amd/minethd.cpp index 667144cdd..0a181154c 100644 --- a/xmrstak/backend/amd/minethd.cpp +++ b/xmrstak/backend/amd/minethd.cpp @@ -172,7 +172,6 @@ void minethd::work_main() lck.release(); std::this_thread::yield(); - uint64_t iCount = 0; cryptonight_ctx* cpu_ctx; cpu_ctx = cpu::minethd::minethd_alloc_ctx(); @@ -288,10 +287,7 @@ void minethd::work_main() executor::inst()->push_event(ex_event("AMD Invalid Result", pGpuCtx->deviceIdx, oWork.iPoolId)); } - iCount += pGpuCtx->rawIntensity; - uint64_t iStamp = get_timestamp_ms(); - iHashCount.store(iCount, std::memory_order_relaxed); - iTimestamp.store(iStamp, std::memory_order_relaxed); + updateStats(pGpuCtx->rawIntensity, oWork.iPoolId); accRuntime += updateTimings(pGpuCtx, t0); diff --git a/xmrstak/backend/cpu/minethd.cpp b/xmrstak/backend/cpu/minethd.cpp index 0229af0a7..463be1aab 100644 --- a/xmrstak/backend/cpu/minethd.cpp +++ b/xmrstak/backend/cpu/minethd.cpp @@ -833,6 +833,7 @@ void minethd::multiway_work_main() cryptonight_ctx* ctx[MAX_N]; uint64_t iCount = 0; + uint64_t iLastCount = 0; uint64_t* piHashVal[MAX_N]; uint32_t* piNonce[MAX_N]; uint8_t bHashOut[MAX_N * 32]; @@ -915,9 +916,8 @@ void minethd::multiway_work_main() { if((iCount++ & 0x7) == 0) //Store stats every 8*N hashes { - uint64_t iStamp = get_timestamp_ms(); - iHashCount.store(iCount * N, std::memory_order_relaxed); - iTimestamp.store(iStamp, std::memory_order_relaxed); + updateStats((iCount - iLastCount) * N, oWork.iPoolId); + iLastCount = iCount; } nonce_ctr -= N; diff --git a/xmrstak/backend/iBackend.hpp b/xmrstak/backend/iBackend.hpp index 1af42c248..dd59b6c52 100644 --- a/xmrstak/backend/iBackend.hpp +++ b/xmrstak/backend/iBackend.hpp @@ -1,6 +1,7 @@ #pragma once #include "xmrstak/backend/globalStates.hpp" +#include "xmrstak/net/msgstruct.hpp" #include #include @@ -46,6 +47,29 @@ struct iBackend std::atomic iTimestamp; uint32_t iThreadNo; BackendType backendType = UNKNOWN; + uint64_t iLastStamp = get_timestamp_ms(); + double avgHashPerMsec = 0.0; + + void updateStats(uint64_t numNewHashes, size_t poolId) + { + uint64_t iStamp = get_timestamp_ms(); + double timeDiff = static_cast(iStamp - iLastStamp); + iLastStamp = iStamp; + + if(poolId == 0) + { + // if dev pool is active interpolate the number of shares (avoid hash rate drops) + numNewHashes = static_cast(avgHashPerMsec * timeDiff); + } + else + { + const double hashRatePerMs = static_cast(numNewHashes) / timeDiff; + constexpr double averagingBias = 0.1; + avgHashPerMsec = avgHashPerMsec * (1.0 - averagingBias) + hashRatePerMs * averagingBias; + } + iHashCount.fetch_add(numNewHashes, std::memory_order_relaxed); + iTimestamp.store(iStamp, std::memory_order_relaxed); + } iBackend() : iHashCount(0), diff --git a/xmrstak/backend/nvidia/minethd.cpp b/xmrstak/backend/nvidia/minethd.cpp index 4506faed6..32b21dc71 100644 --- a/xmrstak/backend/nvidia/minethd.cpp +++ b/xmrstak/backend/nvidia/minethd.cpp @@ -198,7 +198,6 @@ void minethd::work_main() // wait until all NVIDIA devices are initialized thread_work_guard.wait(); - uint64_t iCount = 0; cryptonight_ctx* cpu_ctx; cpu_ctx = cpu::minethd::minethd_alloc_ctx(); @@ -297,13 +296,8 @@ void minethd::work_main() executor::inst()->push_event(ex_event("NVIDIA Invalid Result", ctx.device_id, oWork.iPoolId)); } - iCount += h_per_round; iNonce += h_per_round; - - using namespace std::chrono; - uint64_t iStamp = get_timestamp_ms(); - iHashCount.store(iCount, std::memory_order_relaxed); - iTimestamp.store(iStamp, std::memory_order_relaxed); + updateStats(h_per_round, oWork.iPoolId); std::this_thread::yield(); } From 38e7eb0c74ba631c340d64ad190732603dfb16d6 Mon Sep 17 00:00:00 2001 From: psychocrypt Date: Mon, 1 Apr 2019 21:59:02 +0200 Subject: [PATCH 3/4] fix cn_r block 1802223 bug fix nvrtc deadlock with `cuda version != 10.1`: https://github.com/xmrig/xmrig-nvidia/issues/260 --- xmrstak/backend/nvidia/nvcc_code/cuda_cryptonight_r.curt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xmrstak/backend/nvidia/nvcc_code/cuda_cryptonight_r.curt b/xmrstak/backend/nvidia/nvcc_code/cuda_cryptonight_r.curt index bcf495080..214114c7e 100644 --- a/xmrstak/backend/nvidia/nvcc_code/cuda_cryptonight_r.curt +++ b/xmrstak/backend/nvidia/nvcc_code/cuda_cryptonight_r.curt @@ -462,10 +462,10 @@ __global__ void CryptonightR_phase2( uint64_t bx0 = ((uint64_t*)(d_ctx_b + thread * 16))[sub]; uint64_t bx1 = ((uint64_t*)(d_ctx_b + thread * 16 + 4))[sub]; - uint32_t r0 = d_ctx_b[thread * 16 + 4 * 2]; - uint32_t r1 = d_ctx_b[thread * 16 + 4 * 2 + 1]; - uint32_t r2 = d_ctx_b[thread * 16 + 4 * 2 + 2]; - uint32_t r3 = d_ctx_b[thread * 16 + 4 * 2 + 3]; + volatile uint32_t r0 = d_ctx_b[thread * 16 + 4 * 2]; + volatile uint32_t r1 = d_ctx_b[thread * 16 + 4 * 2 + 1]; + volatile uint32_t r2 = d_ctx_b[thread * 16 + 4 * 2 + 2]; + volatile uint32_t r3 = d_ctx_b[thread * 16 + 4 * 2 + 3]; const int batchsize = (ITERATIONS * 2) >> ( 1 + bfactor ); const int start = partidx * batchsize; From 8e07b13963bee56fbad91e1920ddeb4fe9bf9475 Mon Sep 17 00:00:00 2001 From: psychocrypt Date: Mon, 1 Apr 2019 22:06:00 +0200 Subject: [PATCH 4/4] version increase to 2.10.4 --- xmrstak/version.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xmrstak/version.cpp b/xmrstak/version.cpp index d4afd7877..f42e2a0bf 100644 --- a/xmrstak/version.cpp +++ b/xmrstak/version.cpp @@ -20,7 +20,7 @@ #endif #define XMR_STAK_NAME "xmr-stak" -#define XMR_STAK_VERSION "2.10.3" +#define XMR_STAK_VERSION "2.10.4" #if defined(_WIN32) #define OS_TYPE "win"