From 4adf0e5b1e39a24c0e80d1ae66132bad995a7cd0 Mon Sep 17 00:00:00 2001 From: Jan Willem Penterman Date: Thu, 27 Aug 2015 14:35:46 +0200 Subject: [PATCH] style fixes; removed unused var --- ethminer/MinerAux.h | 2 +- libethash-cu/ethash_cu_miner.cpp | 1 - libethcore/EthashCUDAMiner.cpp | 115 +++++++++++++++---------------- libethcore/EthashCUDAMiner.h | 92 +++++++++++++------------ 4 files changed, 105 insertions(+), 105 deletions(-) diff --git a/ethminer/MinerAux.h b/ethminer/MinerAux.h index e1debead4..4094d49da 100644 --- a/ethminer/MinerAux.h +++ b/ethminer/MinerAux.h @@ -491,7 +491,7 @@ private: f.setSealers(sealers); f.onSolutionFound([&](EthashProofOfWork::Solution) { return false; }); - string platformInfo = _m == MinerType::CPU ? "CPU" : (_m == MinerType::CL ? "GPU" : "CUDA"); + string platformInfo = _m == MinerType::CPU ? "CPU" : (_m == MinerType::CL ? "CL" : "CUDA"); cout << "Benchmarking on platform: " << platformInfo << endl; cout << "Preparing DAG..." << endl; diff --git a/libethash-cu/ethash_cu_miner.cpp b/libethash-cu/ethash_cu_miner.cpp index a5b68b87f..a6c2d9dcb 100644 --- a/libethash-cu/ethash_cu_miner.cpp +++ b/libethash-cu/ethash_cu_miner.cpp @@ -177,7 +177,6 @@ bool ethash_cu_miner::s_highCPU = false; void ethash_cu_miner::listDevices() { string outString = "\nListing CUDA devices.\nFORMAT: [deviceID] deviceName\n"; - unsigned int i = 0; for (unsigned int i = 0; i < getNumDevices(); i++) { cudaDeviceProp props; diff --git a/libethcore/EthashCUDAMiner.cpp b/libethcore/EthashCUDAMiner.cpp index 2282e9a77..edc98919d 100644 --- a/libethcore/EthashCUDAMiner.cpp +++ b/libethcore/EthashCUDAMiner.cpp @@ -33,71 +33,69 @@ using namespace eth; namespace dev { - namespace eth +namespace eth +{ + class EthashCUHook : public ethash_cu_miner::search_hook { + public: + EthashCUHook(EthashCUDAMiner* _owner) : m_owner(_owner) {} + EthashCUHook(EthashCUHook const&) = delete; - class EthashCUHook : public ethash_cu_miner::search_hook + void abort() { - public: - EthashCUHook(EthashCUDAMiner* _owner) : m_owner(_owner) {} - EthashCUHook(EthashCUHook const&) = delete; - - void abort() - { - { - UniqueGuard l(x_all); - if (m_aborted) - return; - // cdebug << "Attempting to abort"; - - m_abort = true; - } - // m_abort is true so now searched()/found() will return true to abort the search. - // we hang around on this thread waiting for them to point out that they have aborted since - // otherwise we may end up deleting this object prior to searched()/found() being called. - m_aborted.wait(true); - // for (unsigned timeout = 0; timeout < 100 && !m_aborted; ++timeout) - // std::this_thread::sleep_for(chrono::milliseconds(30)); - // if (!m_aborted) - // cwarn << "Couldn't abort. Abandoning OpenCL process."; - } - - void reset() { UniqueGuard l(x_all); - m_aborted = m_abort = false; - } + if (m_aborted) + return; + // cdebug << "Attempting to abort"; - protected: - virtual bool found(uint64_t const* _nonces, uint32_t _count) override - { - // dev::operator <<(std::cerr << "Found nonces: ", vector(_nonces, _nonces + _count)) << std::endl; - for (uint32_t i = 0; i < _count; ++i) - if (m_owner->report(_nonces[i])) - return (m_aborted = true); - return m_owner->shouldStop(); + m_abort = true; } + // m_abort is true so now searched()/found() will return true to abort the search. + // we hang around on this thread waiting for them to point out that they have aborted since + // otherwise we may end up deleting this object prior to searched()/found() being called. + m_aborted.wait(true); + // for (unsigned timeout = 0; timeout < 100 && !m_aborted; ++timeout) + // std::this_thread::sleep_for(chrono::milliseconds(30)); + // if (!m_aborted) + // cwarn << "Couldn't abort. Abandoning OpenCL process."; + } - virtual bool searched(uint64_t _startNonce, uint32_t _count) override - { - UniqueGuard l(x_all); - // std::cerr << "Searched " << _count << " from " << _startNonce << std::endl; - m_owner->accumulateHashes(_count); - m_last = _startNonce + _count; - if (m_abort || m_owner->shouldStop()) + void reset() + { + UniqueGuard l(x_all); + m_aborted = m_abort = false; + } + + protected: + virtual bool found(uint64_t const* _nonces, uint32_t _count) override + { + // dev::operator <<(std::cerr << "Found nonces: ", vector(_nonces, _nonces + _count)) << std::endl; + for (uint32_t i = 0; i < _count; ++i) + if (m_owner->report(_nonces[i])) return (m_aborted = true); - return false; - } + return m_owner->shouldStop(); + } - private: - Mutex x_all; - uint64_t m_last; - bool m_abort = false; - Notified m_aborted = { true }; - EthashCUDAMiner* m_owner = nullptr; - }; + virtual bool searched(uint64_t _startNonce, uint32_t _count) override + { + UniqueGuard l(x_all); + // std::cerr << "Searched " << _count << " from " << _startNonce << std::endl; + m_owner->accumulateHashes(_count); + m_last = _startNonce + _count; + if (m_abort || m_owner->shouldStop()) + return (m_aborted = true); + return false; + } - } + private: + Mutex x_all; + uint64_t m_last; + bool m_abort = false; + Notified m_aborted = { true }; + EthashCUDAMiner* m_owner = nullptr; + }; +} } unsigned EthashCUDAMiner::s_platformId = 0; @@ -105,10 +103,9 @@ unsigned EthashCUDAMiner::s_deviceId = 0; unsigned EthashCUDAMiner::s_numInstances = 0; int EthashCUDAMiner::s_devices[16] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; - EthashCUDAMiner::EthashCUDAMiner(ConstructionInfo const& _ci) : -GenericMiner(_ci), -Worker("cudaminer" + toString(index())), + GenericMiner(_ci), + Worker("cudaminer" + toString(index())), m_hook( new EthashCUHook(this)) { } @@ -207,18 +204,16 @@ bool EthashCUDAMiner::configureGPU( unsigned _numStreams, unsigned _deviceId, unsigned _extraGPUMemory, - bool _highcpu, + bool _highcpu, uint64_t _currentBlock ) { s_deviceId = _deviceId; - if (_blockSize != 32 && _blockSize != 64 && _blockSize != 128) { cout << "Given localWorkSize of " << toString(_blockSize) << "is invalid. Must be either 32,64 or 128" << endl; return false; } - if (!ethash_cu_miner::configureGPU( _blockSize, _gridSize, diff --git a/libethcore/EthashCUDAMiner.h b/libethcore/EthashCUDAMiner.h index 6fed08716..d10f70c93 100644 --- a/libethcore/EthashCUDAMiner.h +++ b/libethcore/EthashCUDAMiner.h @@ -30,57 +30,63 @@ along with cpp-ethereum. If not, see . namespace dev { - namespace eth +namespace eth +{ + class EthashCUDAMiner : public GenericMiner, Worker { + friend class dev::eth::EthashCUHook; - class EthashCUDAMiner : public GenericMiner, Worker - { - friend class dev::eth::EthashCUHook; - - public: - EthashCUDAMiner(ConstructionInfo const& _ci); - ~EthashCUDAMiner(); + public: + EthashCUDAMiner(ConstructionInfo const& _ci); + ~EthashCUDAMiner(); - static unsigned instances() { return s_numInstances > 0 ? s_numInstances : 1; } - static std::string platformInfo(); - static unsigned getNumDevices(); - static void listDevices(); - static bool configureGPU( - unsigned _blockSize, - unsigned _gridSize, - unsigned _numStreams, - unsigned _deviceId, - unsigned _extraGPUMemory, - bool _highcpu, - uint64_t _currentBlock - ); - static void setNumInstances(unsigned _instances) { s_numInstances = std::min(_instances, getNumDevices()); } - static void setDevices(unsigned * _devices, unsigned _selectedDeviceCount) { - for (unsigned i = 0; i < _selectedDeviceCount; i++) { - s_devices[i] = _devices[i]; - } + static unsigned instances() + { + return s_numInstances > 0 ? s_numInstances : 1; + } + static std::string platformInfo(); + static unsigned getNumDevices(); + static void listDevices(); + static bool configureGPU( + unsigned _blockSize, + unsigned _gridSize, + unsigned _numStreams, + unsigned _deviceId, + unsigned _extraGPUMemory, + bool _highcpu, + uint64_t _currentBlock + ); + static void setNumInstances(unsigned _instances) + { + s_numInstances = std::min(_instances, getNumDevices()); + } + static void setDevices(unsigned * _devices, unsigned _selectedDeviceCount) + { + for (unsigned i = 0; i < _selectedDeviceCount; i++) + { + s_devices[i] = _devices[i]; } - protected: - void kickOff() override; - void pause() override; - - private: - void workLoop() override; - bool report(uint64_t _nonce); + } + protected: + void kickOff() override; + void pause() override; - using GenericMiner::accumulateHashes; + private: + void workLoop() override; + bool report(uint64_t _nonce); - EthashCUHook* m_hook = nullptr; - ethash_cu_miner* m_miner = nullptr; + using GenericMiner::accumulateHashes; - h256 m_minerSeed; ///< Last seed in m_miner - static unsigned s_platformId; - static unsigned s_deviceId; - static unsigned s_numInstances; - static int s_devices[16]; - }; + EthashCUHook* m_hook = nullptr; + ethash_cu_miner* m_miner = nullptr; - } + h256 m_minerSeed; ///< Last seed in m_miner + static unsigned s_platformId; + static unsigned s_deviceId; + static unsigned s_numInstances; + static int s_devices[16]; + }; +} } #endif