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

Commit d8d618a

Browse files
committed
Merge remote-tracking branch 'origin/master' into release/0.13
2 parents c30a119 + 1164588 commit d8d618a

File tree

8 files changed

+161
-196
lines changed

8 files changed

+161
-196
lines changed

circle.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: 2
22
jobs:
33
build:
44
docker:
5-
- image: nvidia/cuda:9.0-devel-ubuntu17.04
5+
- image: nvidia/cuda:9.1-devel-ubuntu16.04
66
steps:
77
- checkout
88

libethash-cl/CLMiner.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ CLMiner::CLMiner(FarmFace& _farm, unsigned _index):
262262

263263
CLMiner::~CLMiner()
264264
{
265-
pause();
265+
kick_miner();
266266
}
267267

268268
void CLMiner::report(uint64_t _nonce, WorkPackage const& _w)
@@ -278,9 +278,6 @@ void CLMiner::report(uint64_t _nonce, WorkPackage const& _w)
278278
}
279279
}
280280

281-
void CLMiner::kickOff()
282-
{}
283-
284281
namespace
285282
{
286283
uint64_t randomNonce()
@@ -404,9 +401,7 @@ void CLMiner::workLoop()
404401
}
405402
}
406403

407-
void CLMiner::pause() {}
408-
409-
void CLMiner::waitPaused() {}
404+
void CLMiner::kick_miner() {}
410405

411406
unsigned CLMiner::getNumDevices()
412407
{

libethash-cl/CLMiner.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,7 @@ class CLMiner: public Miner
8484
static void setCLKernel(unsigned _clKernel) { s_clKernelName = _clKernel == 1 ? CLKernelName::Unstable : CLKernelName::Stable; }
8585
HwMonitor hwmon() override;
8686
protected:
87-
void kickOff() override;
88-
void pause() override;
89-
void waitPaused() override;
87+
void kick_miner() override;
9088

9189
private:
9290
void workLoop() override;

libethash-cuda/CUDAMiner.cpp

Lines changed: 43 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,18 @@ using namespace dev;
2525
using namespace eth;
2626

2727
unsigned CUDAMiner::s_numInstances = 0;
28-
int CUDAMiner::s_devices[16] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
28+
29+
int CUDAMiner::s_devices[16] = {
30+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
31+
};
2932

3033
struct CUDAChannel: public LogChannel
3134
{
3235
static const char* name() { return EthOrange " cu"; }
3336
static const int verbosity = 2;
3437
static const bool debug = false;
3538
};
39+
3640
#define cudalog clog(CUDAChannel)
3741
#define ETHCUDA_LOG(_contents) cudalog << _contents
3842

@@ -44,26 +48,7 @@ CUDAMiner::CUDAMiner(FarmFace& _farm, unsigned _index) :
4448
CUDAMiner::~CUDAMiner()
4549
{
4650
stopWorking();
47-
pause();
48-
}
49-
50-
void CUDAMiner::report(uint64_t _nonce, const WorkPackage& w)
51-
{
52-
// FIXME: This code is exactly the same as in EthashGPUMiner.
53-
Result r = EthashAux::eval(w.seed, w.header, _nonce);
54-
if (r.value < w.boundary)
55-
farm.submitProof(Solution{_nonce, r.mixHash, w.header, w.seed, w.boundary, w.job, w.job_len, m_abort});
56-
else
57-
{
58-
farm.failedSolution();
59-
cwarn << "FAILURE: GPU gave incorrect result!";
60-
}
61-
}
62-
63-
void CUDAMiner::kickOff()
64-
{
65-
UniqueGuard l(x_all);
66-
m_aborted = m_abort = false;
51+
kick_miner();
6752
}
6853

6954
bool CUDAMiner::init(const h256& seed)
@@ -148,13 +133,10 @@ void CUDAMiner::workLoop()
148133
}
149134
}
150135

151-
void CUDAMiner::pause()
136+
void CUDAMiner::kick_miner()
152137
{
153-
UniqueGuard l(x_all);
154-
if (m_aborted)
155-
return;
156-
157-
m_abort = true;
138+
if (!m_abort)
139+
m_abort = true;
158140
}
159141

160142
void CUDAMiner::setNumInstances(unsigned _instances)
@@ -168,14 +150,6 @@ void CUDAMiner::setDevices(const unsigned* _devices, unsigned _selectedDeviceCou
168150
s_devices[i] = _devices[i];
169151
}
170152

171-
void CUDAMiner::waitPaused()
172-
{
173-
// m_abort is true so now searched()/found() will return true to abort the search.
174-
// we hang around on this thread waiting for them to point out that they have aborted since
175-
// otherwise we may end up deleting this object prior to searched()/found() being called.
176-
m_aborted.wait(true);
177-
}
178-
179153
unsigned CUDAMiner::getNumDevices()
180154
{
181155
int deviceCount = -1;
@@ -323,7 +297,15 @@ unsigned CUDAMiner::s_gridSize = CUDAMiner::c_defaultGridSize;
323297
unsigned CUDAMiner::s_numStreams = CUDAMiner::c_defaultNumStreams;
324298
unsigned CUDAMiner::s_scheduleFlag = 0;
325299

326-
bool CUDAMiner::cuda_init(size_t numDevices, ethash_light_t _light, uint8_t const* _lightData, uint64_t _lightSize, unsigned _deviceId, bool _cpyToHost, uint8_t* &hostDAG, unsigned dagCreateDevice)
300+
bool CUDAMiner::cuda_init(
301+
size_t numDevices,
302+
ethash_light_t _light,
303+
uint8_t const* _lightData,
304+
uint64_t _lightSize,
305+
unsigned _deviceId,
306+
bool _cpyToHost,
307+
uint8_t* &hostDAG,
308+
unsigned dagCreateDevice)
327309
{
328310
try
329311
{
@@ -450,7 +432,6 @@ void CUDAMiner::search(
450432
const dev::eth::WorkPackage& w)
451433
{
452434
bool initialize = false;
453-
bool exit = false;
454435
if (memcmp(&m_current_header, header, sizeof(hash32_t)))
455436
{
456437
m_current_header = *reinterpret_cast<hash32_t const *>(header);
@@ -493,13 +474,15 @@ void CUDAMiner::search(
493474
}
494475
}
495476
uint64_t batch_size = s_gridSize * s_blockSize;
496-
for (; !exit; m_current_index++, m_current_nonce += batch_size)
477+
while (true)
497478
{
479+
m_current_index++;
480+
m_current_nonce += batch_size;
498481
auto stream_index = m_current_index % s_numStreams;
499482
cudaStream_t stream = m_streams[stream_index];
500483
volatile uint32_t* buffer = m_search_buf[stream_index];
501484
uint32_t found_count = 0;
502-
uint64_t nonces[SEARCH_RESULT_BUFFER_SIZE - 1];
485+
uint64_t nonces[SEARCH_RESULT_BUFFER_SIZE];
503486
uint64_t nonce_base = m_current_nonce - s_numStreams * batch_size;
504487
if (m_current_index >= s_numStreams)
505488
{
@@ -509,17 +492,33 @@ void CUDAMiner::search(
509492
buffer[0] = 0;
510493
if (found_count > (SEARCH_RESULT_BUFFER_SIZE - 1))
511494
found_count = SEARCH_RESULT_BUFFER_SIZE - 1;
512-
for (unsigned int j = 0; j < found_count; j++)
513-
nonces[j] = nonce_base + buffer[j + 1];
495+
for (unsigned int j = 1; j <= found_count; j++)
496+
nonces[j] = nonce_base + buffer[j];
514497
}
515498
}
516499
run_ethash_search(s_gridSize, s_blockSize, m_sharedBytes, stream, buffer, m_current_nonce, m_parallelHash);
517500
if (m_current_index >= s_numStreams)
518501
{
519502
if (found_count)
520-
found(nonces, found_count, w);
521-
searched(batch_size);
522-
exit = cuda_shouldStop();
503+
{
504+
for (uint32_t i = 1; i <= found_count; i++)
505+
{
506+
Result r = EthashAux::eval(w.seed, w.header, nonces[i]);
507+
if (r.value < w.boundary)
508+
farm.submitProof(Solution{nonces[i], r.mixHash, w.header, w.seed, w.boundary, w.job, w.job_len, m_abort});
509+
else
510+
{
511+
farm.failedSolution();
512+
cwarn << "GPU gave incorrect result!";
513+
}
514+
}
515+
}
516+
addHashCount(batch_size);
517+
if (m_abort || shouldStop())
518+
{
519+
m_abort = false;
520+
break;
521+
}
523522
}
524523
}
525524
}

0 commit comments

Comments
 (0)