From 83650be2139734148ab1fc9882ff9e5074ac17ba Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 13 May 2015 16:34:37 +0300 Subject: [PATCH] Fix GPU mining in ethminer. --- libethcore/Ethash.cpp | 8 +++++++- libethcore/EthashAux.cpp | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/libethcore/Ethash.cpp b/libethcore/Ethash.cpp index 1a8355fdf..80550886c 100644 --- a/libethcore/Ethash.cpp +++ b/libethcore/Ethash.cpp @@ -300,6 +300,7 @@ void Ethash::GPUMiner::workLoop() // take local copy of work since it may end up being overwritten by kickOff/pause. try { WorkPackage w = work(); + cnote << "workLoop" << !!m_miner << m_minerSeed << w.seedHash; if (!m_miner || m_minerSeed != w.seedHash) { m_minerSeed = w.seedHash; @@ -309,7 +310,12 @@ void Ethash::GPUMiner::workLoop() unsigned device = instances() > 1 ? index() : s_deviceId; - if (!EthashAux::computeFull(EthashAux::number(w.seedHash))) + while (EthashAux::computeFull(EthashAux::number(w.seedHash)) != 100 && !shouldStop()) + { + cnote << "Awaiting DAG" << EthashAux::computeFull(EthashAux::number(w.seedHash)); + this_thread::sleep_for(chrono::milliseconds(500)); + } + if (shouldStop()) return; EthashAux::FullType dag = EthashAux::full(EthashAux::number(w.seedHash)); bytesConstRef dagData = dag->data(); diff --git a/libethcore/EthashAux.cpp b/libethcore/EthashAux.cpp index f7a0ac41d..9287bcbfc 100644 --- a/libethcore/EthashAux.cpp +++ b/libethcore/EthashAux.cpp @@ -170,7 +170,9 @@ EthashAux::FullType EthashAux::full(uint64_t _blockNumber, function(l->light, dagCallbackShim); + cnote << "Done loading."; DEV_GUARDED(get()->x_fulls) get()->m_fulls[seedHash] = get()->m_lastUsedFull = ret; @@ -192,7 +194,9 @@ unsigned EthashAux::computeFull(uint64_t _blockNumber) get()->m_fullProgress = 0; get()->m_generatingFullNumber = _blockNumber / ETHASH_EPOCH_LENGTH * ETHASH_EPOCH_LENGTH; get()->m_fullGenerator = unique_ptr(new thread([=](){ + cnote << "Loading full DAG of" << _blockNumber; get()->full(_blockNumber, [](unsigned p){ get()->m_fullProgress = p; return 0; }); + cnote << "Full DAG loaded"; get()->m_fullProgress = 0; get()->m_generatingFullNumber = NotGenerating; }));