From a142e968d0dbd85c12a87bc388e7f139a1293998 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 26 Jun 2015 11:44:54 +0200 Subject: [PATCH] Greater timing scope. --- libethash-cl/ethash_cl_miner.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/libethash-cl/ethash_cl_miner.cpp b/libethash-cl/ethash_cl_miner.cpp index d8952d6db..bd268ec56 100644 --- a/libethash-cl/ethash_cl_miner.cpp +++ b/libethash-cl/ethash_cl_miner.cpp @@ -464,19 +464,6 @@ void ethash_cl_miner::search(uint8_t const* header, uint64_t target, search_hook // execute it! chrono::high_resolution_clock::time_point t = chrono::high_resolution_clock::now(); m_queue.enqueueNDRangeKernel(m_searchKernel, cl::NullRange, m_batchSize, m_workgroupSize); - chrono::high_resolution_clock::duration d = chrono::high_resolution_clock::now() - t; - if (d > chrono::milliseconds(_msPerBatch * 10 / 9)) - { - cerr << "Batch of" << m_batchSize << "took" << chrono::duration_cast(d).count() << "ms, >>" << _msPerBatch << "ms."; - m_batchSize = max(128, m_batchSize * 9 / 10); - cerr << "New batch size" << m_batchSize; - } - else if (d < chrono::milliseconds(_msPerBatch * 9 / 10)) - { - cerr << "Batch of" << m_batchSize << "took" << chrono::duration_cast(d).count() << "ms, <<" << _msPerBatch << "ms."; - m_batchSize = m_batchSize * 10 / 9; - cerr << "New batch size" << m_batchSize; - } pending.push({ start_nonce, buf }); buf = (buf + 1) % c_bufferCount; @@ -506,6 +493,20 @@ void ethash_cl_miner::search(uint8_t const* header, uint64_t target, search_hook pending.pop(); } + + chrono::high_resolution_clock::duration d = chrono::high_resolution_clock::now() - t; + if (d > chrono::milliseconds(_msPerBatch * 10 / 9)) + { + cerr << "Batch of" << m_batchSize << "took" << chrono::duration_cast(d).count() << "ms, >>" << _msPerBatch << "ms."; + m_batchSize = max(128, m_batchSize * 9 / 10); + cerr << "New batch size" << m_batchSize; + } + else if (d < chrono::milliseconds(_msPerBatch * 9 / 10)) + { + cerr << "Batch of" << m_batchSize << "took" << chrono::duration_cast(d).count() << "ms, <<" << _msPerBatch << "ms."; + m_batchSize = m_batchSize * 10 / 9; + cerr << "New batch size" << m_batchSize; + } } // not safe to return until this is ready