You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
2.3 KiB

9 years ago
/*
9 years ago
This file is part of cpp-ethereum.
9 years ago
9 years ago
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
9 years ago
9 years ago
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
9 years ago
9 years ago
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file EthashCUDAMiner.h
* @author Gav Wood <i@gavwood.com>
* @date 2014
*
* Determines the PoW algorithm.
9 years ago
*/
#pragma once
#if ETH_ETHASHCUDA
9 years ago
#include "libdevcore/Worker.h"
#include "EthashAux.h"
#include "Miner.h"
namespace dev
{
namespace eth
{
class EthashCUDAMiner : public GenericMiner<EthashProofOfWork>, Worker
9 years ago
{
friend class dev::eth::EthashCUDAHook;
9 years ago
public:
EthashCUDAMiner(ConstructionInfo const& _ci);
~EthashCUDAMiner();
9 years ago
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 _extraGPUMemory,
unsigned _scheduleFlag,
uint64_t _currentBlock,
unsigned _dagLoadMode,
unsigned _dagCreateDevice
);
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;
9 years ago
private:
void workLoop() override;
bool report(uint64_t _nonce);
9 years ago
using GenericMiner<EthashProofOfWork>::accumulateHashes;
9 years ago
EthashCUDAHook* m_hook = nullptr;
ethash_cuda_miner* m_miner = nullptr;
9 years ago
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];
};
}
9 years ago
}
#endif