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

Commit 93396ae

Browse files
committed
Merge remote-tracking branch 'origin/master' into release/0.13
2 parents b45e711 + 50fead6 commit 93396ae

File tree

11 files changed

+463
-564
lines changed

11 files changed

+463
-564
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ All bug reports, pull requests and code reviews are very much welcome.
179179

180180
8. Can I CPU Mine?
181181

182-
No, use geth, the go program made for ethereum by ethereum.
182+
No, use geth, the go program made for ethereum by ethereum.
183183

184184

185185

ethminer/MinerAux.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ class MinerCLI
239239
{
240240
m_worktimeout = atoi(argv[++i]);
241241
}
242-
else if ((arg == "-RH" || arg == "--report-hashrate") && i + 1 < argc)
242+
else if ((arg == "-RH" || arg == "--report-hashrate"))
243243
{
244244
m_report_stratum_hashrate = true;
245245
}
@@ -531,7 +531,7 @@ class MinerCLI
531531
exit(1);
532532
#endif
533533
}
534-
else if (m_minerType == MinerType::CUDA || m_minerType == MinerType::Mixed)
534+
if (m_minerType == MinerType::CUDA || m_minerType == MinerType::Mixed)
535535
{
536536
#if ETH_ETHASHCUDA
537537
if (m_cudaDeviceCount > 0)
@@ -626,9 +626,9 @@ class MinerCLI
626626
#endif
627627
#if ETH_ETHASHCUDA
628628
<< " CUDA configuration:" << endl
629-
<< " --cuda-block-size Set the CUDA block work size. Default is " << toString(ethash_cuda_miner::c_defaultBlockSize) << endl
630-
<< " --cuda-grid-size Set the CUDA grid size. Default is " << toString(ethash_cuda_miner::c_defaultGridSize) << endl
631-
<< " --cuda-streams Set the number of CUDA streams. Default is " << toString(ethash_cuda_miner::c_defaultNumStreams) << endl
629+
<< " --cuda-block-size Set the CUDA block work size. Default is " << toString(CUDAMiner::c_defaultBlockSize) << endl
630+
<< " --cuda-grid-size Set the CUDA grid size. Default is " << toString(CUDAMiner::c_defaultGridSize) << endl
631+
<< " --cuda-streams Set the number of CUDA streams. Default is " << toString(CUDAMiner::c_defaultNumStreams) << endl
632632
<< " --cuda-schedule <mode> Set the schedule mode for CUDA threads waiting for CUDA devices to finish work. Default is 'sync'. Possible values are:" << endl
633633
<< " auto - Uses a heuristic based on the number of active CUDA contexts in the process C and the number of logical processors in the system P. If C > P, then yield else spin." << endl
634634
<< " spin - Instruct CUDA to actively spin when waiting for results from the device." << endl
@@ -1083,11 +1083,11 @@ class MinerCLI
10831083
#endif
10841084
#endif
10851085
#if ETH_ETHASHCUDA
1086-
unsigned m_globalWorkSizeMultiplier = ethash_cuda_miner::c_defaultGridSize;
1087-
unsigned m_localWorkSize = ethash_cuda_miner::c_defaultBlockSize;
1086+
unsigned m_globalWorkSizeMultiplier = CUDAMiner::c_defaultGridSize;
1087+
unsigned m_localWorkSize = CUDAMiner::c_defaultBlockSize;
10881088
unsigned m_cudaDeviceCount = 0;
10891089
unsigned m_cudaDevices[16];
1090-
unsigned m_numStreams = ethash_cuda_miner::c_defaultNumStreams;
1090+
unsigned m_numStreams = CUDAMiner::c_defaultNumStreams;
10911091
unsigned m_cudaSchedule = 4; // sync
10921092
#endif
10931093
unsigned m_dagLoadMode = 0; // parallel

libethash-cl/CLMiner.cpp

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ void CLMiner::report(uint64_t _nonce, WorkPackage const& _w)
271271
// TODO: Why re-evaluating?
272272
Result r = EthashAux::eval(_w.seed, _w.header, _nonce);
273273
if (r.value < _w.boundary)
274-
farm.submitProof(Solution{_nonce, r.mixHash, _w.header, _w.seed, _w.boundary, _w.job, false});
274+
farm.submitProof(Solution{_nonce, r.mixHash, _w.header, _w.seed, _w.boundary, _w.job, _w.job_len, false});
275275
else {
276276
farm.failedSolution();
277277
cwarn << "FAILURE: GPU gave incorrect result!";
@@ -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

@@ -678,6 +679,18 @@ bool CLMiner::init(const h256& seed)
678679
return false;
679680
}
680681

682+
//check whether the current dag fits in memory everytime we recreate the DAG
683+
cl_ulong result = 0;
684+
device.getInfo(CL_DEVICE_GLOBAL_MEM_SIZE, &result);
685+
if (result < dagSize)
686+
{
687+
cnote <<
688+
"OpenCL device " << device.getInfo<CL_DEVICE_NAME>()
689+
<< " has insufficient GPU memory." << result <<
690+
" bytes of memory found < " << dagSize << " bytes of memory required";
691+
return false;
692+
}
693+
681694
// create buffer for dag
682695
try
683696
{
@@ -708,8 +721,6 @@ bool CLMiner::init(const h256& seed)
708721
ETHCL_LOG("Creating mining buffer");
709722
m_searchBuffer = cl::Buffer(m_context, CL_MEM_WRITE_ONLY, (c_maxSearchResults + 1) * sizeof(uint32_t));
710723

711-
cllog << "Generating DAG";
712-
713724
uint32_t const work = (uint32_t)(dagSize / sizeof(node));
714725
uint32_t fullRuns = work / m_globalWorkSize;
715726
uint32_t const restWork = work % m_globalWorkSize;
@@ -719,14 +730,18 @@ bool CLMiner::init(const h256& seed)
719730
m_dagKernel.setArg(2, m_dag);
720731
m_dagKernel.setArg(3, ~0u);
721732

733+
auto startDAG = std::chrono::steady_clock::now();
722734
for (uint32_t i = 0; i < fullRuns; i++)
723735
{
724736
m_dagKernel.setArg(0, i * m_globalWorkSize);
725737
m_queue.enqueueNDRangeKernel(m_dagKernel, cl::NullRange, m_globalWorkSize, m_workgroupSize);
726738
m_queue.finish();
727-
cllog << "DAG" << int(100.0f * i / fullRuns) << '%';
728739
}
740+
auto endDAG = std::chrono::steady_clock::now();
729741

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.";
730745
}
731746
catch (cl::Error const& err)
732747
{

0 commit comments

Comments
 (0)