summaryrefslogtreecommitdiffstats
path: root/xmrstak/backend/nvidia/minethd.cpp
diff options
context:
space:
mode:
authorfireice-uk <fireice-uk@users.noreply.github.com>2018-05-30 21:18:45 +0100
committerGitHub <noreply@github.com>2018-05-30 21:18:45 +0100
commitc0ab1734332d6472225d8ac7394f6fcba71aabc9 (patch)
treeb53a4c37905a0cb5dfa6a66f514cf3dc1ea94a21 /xmrstak/backend/nvidia/minethd.cpp
parent26a5d65f12b2f19a0a3ece39a2bc64718796367b (diff)
parent4f34bd18024fa71a8cab81d5a0b86cf5c7d9370e (diff)
downloadxmr-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/nvidia/minethd.cpp')
-rw-r--r--xmrstak/backend/nvidia/minethd.cpp40
1 files changed, 10 insertions, 30 deletions
diff --git a/xmrstak/backend/nvidia/minethd.cpp b/xmrstak/backend/nvidia/minethd.cpp
index 92f5f78..16171e1 100644
--- a/xmrstak/backend/nvidia/minethd.cpp
+++ b/xmrstak/backend/nvidia/minethd.cpp
@@ -181,7 +181,7 @@ std::vector<iBackend*>* minethd::thread_starter(uint32_t threadOffset, miner_wor
}
else
printer::inst()->print_msg(L1, "Starting NVIDIA GPU thread %d, no affinity.", i);
-
+
minethd* thd = new minethd(pWork, i + threadOffset, cfg);
pvThreads->push_back(thd);
@@ -195,27 +195,6 @@ std::vector<iBackend*>* minethd::thread_starter(uint32_t threadOffset, miner_wor
return pvThreads;
}
-void minethd::switch_work(miner_work& pWork)
-{
- // iConsumeCnt is a basic lock-like polling mechanism just in case we happen to push work
- // faster than threads can consume them. This should never happen in real life.
- // Pool cant physically send jobs faster than every 250ms or so due to net latency.
-
- while (globalStates::inst().iConsumeCnt.load(std::memory_order_seq_cst) < globalStates::inst().iThreadCount)
- std::this_thread::sleep_for(std::chrono::milliseconds(100));
-
- globalStates::inst().oGlobalWork = pWork;
- globalStates::inst().iConsumeCnt.store(0, std::memory_order_seq_cst);
- globalStates::inst().iGlobalJobNo++;
-}
-
-void minethd::consume_work()
-{
- memcpy(&oWork, &globalStates::inst().oGlobalWork, sizeof(miner_work));
- iJobNo++;
- globalStates::inst().iConsumeCnt++;
-}
-
void minethd::work_main()
{
if(affinity >= 0) //-1 means no affinity
@@ -223,7 +202,7 @@ void minethd::work_main()
if(cuda_get_deviceinfo(&ctx) != 0 || cryptonight_extra_cpu_init(&ctx) != 1)
{
- printer::inst()->print_msg(L0, "Setup failed for GPU %d. Exitting.\n", (int)iThreadNo);
+ printer::inst()->print_msg(L0, "Setup failed for GPU %d. Exiting.\n", (int)iThreadNo);
std::exit(0);
}
@@ -237,14 +216,12 @@ void minethd::work_main()
uint64_t iCount = 0;
cryptonight_ctx* cpu_ctx;
cpu_ctx = cpu::minethd::minethd_alloc_ctx();
-
+
// start with root algorithm and switch later if fork version is reached
auto miner_algo = ::jconf::inst()->GetCurrentCoinSelection().GetDescription(1).GetMiningAlgoRoot();
cn_hash_fun hash_fun = cpu::minethd::func_selector(::jconf::inst()->HaveHardwareAes(), true /*bNoPrefetch*/, miner_algo);
-
- uint32_t iNonce;
- globalStates::inst().iConsumeCnt++;
+ uint32_t iNonce;
uint8_t version = 0;
size_t lastPoolId = 0;
@@ -261,7 +238,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;
}
uint8_t new_version = oWork.getVersion();
@@ -298,8 +275,11 @@ void minethd::work_main()
if((round_ctr++ & 0xF) == 0)
{
globalStates::inst().calc_start_nonce(iNonce, oWork.bNiceHash, h_per_round * 16);
+ // 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;
}
-
+
uint32_t foundNonce[10];
uint32_t foundCount;
@@ -337,7 +317,7 @@ void minethd::work_main()
std::this_thread::yield();
}
- consume_work();
+ globalStates::inst().consume_work(oWork, iJobNo);
}
}
OpenPOWER on IntegriCloud