Browse Source

Build fixes.

cl-refactor
Gav Wood 10 years ago
parent
commit
a0e8512bed
  1. 2
      libethash-cl/ethash_cl_miner.cpp
  2. 24
      libethcore/Ethash.cpp

2
libethash-cl/ethash_cl_miner.cpp

@ -466,7 +466,7 @@ void ethash_cl_miner::search(uint8_t const* header, uint64_t target, search_hook
m_queue.enqueueNDRangeKernel(m_searchKernel, cl::NullRange, m_batchSize, m_workgroupSize); m_queue.enqueueNDRangeKernel(m_searchKernel, cl::NullRange, m_batchSize, m_workgroupSize);
unsigned ms = t.elapsed() * 1000; unsigned ms = t.elapsed() * 1000;
if (ms > _msPerBatch * 1.1) if (ms > _msPerBatch * 1.1)
m_batchSize = max(128, m_batchSize * 9 / 10); m_batchSize = max<unsigned>(128, m_batchSize * 9 / 10);
else if (ms < _msPerBatch * 0.9) else if (ms < _msPerBatch * 0.9)
m_batchSize = m_batchSize * 10 / 9; m_batchSize = m_batchSize * 10 / 9;

24
libethcore/Ethash.cpp

@ -225,23 +225,26 @@ std::string Ethash::CPUMiner::platformInfo()
#if ETH_ETHASHCL || !ETH_TRUE #if ETH_ETHASHCL || !ETH_TRUE
using UniqueGuard = std::unique_lock<std::mutex>;
template <class N> template <class N>
class Notified class Notified
{ {
public: public:
Notified() {} Notified() {}
Notified(N const& _v): m_value(_v) {} Notified(N const& _v): m_value(_v) {}
Notified& operator=(N const& _v) { std::unique_lock l(m_mutex); m_value = _v; m_cv.notify_all(); return *this; } Notified(Notified const&) = delete;
Notified& operator=(N const& _v) { UniqueGuard l(m_mutex); m_value = _v; m_cv.notify_all(); return *this; }
operator N() const { std::unique_lock l(m_mutex); return m_value; } operator N() const { UniqueGuard l(m_mutex); return m_value; }
void wait() const { std::unique_lock l(m_mutex); m_cv.wait(l); } void wait() const { UniqueGuard l(m_mutex); m_cv.wait(l); }
void wait(N const& _v) const { std::unique_lock l(m_mutex); m_cv.wait(l, [&](){return m_value == _v;}); } void wait(N const& _v) const { UniqueGuard l(m_mutex); m_cv.wait(l, [&](){return m_value == _v;}); }
template <class F> void wait(F const& _f) const { std::unique_lock l(m_mutex); m_cv.wait(l, _f); } template <class F> void wait(F const& _f) const { UniqueGuard l(m_mutex); m_cv.wait(l, _f); }
private: private:
Mutex m_mutex; mutable Mutex m_mutex;
std::condition_variable m_cv; mutable std::condition_variable m_cv;
N m_value; N m_value;
}; };
@ -249,10 +252,11 @@ class EthashCLHook: public ethash_cl_miner::search_hook
{ {
public: public:
EthashCLHook(Ethash::GPUMiner* _owner): m_owner(_owner) {} EthashCLHook(Ethash::GPUMiner* _owner): m_owner(_owner) {}
EthashCLHook(EthashCLHook const&) = delete;
void abort() void abort()
{ {
std::unique_lock l(x_all); UniqueGuard l(x_all);
if (m_aborted) if (m_aborted)
return; return;
// cdebug << "Attempting to abort"; // cdebug << "Attempting to abort";
@ -270,7 +274,7 @@ public:
void reset() void reset()
{ {
Mutex l(x_all); UniqueGuard l(x_all);
m_aborted = m_abort = false; m_aborted = m_abort = false;
} }
@ -286,7 +290,7 @@ protected:
virtual bool searched(uint64_t _startNonce, uint32_t _count) override virtual bool searched(uint64_t _startNonce, uint32_t _count) override
{ {
Mutex l(x_all); UniqueGuard l(x_all);
// std::cerr << "Searched " << _count << " from " << _startNonce << std::endl; // std::cerr << "Searched " << _count << " from " << _startNonce << std::endl;
m_owner->accumulateHashes(_count); m_owner->accumulateHashes(_count);
m_last = _startNonce + _count; m_last = _startNonce + _count;

Loading…
Cancel
Save