@@ -351,7 +351,6 @@ void CLMiner::workLoop()
351
351
else
352
352
startNonce = randomNonce ();
353
353
354
- current = w;
355
354
auto switchEnd = std::chrono::high_resolution_clock::now ();
356
355
auto globalSwitchTime = std::chrono::duration_cast<std::chrono::milliseconds>(switchEnd - workSwitchStart).count ();
357
356
auto localSwitchTime = std::chrono::duration_cast<std::chrono::microseconds>(switchEnd - localSwitchStart).count ();
@@ -367,14 +366,11 @@ void CLMiner::workLoop()
367
366
if (results[0 ] > 0 )
368
367
{
369
368
// Ignore results except the first one.
370
- nonce = startNonce + results[1 ];
369
+ nonce = current. startNonce + results[1 ];
371
370
// Reset search buffer if any solution found.
372
371
m_queue.enqueueWriteBuffer (m_searchBuffer, CL_FALSE, 0 , sizeof (c_zero), &c_zero);
373
372
}
374
373
375
- // Increase start nonce for following kernel execution.
376
- startNonce += m_globalWorkSize;
377
-
378
374
// Run the kernel.
379
375
m_searchKernel.setArg (3 , startNonce);
380
376
m_queue.enqueueNDRangeKernel (m_searchKernel, cl::NullRange, m_globalWorkSize, m_workgroupSize);
@@ -384,6 +380,11 @@ void CLMiner::workLoop()
384
380
if (nonce != 0 )
385
381
report (nonce, current);
386
382
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
+
387
388
// Report hash count
388
389
addHashCount (m_globalWorkSize);
389
390
@@ -720,8 +721,6 @@ bool CLMiner::init(const h256& seed)
720
721
ETHCL_LOG (" Creating mining buffer" );
721
722
m_searchBuffer = cl::Buffer (m_context, CL_MEM_WRITE_ONLY, (c_maxSearchResults + 1 ) * sizeof (uint32_t ));
722
723
723
- cllog << " Generating DAG" ;
724
-
725
724
uint32_t const work = (uint32_t )(dagSize / sizeof (node));
726
725
uint32_t fullRuns = work / m_globalWorkSize;
727
726
uint32_t const restWork = work % m_globalWorkSize;
@@ -731,14 +730,18 @@ bool CLMiner::init(const h256& seed)
731
730
m_dagKernel.setArg (2 , m_dag);
732
731
m_dagKernel.setArg (3 , ~0u );
733
732
733
+ auto startDAG = std::chrono::steady_clock::now ();
734
734
for (uint32_t i = 0 ; i < fullRuns; i++)
735
735
{
736
736
m_dagKernel.setArg (0 , i * m_globalWorkSize);
737
737
m_queue.enqueueNDRangeKernel (m_dagKernel, cl::NullRange, m_globalWorkSize, m_workgroupSize);
738
738
m_queue.finish ();
739
- cllog << " DAG" << int (100 .0f * i / fullRuns) << ' %' ;
740
739
}
740
+ auto endDAG = std::chrono::steady_clock::now ();
741
741
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." ;
742
745
}
743
746
catch (cl::Error const & err)
744
747
{
0 commit comments