diff options
author | psychocrypt <psychocryptHPC@gmail.com> | 2018-04-08 20:40:54 +0200 |
---|---|---|
committer | psychocrypt <psychocryptHPC@gmail.com> | 2018-04-08 20:52:30 +0200 |
commit | 1b18f598aa1190a0e6126ed2c70e052e9403d180 (patch) | |
tree | 626314a2add2f76649ca31c4b7e0a731f6d80f9b /xmrstak/backend/cpu | |
parent | a57976439b1322eecb5e29198f3d9676d6f06909 (diff) | |
download | xmr-stak-1b18f598aa1190a0e6126ed2c70e052e9403d180.zip xmr-stak-1b18f598aa1190a0e6126ed2c70e052e9403d180.tar.gz |
refactor scratchpad creation
Use the maximum scratchpad size from before and after the fork.
Diffstat (limited to 'xmrstak/backend/cpu')
-rw-r--r-- | xmrstak/backend/cpu/autoAdjust.hpp | 5 | ||||
-rw-r--r-- | xmrstak/backend/cpu/autoAdjustHwloc.hpp | 5 | ||||
-rw-r--r-- | xmrstak/backend/cpu/crypto/cryptonight_common.cpp | 11 |
3 files changed, 17 insertions, 4 deletions
diff --git a/xmrstak/backend/cpu/autoAdjust.hpp b/xmrstak/backend/cpu/autoAdjust.hpp index abba8b6..ed96d8b 100644 --- a/xmrstak/backend/cpu/autoAdjust.hpp +++ b/xmrstak/backend/cpu/autoAdjust.hpp @@ -36,7 +36,10 @@ public: bool printConfig() { - const size_t hashMemSizeKB = cn_select_memory(::jconf::inst()->GetMiningAlgo()) / 1024u; + const size_t hashMemSizeKB = std::max( + cn_select_memory(::jconf::inst()->GetMiningAlgo()), + cn_select_memory(::jconf::inst()->GetMiningAlgoRoot()) + ) / 1024u; const size_t halfHashMemSizeKB = hashMemSizeKB / 2u; configEditor configTpl{}; diff --git a/xmrstak/backend/cpu/autoAdjustHwloc.hpp b/xmrstak/backend/cpu/autoAdjustHwloc.hpp index 68d2b3f..f110ee3 100644 --- a/xmrstak/backend/cpu/autoAdjustHwloc.hpp +++ b/xmrstak/backend/cpu/autoAdjustHwloc.hpp @@ -28,7 +28,10 @@ public: autoAdjust() { - hashMemSize = cn_select_memory(::jconf::inst()->GetMiningAlgo()); + hashMemSize = std::max( + cn_select_memory(::jconf::inst()->GetMiningAlgo()), + cn_select_memory(::jconf::inst()->GetMiningAlgoRoot()) + ); halfHashMemSize = hashMemSize / 2u; } diff --git a/xmrstak/backend/cpu/crypto/cryptonight_common.cpp b/xmrstak/backend/cpu/crypto/cryptonight_common.cpp index 17fa24b..ac696dd 100644 --- a/xmrstak/backend/cpu/crypto/cryptonight_common.cpp +++ b/xmrstak/backend/cpu/crypto/cryptonight_common.cpp @@ -35,6 +35,7 @@ extern "C" #include "xmrstak/jconf.hpp" #include <stdio.h> #include <stdlib.h> +#include <algorithm> #ifdef __GNUC__ #include <mm_malloc.h> @@ -202,7 +203,10 @@ size_t cryptonight_init(size_t use_fast_mem, size_t use_mlock, alloc_msg* msg) cryptonight_ctx* cryptonight_alloc_ctx(size_t use_fast_mem, size_t use_mlock, alloc_msg* msg) { - size_t hashMemSize = cn_select_memory(::jconf::inst()->GetMiningAlgo()); + size_t hashMemSize = std::max( + cn_select_memory(::jconf::inst()->GetMiningAlgo()), + cn_select_memory(::jconf::inst()->GetMiningAlgoRoot()) + ); cryptonight_ctx* ptr = (cryptonight_ctx*)_mm_malloc(sizeof(cryptonight_ctx), 4096); @@ -278,7 +282,10 @@ cryptonight_ctx* cryptonight_alloc_ctx(size_t use_fast_mem, size_t use_mlock, al void cryptonight_free_ctx(cryptonight_ctx* ctx) { - size_t hashMemSize = cn_select_memory(::jconf::inst()->GetMiningAlgo()); + size_t hashMemSize = std::max( + cn_select_memory(::jconf::inst()->GetMiningAlgo()), + cn_select_memory(::jconf::inst()->GetMiningAlgoRoot()) + ); if(ctx->ctx_info[0] != 0) { |