Skip to content
This repository was archived by the owner on Apr 24, 2022. It is now read-only.

Commit 50fead6

Browse files
authoredJan 21, 2018
Merge pull request #571 from nerdralph/master
match stale solutions to correct header
2 parents 02ea7c8 + 5b03cc9 commit 50fead6

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed
 

‎libethash-cl/CLMiner.cpp

+11-8
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,6 @@ void CLMiner::workLoop()
351351
else
352352
startNonce = randomNonce();
353353

354-
current = w;
355354
auto switchEnd = std::chrono::high_resolution_clock::now();
356355
auto globalSwitchTime = std::chrono::duration_cast<std::chrono::milliseconds>(switchEnd - workSwitchStart).count();
357356
auto localSwitchTime = std::chrono::duration_cast<std::chrono::microseconds>(switchEnd - localSwitchStart).count();
@@ -367,14 +366,11 @@ void CLMiner::workLoop()
367366
if (results[0] > 0)
368367
{
369368
// Ignore results except the first one.
370-
nonce = startNonce + results[1];
369+
nonce = current.startNonce + results[1];
371370
// Reset search buffer if any solution found.
372371
m_queue.enqueueWriteBuffer(m_searchBuffer, CL_FALSE, 0, sizeof(c_zero), &c_zero);
373372
}
374373

375-
// Increase start nonce for following kernel execution.
376-
startNonce += m_globalWorkSize;
377-
378374
// Run the kernel.
379375
m_searchKernel.setArg(3, startNonce);
380376
m_queue.enqueueNDRangeKernel(m_searchKernel, cl::NullRange, m_globalWorkSize, m_workgroupSize);
@@ -384,6 +380,11 @@ void CLMiner::workLoop()
384380
if (nonce != 0)
385381
report(nonce, current);
386382

383+
current = w; // kernel now processing newest work
384+
current.startNonce = startNonce;
385+
// Increase start nonce for following kernel execution.
386+
startNonce += m_globalWorkSize;
387+
387388
// Report hash count
388389
addHashCount(m_globalWorkSize);
389390

@@ -720,8 +721,6 @@ bool CLMiner::init(const h256& seed)
720721
ETHCL_LOG("Creating mining buffer");
721722
m_searchBuffer = cl::Buffer(m_context, CL_MEM_WRITE_ONLY, (c_maxSearchResults + 1) * sizeof(uint32_t));
722723

723-
cllog << "Generating DAG";
724-
725724
uint32_t const work = (uint32_t)(dagSize / sizeof(node));
726725
uint32_t fullRuns = work / m_globalWorkSize;
727726
uint32_t const restWork = work % m_globalWorkSize;
@@ -731,14 +730,18 @@ bool CLMiner::init(const h256& seed)
731730
m_dagKernel.setArg(2, m_dag);
732731
m_dagKernel.setArg(3, ~0u);
733732

733+
auto startDAG = std::chrono::steady_clock::now();
734734
for (uint32_t i = 0; i < fullRuns; i++)
735735
{
736736
m_dagKernel.setArg(0, i * m_globalWorkSize);
737737
m_queue.enqueueNDRangeKernel(m_dagKernel, cl::NullRange, m_globalWorkSize, m_workgroupSize);
738738
m_queue.finish();
739-
cllog << "DAG" << int(100.0f * i / fullRuns) << '%';
740739
}
740+
auto endDAG = std::chrono::steady_clock::now();
741741

742+
auto dagTime = std::chrono::duration_cast<std::chrono::milliseconds>(endDAG-startDAG);
743+
float gb = (float)dagSize / (1024 * 1024 * 1024);
744+
cnote << gb << " GB of DAG data generated in" << dagTime.count() << "ms.";
742745
}
743746
catch (cl::Error const& err)
744747
{

0 commit comments

Comments
 (0)
This repository has been archived.