Browse Source

style fixes; removed unused var

cl-refactor
Jan Willem Penterman 10 years ago
parent
commit
4adf0e5b1e
  1. 2
      ethminer/MinerAux.h
  2. 1
      libethash-cu/ethash_cu_miner.cpp
  3. 115
      libethcore/EthashCUDAMiner.cpp
  4. 92
      libethcore/EthashCUDAMiner.h

2
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;

1
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;

115
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<uint64_t>(_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<uint64_t>(_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<bool> 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<bool> 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<EthashProofOfWork>(_ci),
Worker("cudaminer" + toString(index())),
GenericMiner<EthashProofOfWork>(_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,

92
libethcore/EthashCUDAMiner.h

@ -30,57 +30,63 @@ along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
namespace dev
{
namespace eth
namespace eth
{
class EthashCUDAMiner : public GenericMiner<EthashProofOfWork>, Worker
{
friend class dev::eth::EthashCUHook;
class EthashCUDAMiner : public GenericMiner<EthashProofOfWork>, 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<unsigned>(_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<unsigned>(_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<EthashProofOfWork>::accumulateHashes;
private:
void workLoop() override;
bool report(uint64_t _nonce);
EthashCUHook* m_hook = nullptr;
ethash_cu_miner* m_miner = nullptr;
using GenericMiner<EthashProofOfWork>::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

Loading…
Cancel
Save