diff options
author | fireice-uk <fireice-uk@users.noreply.github.com> | 2018-05-30 21:18:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-30 21:18:45 +0100 |
commit | c0ab1734332d6472225d8ac7394f6fcba71aabc9 (patch) | |
tree | b53a4c37905a0cb5dfa6a66f514cf3dc1ea94a21 /xmrstak/backend/cpu/minethd.cpp | |
parent | 26a5d65f12b2f19a0a3ece39a2bc64718796367b (diff) | |
parent | 4f34bd18024fa71a8cab81d5a0b86cf5c7d9370e (diff) | |
download | xmr-stak-2.4.4.zip xmr-stak-2.4.4.tar.gz |
Merge pull request #1610 from fireice-uk/dev2.4.4
release 2.4.4
Diffstat (limited to 'xmrstak/backend/cpu/minethd.cpp')
-rw-r--r-- | xmrstak/backend/cpu/minethd.cpp | 94 |
1 files changed, 76 insertions, 18 deletions
diff --git a/xmrstak/backend/cpu/minethd.cpp b/xmrstak/backend/cpu/minethd.cpp index f8f70f9..482c085 100644 --- a/xmrstak/backend/cpu/minethd.cpp +++ b/xmrstak/backend/cpu/minethd.cpp @@ -95,6 +95,7 @@ bool minethd::thd_setaffinity(std::thread::native_handle_type h, uint64_t cpu_id return pthread_setaffinity_np(h, sizeof(cpuset_t), &mn) == 0; #elif defined(__OpenBSD__) printer::inst()->print_msg(L0,"WARNING: thread pinning is not supported under OPENBSD."); + return true; #else cpu_set_t mn; CPU_ZERO(&mn); @@ -285,7 +286,12 @@ bool minethd::self_test() else if(::jconf::inst()->GetCurrentCoinSelection().GetDescription(1).GetMiningAlgo() == cryptonight_aeon) { } - + else if(::jconf::inst()->GetCurrentCoinSelection().GetDescription(1).GetMiningAlgo() == cryptonight_ipbc) + { + } + else if(::jconf::inst()->GetCurrentCoinSelection().GetDescription(1).GetMiningAlgo() == cryptonight_stellite) + { + } for (int i = 0; i < MAX_N; i++) cryptonight_free_ctx(ctx[i]); @@ -333,7 +339,7 @@ std::vector<iBackend*> minethd::thread_starter(uint32_t threadOffset, miner_work } else printer::inst()->print_msg(L1, "Starting %dx thread, no affinity.", cfg.iMultiway); - + minethd* thd = new minethd(pWork, i + threadOffset, cfg.iMultiway, cfg.bNoPrefetch, cfg.iCpuAff); pvThreads.push_back(thd); } @@ -341,13 +347,6 @@ std::vector<iBackend*> minethd::thread_starter(uint32_t threadOffset, miner_work return pvThreads; } -void minethd::consume_work() -{ - memcpy(&oWork, &globalStates::inst().inst().oGlobalWork, sizeof(miner_work)); - iJobNo++; - globalStates::inst().inst().iConsumeCnt++; -} - minethd::cn_hash_fun minethd::func_selector(bool bHaveAes, bool bNoPrefetch, xmrstak_algo algo) { // We have two independent flag bits in the functions @@ -372,6 +371,12 @@ minethd::cn_hash_fun minethd::func_selector(bool bHaveAes, bool bNoPrefetch, xmr case cryptonight_aeon: algv = 4; break; + case cryptonight_ipbc: + algv = 5; + break; + case cryptonight_stellite: + algv = 6; + break; default: algv = 2; break; @@ -397,7 +402,15 @@ minethd::cn_hash_fun minethd::func_selector(bool bHaveAes, bool bNoPrefetch, xmr cryptonight_hash<cryptonight_aeon, false, false>, cryptonight_hash<cryptonight_aeon, true, false>, cryptonight_hash<cryptonight_aeon, false, true>, - cryptonight_hash<cryptonight_aeon, true, true> + cryptonight_hash<cryptonight_aeon, true, true>, + cryptonight_hash<cryptonight_ipbc, false, false>, + cryptonight_hash<cryptonight_ipbc, true, false>, + cryptonight_hash<cryptonight_ipbc, false, true>, + cryptonight_hash<cryptonight_ipbc, true, true>, + cryptonight_hash<cryptonight_stellite, false, false>, + cryptonight_hash<cryptonight_stellite, true, false>, + cryptonight_hash<cryptonight_stellite, false, true>, + cryptonight_hash<cryptonight_stellite, true, true> }; std::bitset<2> digit; @@ -430,7 +443,6 @@ void minethd::work_main() piHashVal = (uint64_t*)(result.bResult + 24); piNonce = (uint32_t*)(oWork.bWorkBlob + 39); - globalStates::inst().inst().iConsumeCnt++; result.iThreadId = iThreadNo; uint8_t version = 0; @@ -448,7 +460,7 @@ void minethd::work_main() while (globalStates::inst().iGlobalJobNo.load(std::memory_order_relaxed) == iJobNo) std::this_thread::sleep_for(std::chrono::milliseconds(100)); - consume_work(); + globalStates::inst().consume_work(oWork, iJobNo); continue; } @@ -491,6 +503,9 @@ void minethd::work_main() if((nonce_ctr++ & (nonce_chunk-1)) == 0) { globalStates::inst().calc_start_nonce(result.iNonce, oWork.bNiceHash, nonce_chunk); + // check if the job is still valid, there is a small posibility that the job is switched + if(globalStates::inst().iGlobalJobNo.load(std::memory_order_relaxed) != iJobNo) + break; } *piNonce = result.iNonce; @@ -504,7 +519,7 @@ void minethd::work_main() std::this_thread::yield(); } - consume_work(); + globalStates::inst().consume_work(oWork, iJobNo); } cryptonight_free_ctx(ctx); @@ -534,6 +549,12 @@ minethd::cn_hash_fun_multi minethd::func_multi_selector(size_t N, bool bHaveAes, case cryptonight_aeon: algv = 4; break; + case cryptonight_ipbc: + algv = 5; + break; + case cryptonight_stellite: + algv = 6; + break; default: algv = 2; break; @@ -573,7 +594,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>, @@ -623,13 +644,47 @@ minethd::cn_hash_fun_multi minethd::func_multi_selector(size_t N, bool bHaveAes, 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> + cryptonight_penta_hash<cryptonight_aeon, true, true>, + + cryptonight_double_hash<cryptonight_ipbc, false, false>, + cryptonight_double_hash<cryptonight_ipbc, true, false>, + cryptonight_double_hash<cryptonight_ipbc, false, true>, + cryptonight_double_hash<cryptonight_ipbc, true, true>, + cryptonight_triple_hash<cryptonight_ipbc, false, false>, + cryptonight_triple_hash<cryptonight_ipbc, true, false>, + cryptonight_triple_hash<cryptonight_ipbc, false, true>, + cryptonight_triple_hash<cryptonight_ipbc, true, true>, + cryptonight_quad_hash<cryptonight_ipbc, false, false>, + cryptonight_quad_hash<cryptonight_ipbc, true, false>, + cryptonight_quad_hash<cryptonight_ipbc, false, true>, + cryptonight_quad_hash<cryptonight_ipbc, true, true>, + cryptonight_penta_hash<cryptonight_ipbc, false, false>, + cryptonight_penta_hash<cryptonight_ipbc, true, false>, + cryptonight_penta_hash<cryptonight_ipbc, false, true>, + cryptonight_penta_hash<cryptonight_ipbc, true, true>, + + cryptonight_double_hash<cryptonight_stellite, false, false>, + cryptonight_double_hash<cryptonight_stellite, true, false>, + cryptonight_double_hash<cryptonight_stellite, false, true>, + cryptonight_double_hash<cryptonight_stellite, true, true>, + cryptonight_triple_hash<cryptonight_stellite, false, false>, + cryptonight_triple_hash<cryptonight_stellite, true, false>, + cryptonight_triple_hash<cryptonight_stellite, false, true>, + cryptonight_triple_hash<cryptonight_stellite, true, true>, + cryptonight_quad_hash<cryptonight_stellite, false, false>, + cryptonight_quad_hash<cryptonight_stellite, true, false>, + cryptonight_quad_hash<cryptonight_stellite, false, true>, + cryptonight_quad_hash<cryptonight_stellite, true, true>, + cryptonight_penta_hash<cryptonight_stellite, false, false>, + cryptonight_penta_hash<cryptonight_stellite, true, false>, + cryptonight_penta_hash<cryptonight_stellite, false, true>, + cryptonight_penta_hash<cryptonight_stellite, true, true>, }; std::bitset<2> digit; digit.set(0, !bHaveAes); digit.set(1, !bNoPrefetch); - + return func_table[algv << 4 | (N-2) << 2 | digit.to_ulong()]; } @@ -713,7 +768,7 @@ void minethd::multiway_work_main() while (globalStates::inst().iGlobalJobNo.load(std::memory_order_relaxed) == iJobNo) std::this_thread::sleep_for(std::chrono::milliseconds(100)); - consume_work(); + globalStates::inst().consume_work(oWork, iJobNo); prep_multiway_work<N>(bWorkBlob, piNonce); continue; } @@ -758,6 +813,9 @@ void minethd::multiway_work_main() { globalStates::inst().calc_start_nonce(iNonce, oWork.bNiceHash, nonce_chunk); nonce_ctr = nonce_chunk; + // check if the job is still valid, there is a small posibility that the job is switched + if(globalStates::inst().iGlobalJobNo.load(std::memory_order_relaxed) != iJobNo) + break; } for (size_t i = 0; i < N; i++) @@ -776,7 +834,7 @@ void minethd::multiway_work_main() std::this_thread::yield(); } - consume_work(); + globalStates::inst().consume_work(oWork, iJobNo); prep_multiway_work<N>(bWorkBlob, piNonce); } |