aboutsummaryrefslogtreecommitdiffstats
path: root/Godeps/_workspace/src/github.com/ethereum/ethash/libethash-cl/ethash_cl_miner.h
diff options
context:
space:
mode:
authorMatthew Wampler-Doty <matthew.wampler.doty@gmail.com>2015-03-01 03:58:37 +0800
committerMatthew Wampler-Doty <matthew.wampler.doty@gmail.com>2015-03-03 11:29:34 +0800
commitde9f79133faa1ff5dcd16fb4fd13d06b7799ded9 (patch)
treefcc9001d6b681ccdd1b3bbe516e3611e808341d7 /Godeps/_workspace/src/github.com/ethereum/ethash/libethash-cl/ethash_cl_miner.h
parent080823bdeebbab2bcffdaefad703896700ed2c30 (diff)
downloadgo-tangerine-de9f79133faa1ff5dcd16fb4fd13d06b7799ded9.tar.gz
go-tangerine-de9f79133faa1ff5dcd16fb4fd13d06b7799ded9.tar.zst
go-tangerine-de9f79133faa1ff5dcd16fb4fd13d06b7799ded9.zip
Introducing ethash
Diffstat (limited to 'Godeps/_workspace/src/github.com/ethereum/ethash/libethash-cl/ethash_cl_miner.h')
-rw-r--r--Godeps/_workspace/src/github.com/ethereum/ethash/libethash-cl/ethash_cl_miner.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/Godeps/_workspace/src/github.com/ethereum/ethash/libethash-cl/ethash_cl_miner.h b/Godeps/_workspace/src/github.com/ethereum/ethash/libethash-cl/ethash_cl_miner.h
new file mode 100644
index 000000000..f37100d91
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/ethereum/ethash/libethash-cl/ethash_cl_miner.h
@@ -0,0 +1,43 @@
+#pragma once
+
+#define __CL_ENABLE_EXCEPTIONS
+#define CL_USE_DEPRECATED_OPENCL_2_0_APIS
+#include "cl.hpp"
+#include <time.h>
+#include <libethash/ethash.h>
+
+class ethash_cl_miner
+{
+public:
+ struct search_hook
+ {
+ // 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:
+ ethash_cl_miner();
+
+ bool init(ethash_params const& params, const uint8_t seed[32], unsigned workgroup_size = 64);
+
+ 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);
+
+private:
+ static unsigned const c_max_search_results = 63;
+ static unsigned const c_num_buffers = 2;
+ static unsigned const c_hash_batch_size = 1024;
+ static unsigned const c_search_batch_size = 1024*256;
+
+ ethash_params m_params;
+ cl::Context m_context;
+ cl::CommandQueue m_queue;
+ cl::Kernel m_hash_kernel;
+ cl::Kernel m_search_kernel;
+ cl::Buffer m_dag;
+ cl::Buffer m_header;
+ cl::Buffer m_hash_buf[c_num_buffers];
+ cl::Buffer m_search_buf[c_num_buffers];
+ unsigned m_workgroup_size;
+}; \ No newline at end of file