diff options
Diffstat (limited to 'xmrstak/backend/cpu')
-rw-r--r-- | xmrstak/backend/cpu/autoAdjust.hpp | 14 | ||||
-rw-r--r-- | xmrstak/backend/cpu/crypto/cryptonight_aesni.h | 30 | ||||
-rw-r--r-- | xmrstak/backend/cpu/jconf.cpp | 10 | ||||
-rw-r--r-- | xmrstak/backend/cpu/minethd.cpp | 120 | ||||
-rw-r--r-- | xmrstak/backend/cpu/minethd.hpp | 2 |
5 files changed, 108 insertions, 68 deletions
diff --git a/xmrstak/backend/cpu/autoAdjust.hpp b/xmrstak/backend/cpu/autoAdjust.hpp index db805ec..969d478 100644 --- a/xmrstak/backend/cpu/autoAdjust.hpp +++ b/xmrstak/backend/cpu/autoAdjust.hpp @@ -35,19 +35,9 @@ public: bool printConfig() { - size_t hashMemSizeKB; - size_t halfHashMemSizeKB; - if(::jconf::inst()->IsCurrencyMonero()) - { - hashMemSizeKB = MONERO_MEMORY / 1024u; - halfHashMemSizeKB = hashMemSizeKB / 2u; - } - else - { - hashMemSizeKB = AEON_MEMORY / 1024u; - halfHashMemSizeKB = hashMemSizeKB / 2u; - } + const size_t hashMemSizeKB = cn_select_memory(::jconf::inst()->GetMiningAlgo()) / 1024u; + const size_t halfHashMemSizeKB = hashMemSizeKB / 2u; configEditor configTpl{}; diff --git a/xmrstak/backend/cpu/crypto/cryptonight_aesni.h b/xmrstak/backend/cpu/crypto/cryptonight_aesni.h index 85373e8..5203de8 100644 --- a/xmrstak/backend/cpu/crypto/cryptonight_aesni.h +++ b/xmrstak/backend/cpu/crypto/cryptonight_aesni.h @@ -444,7 +444,7 @@ void cryptonight_hash(const void* input, size_t len, void* output, cryptonight_c constexpr size_t ITERATIONS = cn_select_iter<ALGO>(); constexpr size_t MEM = cn_select_memory<ALGO>(); - if(ALGO == cryptonight_monero && len < 43) + if((ALGO == cryptonight_monero || ALGO == cryptonight_aeon) && len < 43) { memset(output, 0, 32); return; @@ -453,7 +453,7 @@ void cryptonight_hash(const void* input, size_t len, void* output, cryptonight_c keccak((const uint8_t *)input, len, ctx0->hash_state, 200); uint64_t monero_const; - if(ALGO == cryptonight_monero) + if(ALGO == cryptonight_monero || ALGO == cryptonight_aeon) { monero_const = *reinterpret_cast<const uint64_t*>(reinterpret_cast<const uint8_t*>(input) + 35); monero_const ^= *(reinterpret_cast<const uint64_t*>(ctx0->hash_state) + 24); @@ -482,7 +482,7 @@ void cryptonight_hash(const void* input, size_t len, void* output, cryptonight_c else cx = _mm_aesenc_si128(cx, _mm_set_epi64x(ah0, al0)); - if(ALGO == cryptonight_monero) + if(ALGO == cryptonight_monero || ALGO == cryptonight_aeon) cryptonight_monero_tweak((uint64_t*)&l0[idx0 & MASK], _mm_xor_si128(bx0, cx)); else _mm_store_si128((__m128i *)&l0[idx0 & MASK], _mm_xor_si128(bx0, cx)); @@ -506,7 +506,7 @@ void cryptonight_hash(const void* input, size_t len, void* output, cryptonight_c _mm_prefetch((const char*)&l0[al0 & MASK], _MM_HINT_T0); ah0 += lo; - if(ALGO == cryptonight_monero) + if(ALGO == cryptonight_monero || ALGO == cryptonight_aeon) ((uint64_t*)&l0[idx0 & MASK])[1] = ah0 ^ monero_const; else ((uint64_t*)&l0[idx0 & MASK])[1] = ah0; @@ -544,7 +544,7 @@ void cryptonight_double_hash(const void* input, size_t len, void* output, crypto constexpr size_t ITERATIONS = cn_select_iter<ALGO>(); constexpr size_t MEM = cn_select_memory<ALGO>(); - if(ALGO == cryptonight_monero && len < 43) + if((ALGO == cryptonight_monero || ALGO == cryptonight_aeon) && len < 43) { memset(output, 0, 64); return; @@ -554,7 +554,7 @@ void cryptonight_double_hash(const void* input, size_t len, void* output, crypto keccak((const uint8_t *)input+len, len, ctx[1]->hash_state, 200); uint64_t monero_const_0, monero_const_1; - if(ALGO == cryptonight_monero) + if(ALGO == cryptonight_monero || ALGO == cryptonight_aeon) { monero_const_0 = *reinterpret_cast<const uint64_t*>(reinterpret_cast<const uint8_t*>(input) + 35); monero_const_0 ^= *(reinterpret_cast<const uint64_t*>(ctx[0]->hash_state) + 24); @@ -592,7 +592,7 @@ void cryptonight_double_hash(const void* input, size_t len, void* output, crypto else cx = _mm_aesenc_si128(cx, _mm_set_epi64x(axh0, axl0)); - if(ALGO == cryptonight_monero) + if(ALGO == cryptonight_monero || ALGO == cryptonight_aeon) cryptonight_monero_tweak((uint64_t*)&l0[idx0 & MASK], _mm_xor_si128(bx0, cx)); else _mm_store_si128((__m128i *)&l0[idx0 & MASK], _mm_xor_si128(bx0, cx)); @@ -610,7 +610,7 @@ void cryptonight_double_hash(const void* input, size_t len, void* output, crypto else cx = _mm_aesenc_si128(cx, _mm_set_epi64x(axh1, axl1)); - if(ALGO == cryptonight_monero) + if(ALGO == cryptonight_monero || ALGO == cryptonight_aeon) cryptonight_monero_tweak((uint64_t*)&l1[idx1 & MASK], _mm_xor_si128(bx1, cx)); else _mm_store_si128((__m128i *)&l1[idx1 & MASK], _mm_xor_si128(bx1, cx)); @@ -631,7 +631,7 @@ void cryptonight_double_hash(const void* input, size_t len, void* output, crypto axh0 += lo; ((uint64_t*)&l0[idx0 & MASK])[0] = axl0; - if(ALGO == cryptonight_monero) + if(ALGO == cryptonight_monero || ALGO == cryptonight_aeon) ((uint64_t*)&l0[idx0 & MASK])[1] = axh0 ^ monero_const_0; else ((uint64_t*)&l0[idx0 & MASK])[1] = axh0; @@ -662,7 +662,7 @@ void cryptonight_double_hash(const void* input, size_t len, void* output, crypto axh1 += lo; ((uint64_t*)&l1[idx1 & MASK])[0] = axl1; - if(ALGO == cryptonight_monero) + if(ALGO == cryptonight_monero || ALGO == cryptonight_aeon) ((uint64_t*)&l1[idx1 & MASK])[1] = axh1 ^ monero_const_1; else ((uint64_t*)&l1[idx1 & MASK])[1] = axh1; @@ -709,7 +709,7 @@ void cryptonight_double_hash(const void* input, size_t len, void* output, crypto else \ c = _mm_aesenc_si128(c, a); \ b = _mm_xor_si128(b, c); \ - if(ALGO == cryptonight_monero) \ + if(ALGO == cryptonight_monero || ALGO == cryptonight_aeon) \ cryptonight_monero_tweak((uint64_t*)ptr, b); \ else \ _mm_store_si128(ptr, b);\ @@ -724,7 +724,7 @@ void cryptonight_double_hash(const void* input, size_t len, void* output, crypto #define CN_STEP4(a, b, c, l, mc, ptr, idx) \ lo = _umul128(idx, _mm_cvtsi128_si64(b), &hi); \ a = _mm_add_epi64(a, _mm_set_epi64x(lo, hi)); \ - if(ALGO == cryptonight_monero) \ + if(ALGO == cryptonight_monero || ALGO == cryptonight_aeon) \ _mm_store_si128(ptr, _mm_xor_si128(a, mc)); \ else \ _mm_store_si128(ptr, a);\ @@ -751,7 +751,7 @@ void cryptonight_triple_hash(const void* input, size_t len, void* output, crypto constexpr size_t ITERATIONS = cn_select_iter<ALGO>(); constexpr size_t MEM = cn_select_memory<ALGO>(); - if(ALGO == cryptonight_monero && len < 43) + if((ALGO == cryptonight_monero || ALGO == cryptonight_aeon) && len < 43) { memset(output, 0, 32 * 3); return; @@ -845,7 +845,7 @@ void cryptonight_quad_hash(const void* input, size_t len, void* output, cryptoni constexpr size_t ITERATIONS = cn_select_iter<ALGO>(); constexpr size_t MEM = cn_select_memory<ALGO>(); - if(ALGO == cryptonight_monero && len < 43) + if((ALGO == cryptonight_monero || ALGO == cryptonight_aeon) && len < 43) { memset(output, 0, 32 * 4); return; @@ -954,7 +954,7 @@ void cryptonight_penta_hash(const void* input, size_t len, void* output, crypton constexpr size_t ITERATIONS = cn_select_iter<ALGO>(); constexpr size_t MEM = cn_select_memory<ALGO>(); - if(ALGO == cryptonight_monero && len < 43) + if((ALGO == cryptonight_monero || ALGO == cryptonight_aeon) && len < 43) { memset(output, 0, 32 * 5); return; diff --git a/xmrstak/backend/cpu/jconf.cpp b/xmrstak/backend/cpu/jconf.cpp index 6e709bd..399dd16 100644 --- a/xmrstak/backend/cpu/jconf.cpp +++ b/xmrstak/backend/cpu/jconf.cpp @@ -211,14 +211,14 @@ bool jconf::parse_config(const char* sFilename) if(prv->jsonDoc.HasParseError()) { - printer::inst()->print_msg(L0, "JSON config parse error(offset %llu): %s", - int_port(prv->jsonDoc.GetErrorOffset()), GetParseError_En(prv->jsonDoc.GetParseError())); + printer::inst()->print_msg(L0, "JSON config parse error in '%s' (offset %llu): %s", + sFilename, int_port(prv->jsonDoc.GetErrorOffset()), GetParseError_En(prv->jsonDoc.GetParseError())); return false; } if(!prv->jsonDoc.IsObject()) { //This should never happen as we created the root ourselves - printer::inst()->print_msg(L0, "Invalid config file. No root?\n"); + printer::inst()->print_msg(L0, "Invalid config file '%s'. No root?", sFilename); return false; } @@ -234,13 +234,13 @@ bool jconf::parse_config(const char* sFilename) if(prv->configValues[i] == nullptr) { - printer::inst()->print_msg(L0, "Invalid config file. Missing value \"%s\".", oConfigValues[i].sName); + printer::inst()->print_msg(L0, "Invalid config file '%s'. Missing value \"%s\".", sFilename, oConfigValues[i].sName); return false; } if(!checkType(prv->configValues[i]->GetType(), oConfigValues[i].iType)) { - printer::inst()->print_msg(L0, "Invalid config file. Value \"%s\" has unexpected type.", oConfigValues[i].sName); + printer::inst()->print_msg(L0, "Invalid config file '%s'. Value \"%s\" has unexpected type.", sFilename, oConfigValues[i].sName); return false; } } diff --git a/xmrstak/backend/cpu/minethd.cpp b/xmrstak/backend/cpu/minethd.cpp index e263aca..5b56f85 100644 --- a/xmrstak/backend/cpu/minethd.cpp +++ b/xmrstak/backend/cpu/minethd.cpp @@ -282,6 +282,9 @@ bool minethd::self_test() else if(::jconf::inst()->GetMiningAlgo() == cryptonight_monero) { } + else if(::jconf::inst()->GetMiningAlgo() == cryptonight_aeon) + { + } for (int i = 0; i < MAX_N; i++) cryptonight_free_ctx(ctx[i]); @@ -366,6 +369,9 @@ minethd::cn_hash_fun minethd::func_selector(bool bHaveAes, bool bNoPrefetch, xmr case cryptonight_heavy: algv = 3; break; + case cryptonight_aeon: + algv = 4; + break; default: algv = 2; break; @@ -387,7 +393,11 @@ minethd::cn_hash_fun minethd::func_selector(bool bHaveAes, bool bNoPrefetch, xmr cryptonight_hash<cryptonight_heavy, false, false>, cryptonight_hash<cryptonight_heavy, true, false>, cryptonight_hash<cryptonight_heavy, false, true>, - cryptonight_hash<cryptonight_heavy, true, true> + cryptonight_hash<cryptonight_heavy, true, true>, + cryptonight_hash<cryptonight_aeon, false, false>, + cryptonight_hash<cryptonight_aeon, true, false>, + cryptonight_hash<cryptonight_aeon, false, true>, + cryptonight_hash<cryptonight_aeon, true, true> }; std::bitset<2> digit; @@ -407,14 +417,15 @@ void minethd::work_main() lck.release(); std::this_thread::yield(); - cn_hash_fun hash_fun; cryptonight_ctx* ctx; uint64_t iCount = 0; uint64_t* piHashVal; uint32_t* piNonce; job_result result; - hash_fun = func_selector(::jconf::inst()->HaveHardwareAes(), bNoPrefetch, ::jconf::inst()->GetMiningAlgo()); + // start with root algorithm and switch later if fork version is reached + auto miner_algo = ::jconf::inst()->GetMiningAlgoRoot(); + cn_hash_fun hash_fun = func_selector(::jconf::inst()->HaveHardwareAes(), bNoPrefetch, miner_algo); ctx = minethd_alloc_ctx(); piHashVal = (uint64_t*)(result.bResult + 24); @@ -422,6 +433,8 @@ void minethd::work_main() globalStates::inst().inst().iConsumeCnt++; result.iThreadId = iThreadNo; + uint8_t version = 0; + while (bQuit == 0) { if (oWork.bStall) @@ -447,20 +460,15 @@ void minethd::work_main() if(oWork.bNiceHash) result.iNonce = *piNonce; - if(::jconf::inst()->GetMiningAlgo() == cryptonight_monero) + uint8_t new_version = oWork.getVersion(); + if(new_version != version) { - if(oWork.bWorkBlob[0] >= 7) - hash_fun = func_selector(::jconf::inst()->HaveHardwareAes(), bNoPrefetch, cryptonight_monero); - else - hash_fun = func_selector(::jconf::inst()->HaveHardwareAes(), bNoPrefetch, cryptonight); - } - - if(::jconf::inst()->GetMiningAlgo() == cryptonight_heavy) - { - if(oWork.bWorkBlob[0] >= 3) - hash_fun = func_selector(::jconf::inst()->HaveHardwareAes(), bNoPrefetch, cryptonight_heavy); - else - hash_fun = func_selector(::jconf::inst()->HaveHardwareAes(), bNoPrefetch, cryptonight); + if(new_version >= ::jconf::inst()->GetMiningForkVersion()) + { + miner_algo = ::jconf::inst()->GetMiningAlgo(); + hash_fun = func_selector(::jconf::inst()->HaveHardwareAes(), bNoPrefetch, miner_algo); + } + version = new_version; } while(globalStates::inst().iGlobalJobNo.load(std::memory_order_relaxed) == iJobNo) @@ -512,6 +520,12 @@ minethd::cn_hash_fun_multi minethd::func_multi_selector(size_t N, bool bHaveAes, case cryptonight_monero: algv = 0; break; + case cryptonight_heavy: + algv = 3; + break; + case cryptonight_aeon: + algv = 4; + break; default: algv = 2; break; @@ -534,6 +548,7 @@ minethd::cn_hash_fun_multi minethd::func_multi_selector(size_t N, bool bHaveAes, cryptonight_penta_hash<cryptonight_monero, true, false>, cryptonight_penta_hash<cryptonight_monero, false, true>, cryptonight_penta_hash<cryptonight_monero, true, true>, + cryptonight_double_hash<cryptonight_lite, false, false>, cryptonight_double_hash<cryptonight_lite, true, false>, cryptonight_double_hash<cryptonight_lite, false, true>, @@ -550,6 +565,7 @@ minethd::cn_hash_fun_multi minethd::func_multi_selector(size_t N, bool bHaveAes, cryptonight_penta_hash<cryptonight_lite, true, false>, cryptonight_penta_hash<cryptonight_lite, false, true>, cryptonight_penta_hash<cryptonight_lite, true, true>, + cryptonight_double_hash<cryptonight, false, false>, cryptonight_double_hash<cryptonight, true, false>, cryptonight_double_hash<cryptonight, false, true>, @@ -565,7 +581,41 @@ minethd::cn_hash_fun_multi minethd::func_multi_selector(size_t N, bool bHaveAes, cryptonight_penta_hash<cryptonight, false, false>, cryptonight_penta_hash<cryptonight, true, false>, cryptonight_penta_hash<cryptonight, false, true>, - cryptonight_penta_hash<cryptonight, true, true> + cryptonight_penta_hash<cryptonight, true, true>, + + cryptonight_double_hash<cryptonight_heavy, false, false>, + cryptonight_double_hash<cryptonight_heavy, true, false>, + cryptonight_double_hash<cryptonight_heavy, false, true>, + cryptonight_double_hash<cryptonight_heavy, true, true>, + cryptonight_triple_hash<cryptonight_heavy, false, false>, + cryptonight_triple_hash<cryptonight_heavy, true, false>, + cryptonight_triple_hash<cryptonight_heavy, false, true>, + cryptonight_triple_hash<cryptonight_heavy, true, true>, + cryptonight_quad_hash<cryptonight_heavy, false, false>, + cryptonight_quad_hash<cryptonight_heavy, true, false>, + cryptonight_quad_hash<cryptonight_heavy, false, true>, + cryptonight_quad_hash<cryptonight_heavy, true, true>, + cryptonight_penta_hash<cryptonight_heavy, false, false>, + cryptonight_penta_hash<cryptonight_heavy, true, false>, + cryptonight_penta_hash<cryptonight_heavy, false, true>, + cryptonight_penta_hash<cryptonight_heavy, true, true>, + + cryptonight_double_hash<cryptonight_aeon, false, false>, + cryptonight_double_hash<cryptonight_aeon, true, false>, + cryptonight_double_hash<cryptonight_aeon, false, true>, + cryptonight_double_hash<cryptonight_aeon, true, true>, + cryptonight_triple_hash<cryptonight_aeon, false, false>, + cryptonight_triple_hash<cryptonight_aeon, true, false>, + cryptonight_triple_hash<cryptonight_aeon, false, true>, + cryptonight_triple_hash<cryptonight_aeon, true, true>, + cryptonight_quad_hash<cryptonight_aeon, false, false>, + cryptonight_quad_hash<cryptonight_aeon, true, false>, + cryptonight_quad_hash<cryptonight_aeon, false, true>, + cryptonight_quad_hash<cryptonight_aeon, true, true>, + cryptonight_penta_hash<cryptonight_aeon, false, false>, + cryptonight_penta_hash<cryptonight_aeon, true, false>, + cryptonight_penta_hash<cryptonight_aeon, false, true>, + cryptonight_penta_hash<cryptonight_aeon, true, true> }; std::bitset<2> digit; @@ -577,22 +627,22 @@ minethd::cn_hash_fun_multi minethd::func_multi_selector(size_t N, bool bHaveAes, void minethd::double_work_main() { - multiway_work_main<2>(func_multi_selector(2, ::jconf::inst()->HaveHardwareAes(), bNoPrefetch, ::jconf::inst()->GetMiningAlgo())); + multiway_work_main<2>(); } void minethd::triple_work_main() { - multiway_work_main<3>(func_multi_selector(3, ::jconf::inst()->HaveHardwareAes(), bNoPrefetch, ::jconf::inst()->GetMiningAlgo())); + multiway_work_main<3>(); } void minethd::quad_work_main() { - multiway_work_main<4>(func_multi_selector(4, ::jconf::inst()->HaveHardwareAes(), bNoPrefetch, ::jconf::inst()->GetMiningAlgo())); + multiway_work_main<4>(); } void minethd::penta_work_main() { - multiway_work_main<5>(func_multi_selector(5, ::jconf::inst()->HaveHardwareAes(), bNoPrefetch, ::jconf::inst()->GetMiningAlgo())); + multiway_work_main<5>(); } template<size_t N> @@ -607,7 +657,7 @@ void minethd::prep_multiway_work(uint8_t *bWorkBlob, uint32_t **piNonce) } template<size_t N> -void minethd::multiway_work_main(cn_hash_fun_multi hash_fun_multi) +void minethd::multiway_work_main() { if(affinity >= 0) //-1 means no affinity bindMemoryToNUMANode(affinity); @@ -638,6 +688,11 @@ void minethd::multiway_work_main(cn_hash_fun_multi hash_fun_multi) globalStates::inst().iConsumeCnt++; + // start with root algorithm and switch later if fork version is reached + auto miner_algo = ::jconf::inst()->GetMiningAlgoRoot(); + cn_hash_fun_multi hash_fun_multi = func_multi_selector(N, ::jconf::inst()->HaveHardwareAes(), bNoPrefetch, miner_algo); + uint8_t version = 0; + while (bQuit == 0) { if (oWork.bStall) @@ -662,20 +717,15 @@ void minethd::multiway_work_main(cn_hash_fun_multi hash_fun_multi) if(oWork.bNiceHash) iNonce = *piNonce[0]; - if(::jconf::inst()->GetMiningAlgo() == cryptonight_monero) + uint8_t new_version = oWork.getVersion(); + if(new_version != version) { - if(oWork.bWorkBlob[0] >= 7) - hash_fun_multi = func_multi_selector(N, ::jconf::inst()->HaveHardwareAes(), bNoPrefetch, cryptonight_monero); - else - hash_fun_multi = func_multi_selector(N, ::jconf::inst()->HaveHardwareAes(), bNoPrefetch, cryptonight); - } - - if(::jconf::inst()->GetMiningAlgo() == cryptonight_heavy) - { - if(oWork.bWorkBlob[0] >= 3) - hash_fun_multi = func_multi_selector(N, ::jconf::inst()->HaveHardwareAes(), bNoPrefetch, cryptonight_heavy); - else - hash_fun_multi = func_multi_selector(N, ::jconf::inst()->HaveHardwareAes(), bNoPrefetch, cryptonight); + if(new_version >= ::jconf::inst()->GetMiningForkVersion()) + { + miner_algo = ::jconf::inst()->GetMiningAlgo(); + hash_fun_multi = func_multi_selector(N, ::jconf::inst()->HaveHardwareAes(), bNoPrefetch, miner_algo); + } + version = new_version; } while (globalStates::inst().iGlobalJobNo.load(std::memory_order_relaxed) == iJobNo) diff --git a/xmrstak/backend/cpu/minethd.hpp b/xmrstak/backend/cpu/minethd.hpp index ef1bbd2..cd78343 100644 --- a/xmrstak/backend/cpu/minethd.hpp +++ b/xmrstak/backend/cpu/minethd.hpp @@ -36,7 +36,7 @@ private: minethd(miner_work& pWork, size_t iNo, int iMultiway, bool no_prefetch, int64_t affinity); template<size_t N> - void multiway_work_main(cn_hash_fun_multi hash_fun_multi); + void multiway_work_main(); template<size_t N> void prep_multiway_work(uint8_t *bWorkBlob, uint32_t **piNonce); |