Browse Source

MH/s output

cl-refactor
Genoil 9 years ago
parent
commit
6107b5ddcc
  1. 28
      libethash-cl/ethash_cl_miner.cpp
  2. 4
      libethash-cl/ethash_cl_miner.h
  3. 5
      libethcore/Miner.h

28
libethash-cl/ethash_cl_miner.cpp

@ -376,7 +376,10 @@ bool ethash_cl_miner::init(
computeCapability = computeCapabilityMajor * 10 + computeCapabilityMinor;
int maxregs = computeCapability >= 35 ? 72 : 63;
sprintf(options, "-cl-nv-verbose -cl-nv-maxrregcount=%d", maxregs);// , computeCapability);
sprintf(options, "-cl-nv-maxrregcount=%d", maxregs);// , computeCapability);
}
else {
sprintf(options, "");
}
// create context
@ -399,10 +402,6 @@ bool ethash_cl_miner::init(
addDefinition(code, "PLATFORM", platformId);
addDefinition(code, "COMPUTE", computeCapability);
//debugf("%s", code.c_str());
// create miner OpenCL program
cl::Program::Sources sources;
sources.push_back({ code.c_str(), code.size() });
@ -439,6 +438,10 @@ bool ethash_cl_miner::init(
ETHCL_LOG("Creating buffer for header.");
m_header = cl::Buffer(m_context, CL_MEM_READ_ONLY, 32);
m_searchKernel.setArg(1, m_header);
m_searchKernel.setArg(2, m_dag);
m_searchKernel.setArg(5, ~0u);
// create mining buffers
for (unsigned i = 0; i != c_bufferCount; ++i)
{
@ -454,15 +457,16 @@ bool ethash_cl_miner::init(
return true;
}
typedef struct
{
uint64_t start_nonce;
unsigned buf;
} pending_batch;
void ethash_cl_miner::search(uint8_t const* header, uint64_t target, search_hook& hook)
{
try
{
struct pending_batch
{
uint64_t start_nonce;
unsigned buf;
};
queue<pending_batch> pending;
// this can't be a static because in MacOSX OpenCL implementation a segfault occurs when a static is passed to OpenCL functions
@ -481,12 +485,8 @@ void ethash_cl_miner::search(uint8_t const* header, uint64_t target, search_hook
#endif
m_queue.finish();
m_searchKernel.setArg(1, m_header);
m_searchKernel.setArg(2, m_dag );
// pass these to stop the compiler unrolling the loops
m_searchKernel.setArg(4, target);
m_searchKernel.setArg(5, ~0u);
unsigned buf = 0;
random_device engine;

4
libethash-cl/ethash_cl_miner.h

@ -6,10 +6,10 @@
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter"
#include "cl.hpp"
#include "CL/cl.hpp"
#pragma clang diagnostic pop
#else
#include "cl.hpp"
#include "CL/cl.hpp"
#endif
#include <time.h>

5
libethcore/Miner.h

@ -47,7 +47,10 @@ struct MineInfo: public WorkingProgress {};
inline std::ostream& operator<<(std::ostream& _out, WorkingProgress _p)
{
_out << _p.rate() << " H/s = " << _p.hashes << " hashes / " << (double(_p.ms) / 1000) << " s";
float mh = _p.rate() / 1000000.0f;
char mhs[16];
sprintf(mhs, "%.2f", mh);
_out << std::string(mhs) + "MH/s";
return _out;
}

Loading…
Cancel
Save