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.
74 lines
1.9 KiB
74 lines
1.9 KiB
10 years ago
|
#pragma once
|
||
|
|
||
10 years ago
|
//#include <cuda_runtime.h>
|
||
10 years ago
|
|
||
|
#include <time.h>
|
||
|
#include <functional>
|
||
|
#include <libethash/ethash.h>
|
||
10 years ago
|
#include "ethash_cuda_miner_kernel.h"
|
||
10 years ago
|
|
||
10 years ago
|
class ethash_cuda_miner
|
||
10 years ago
|
{
|
||
|
public:
|
||
|
struct search_hook
|
||
|
{
|
||
|
virtual ~search_hook(); // always a virtual destructor for a class with virtuals.
|
||
|
|
||
|
// reports progress, return true to abort
|
||
|
virtual bool found(uint64_t const* nonces, uint32_t count) = 0;
|
||
|
virtual bool searched(uint64_t start_nonce, uint32_t count) = 0;
|
||
|
};
|
||
|
|
||
|
public:
|
||
10 years ago
|
ethash_cuda_miner();
|
||
10 years ago
|
|
||
|
static std::string platform_info(unsigned _deviceId = 0);
|
||
10 years ago
|
static unsigned getNumDevices();
|
||
10 years ago
|
static void listDevices();
|
||
|
static bool configureGPU(
|
||
10 years ago
|
unsigned _blockSize,
|
||
|
unsigned _gridSize,
|
||
|
unsigned _numStreams,
|
||
10 years ago
|
unsigned _extraGPUMemory,
|
||
10 years ago
|
bool _highcpu,
|
||
10 years ago
|
uint64_t _currentBlock
|
||
|
);
|
||
10 years ago
|
bool init(
|
||
|
uint8_t const* _dag,
|
||
|
uint64_t _dagSize,
|
||
|
unsigned _deviceId = 0
|
||
|
);
|
||
10 years ago
|
void finish();
|
||
|
void search(uint8_t const* header, uint64_t target, search_hook& hook);
|
||
|
|
||
|
/* -- default values -- */
|
||
10 years ago
|
/// Default value of the block size. Also known as workgroup size.
|
||
|
static unsigned const c_defaultBlockSize;
|
||
|
/// Default value of the grid size
|
||
|
static unsigned const c_defaultGridSize;
|
||
|
// default number of CUDA streams
|
||
|
static unsigned const c_defaultNumStreams;
|
||
10 years ago
|
|
||
|
private:
|
||
|
enum { c_max_search_results = 63, c_hash_batch_size = 1024 };
|
||
|
|
||
|
hash128_t * m_dag_ptr;
|
||
|
hash32_t * m_header;
|
||
|
|
||
|
void ** m_hash_buf;
|
||
|
uint32_t ** m_search_buf;
|
||
|
cudaStream_t * m_streams;
|
||
|
|
||
10 years ago
|
/// The local work size for the search
|
||
|
static unsigned s_blockSize;
|
||
|
/// The initial global work size for the searches
|
||
|
static unsigned s_gridSize;
|
||
|
/// The number of CUDA streams
|
||
|
static unsigned s_numStreams;
|
||
|
/// Whether or not to let the CPU wait
|
||
|
static bool s_highCPU;
|
||
|
|
||
|
/// GPU memory required for other things, like window rendering e.t.c.
|
||
|
/// User can set it via the --cl-extragpu-mem argument.
|
||
|
static unsigned s_extraRequiredGPUMem;
|
||
10 years ago
|
};
|