diff --git a/libethash-cl/ethash_cl_miner.cpp b/libethash-cl/ethash_cl_miner.cpp index 111f92529..42098e09d 100644 --- a/libethash-cl/ethash_cl_miner.cpp +++ b/libethash-cl/ethash_cl_miner.cpp @@ -88,6 +88,13 @@ std::string ethash_cl_miner::platform_info(unsigned _platformId, unsigned _devic return "{ \"platform\": \"" + platforms[platform_num].getInfo() + "\", \"device\": \"" + device.getInfo() + "\", \"version\": \"" + device_version + "\" }"; } +unsigned ethash_cl_miner::get_num_platforms() +{ + std::vector platforms; + cl::Platform::get(&platforms); + return platforms.size(); +} + unsigned ethash_cl_miner::get_num_devices(unsigned _platformId) { std::vector platforms; @@ -117,14 +124,11 @@ void ethash_cl_miner::finish() } } -bool ethash_cl_miner::init(ethash_params const& params, std::function _fillDAG, unsigned workgroup_size, unsigned _platformId, unsigned _deviceId) +bool ethash_cl_miner::init(uint8_t const* _dag, uint64_t _dagSize, unsigned workgroup_size, unsigned _platformId, unsigned _deviceId) { - // store params - m_params = params; - // get all platforms - std::vector platforms; - cl::Platform::get(&platforms); + std::vector platforms; + cl::Platform::get(&platforms); if (platforms.empty()) { cout << "No OpenCL platforms found." << endl; @@ -137,10 +141,10 @@ bool ethash_cl_miner::init(ethash_params const& params, std::function().c_str() << endl; - // get GPU device of the default platform - std::vector devices; + // get GPU device of the default platform + std::vector devices; platforms[_platformId].getDevices(CL_DEVICE_TYPE_ALL, &devices); - if (devices.empty()) + if (devices.empty()) { cout << "No OpenCL devices found." << endl; return false; @@ -171,7 +175,7 @@ bool ethash_cl_miner::init(ethash_params const& params, std::function _fillDAG, unsigned workgroup_size = 64, unsigned _platformId = 0, unsigned _deviceId = 0); - static std::string platform_info(unsigned _platformId = 0, unsigned _deviceId = 0); + static unsigned get_num_platforms(); static unsigned get_num_devices(unsigned _platformId = 0); + static std::string platform_info(unsigned _platformId = 0, unsigned _deviceId = 0); - + bool init(uint8_t const* _dag, uint64_t _dagSize, unsigned workgroup_size = 64, unsigned _platformId = 0, unsigned _deviceId = 0); void finish(); void hash(uint8_t* ret, uint8_t const* header, uint64_t nonce, unsigned count); void search(uint8_t const* header, uint64_t target, search_hook& hook); @@ -43,7 +43,6 @@ public: private: enum { c_max_search_results = 63, c_num_buffers = 2, c_hash_batch_size = 1024, c_search_batch_size = 1024*256 }; - ethash_params m_params; cl::Context m_context; cl::CommandQueue m_queue; cl::Kernel m_hash_kernel; diff --git a/libethcore/Ethash.cpp b/libethcore/Ethash.cpp index e932fced4..011f0b9e0 100644 --- a/libethcore/Ethash.cpp +++ b/libethcore/Ethash.cpp @@ -309,10 +309,10 @@ void Ethash::GPUMiner::workLoop() delete m_miner; m_miner = new ethash_cl_miner; - auto p = EthashAux::params(m_minerSeed); - auto cb = [&](void* d) { EthashAux::full(m_minerSeed, bytesRef((byte*)d, p.full_size)); }; unsigned device = instances() > 1 ? index() : s_deviceId; - m_miner->init(p, cb, 32, s_platformId, device); + + EthashAux::FullType dag = EthashAux::full(m_minerSeed); + m_miner->init(dag->data.data(), dag->data.size(), 32, s_platformId, device); } uint64_t upper64OfBoundary = (uint64_t)(u64)((u256)w.boundary >> 192); diff --git a/libethcore/EthashAux.cpp b/libethcore/EthashAux.cpp index ad7dfe53b..0b9af98ac 100644 --- a/libethcore/EthashAux.cpp +++ b/libethcore/EthashAux.cpp @@ -133,7 +133,6 @@ EthashAux::LightAllocation::~LightAllocation() ethash_delete_light(light); } - EthashAux::FullType EthashAux::full(BlockInfo const& _header, bytesRef _dest, bool _createIfMissing) { return full(_header.seedHash(), _dest, _createIfMissing);