Browse Source

mixed AMD/Nvidia mining

cl-refactor
Genoil 9 years ago
parent
commit
9196115f23
  1. 2
      CMakeLists.txt
  2. 83
      ethminer/MinerAux.h
  3. 2
      libethash-cl/ethash_cl_miner.cpp
  4. 2
      libethash-cuda/ethash_cuda_miner_kernel.cu
  5. 2
      libethcore/EthashGPUMiner.cpp
  6. 2
      libethcore/EthashSealEngine.cpp
  7. 21
      libethcore/Farm.h
  8. 3
      libethcore/Miner.h
  9. 10
      libstratum/EthStratumClient.cpp
  10. 10
      libstratum/EthStratumClientV2.cpp
  11. BIN
      releases/ethminer-0.9.41-genoil-1.1.2.zip

2
CMakeLists.txt

@ -2,7 +2,7 @@
cmake_minimum_required(VERSION 2.8.12)
set(PROJECT_VERSION "0.9.41")
set(GENOIL_VERSION "1.1.1")
set(GENOIL_VERSION "1.1.2")
if (${CMAKE_VERSION} VERSION_GREATER 3.0)
cmake_policy(SET CMP0042 OLD) # fix MACOSX_RPATH
cmake_policy(SET CMP0048 NEW) # allow VERSION argument in project()

83
ethminer/MinerAux.h

@ -374,43 +374,12 @@ public:
{
m_minerType = MinerType::CUDA;
}
else if (arg == "--current-block" && i + 1 < argc)
m_currentBlock = stol(argv[++i]);
/*
else if ((arg == "-R" || arg == "--dag-dir") && i + 1 < argc)
{
strcpy(s_dagDir, argv[++i]);
}
else if ((arg == "-E" || arg == "--erase-dags") && i + 1 < argc)
{
string m = string(argv[++i]);
if (m == "none") m_eraseMode = DAGEraseMode::None;
else if (m == "old") m_eraseMode = DAGEraseMode::Old;
else if (m == "bench") m_eraseMode = DAGEraseMode::Bench;
else if (m == "all") m_eraseMode = DAGEraseMode::All;
else
{
cerr << "Bad " << arg << " option: " << argv[i] << endl;
BOOST_THROW_EXCEPTION(BadArgument());
}
}
else if (arg == "--no-precompute")
m_precompute = false;
else if ((arg == "-D" || arg == "--create-dag") && i + 1 < argc)
else if (arg == "-X" || arg == "--cuda-opencl")
{
string m = boost::to_lower_copy(string(argv[++i]));
mode = OperationMode::DAGInit;
try
{
m_initDAG = stol(m);
}
catch (...)
{
cerr << "Bad " << arg << " option: " << m << endl;
BOOST_THROW_EXCEPTION(BadArgument());
}
m_minerType = MinerType::Mixed;
}
*/
else if (arg == "--current-block" && i + 1 < argc)
m_currentBlock = stol(argv[++i]);
else if ((arg == "-w" || arg == "--check-pow") && i + 4 < argc)
{
string m;
@ -510,24 +479,14 @@ public:
void execute()
{
/*
EthashAux::setDAGDirName(s_dagDir);
EthashAux::setDAGEraseMode(m_eraseMode);
EthashAux::eraseDAGs();
if (m_eraseMode == DAGEraseMode::All)
{
m_eraseMode = DAGEraseMode::None;
}
*/
if (m_shouldListDevices)
{
#if ETH_ETHASHCL || !ETH_TRUE
if (m_minerType == MinerType::CL)
if (m_minerType == MinerType::CL || m_minerType == MinerType::Mixed)
EthashGPUMiner::listDevices();
#endif
#if ETH_ETHASHCUDA || !ETH_TRUE
if (m_minerType == MinerType::CUDA)
if (m_minerType == MinerType::CUDA || m_minerType == MinerType::Mixed)
EthashCUDAMiner::listDevices();
#endif
if (m_minerType == MinerType::CPU)
@ -537,7 +496,7 @@ public:
if (m_minerType == MinerType::CPU)
EthashCPUMiner::setNumInstances(m_miningThreads);
else if (m_minerType == MinerType::CL)
else if (m_minerType == MinerType::CL || m_minerType == MinerType::Mixed)
{
#if ETH_ETHASHCL || !ETH_TRUE
if (m_openclDeviceCount > 0)
@ -562,7 +521,7 @@ public:
exit(1);
#endif
}
else if (m_minerType == MinerType::CUDA)
else if (m_minerType == MinerType::CUDA || m_minerType == MinerType::Mixed)
{
#if ETH_ETHASHCUDA || !ETH_TRUE
if (m_cudaDeviceCount > 0)
@ -707,11 +666,11 @@ private:
genesis.setDifficulty(u256(1) << 63);
f.setWork(genesis);
if (_m == MinerType::CPU)
f.start("cpu");
f.start("cpu", false);
else if (_m == MinerType::CL)
f.start("opencl");
f.start("opencl", false);
else if (_m == MinerType::CUDA)
f.start("cuda");
f.start("cuda", false);
map<uint64_t, WorkingProgress> results;
uint64_t mean = 0;
@ -791,11 +750,11 @@ private:
f.setWork(genesis);
if (_m == MinerType::CPU)
f.start("cpu");
f.start("cpu", false);
else if (_m == MinerType::CL)
f.start("opencl");
f.start("opencl", false);
else if (_m == MinerType::CUDA)
f.start("cuda");
f.start("cuda", false);
int time = 0;
@ -817,13 +776,7 @@ private:
this_thread::sleep_for(chrono::milliseconds(1000));
time++;
}
//cnote << "Solution found";
cnote << "Difficulty:" << difficulty << " Nonce:" << solution.nonce.hex();
//cnote << " Mixhash:" << solution.mixHash.hex();
//cnote << " Header-hash:" << current.headerHash.hex();
//cnote << " Seedhash:" << current.seedHash.hex();
//cnote << " Target: " << h256(current.boundary).hex();
//cnote << " Ethash: " << h256(EthashAux::eval(current.seedHash, current.headerHash, solution.nonce).value).hex();
if (EthashAux::eval(current.seedHash, current.headerHash, solution.nonce).value < current.boundary)
{
cnote << "SUCCESS: GPU gave correct result!";
@ -880,11 +833,11 @@ private:
GenericFarm<EthashProofOfWork> f;
f.setSealers(sealers);
if (_m == MinerType::CPU)
f.start("cpu");
f.start("cpu", false);
else if (_m == MinerType::CL)
f.start("opencl");
f.start("opencl", false);
else if (_m == MinerType::CUDA)
f.start("cuda");
f.start("cuda", false);
EthashProofOfWork::WorkPackage current, previous;
boost::mutex x_current;
EthashAux::FullType dag;
@ -933,8 +886,6 @@ private:
current.seedHash = newSeedHash;
current.boundary = h256(fromHex(v[2].asString()), h256::AlignRight);
minelog << "Got work package: #" + current.headerHash.hex().substr(0,8);
//minelog << " Seedhash:" << current.seedHash.hex();
//minelog << " Target: " << h256(current.boundary).hex();
f.setWork(current);
x_current.unlock();
}

2
libethash-cl/ethash_cl_miner.cpp

@ -485,7 +485,7 @@ bool ethash_cl_miner::init(
m_dagKernel.setArg(0, i * m_globalWorkSize);
m_queue.enqueueNDRangeKernel(m_dagKernel, cl::NullRange, m_globalWorkSize, s_workgroupSize);
m_queue.finish();
printf("%.0f%%\n", 100.0f * (float)i / (float)fullRuns);
printf("OPENCL#%d: %.0f%%\n", _deviceId, 100.0f * (float)i / (float)fullRuns);
}
}

2
libethash-cuda/ethash_cuda_miner_kernel.cu

@ -127,7 +127,7 @@ void ethash_generate_dag(
{
ethash_calculate_dag_item <<<blocks, threads, 0, stream >>>(i * blocks * threads);
CUDA_SAFE_CALL(cudaDeviceSynchronize());
printf("GPU#%d %.0f%%\r",device, 100.0f * (float)i / (float)fullRuns);
printf("CUDA#%d: %.0f%%\n",device, 100.0f * (float)i / (float)fullRuns);
}
//printf("GPU#%d 100%%\n");
CUDA_SAFE_CALL(cudaGetLastError());

2
libethcore/EthashGPUMiner.cpp

@ -107,7 +107,7 @@ int EthashGPUMiner::s_devices[16] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
EthashGPUMiner::EthashGPUMiner(ConstructionInfo const& _ci):
GenericMiner<EthashProofOfWork>(_ci),
Worker("gpuminer" + toString(index())),
Worker("openclminer" + toString(index())),
m_hook(new EthashCLHook(this))
{
}

2
libethcore/EthashSealEngine.cpp

@ -59,7 +59,7 @@ void EthashSealEngine::generateSeal(BlockInfo const& _bi)
{
m_sealing = Ethash::BlockHeader(_bi);
m_farm.setWork(m_sealing);
m_farm.start(m_sealer);
m_farm.start(m_sealer, false);
m_farm.setWork(m_sealing); // TODO: take out one before or one after...
bytes shouldPrecompute = option("precomputeDAG");
if (!shouldPrecompute.empty() && shouldPrecompute[0] == 1)

21
libethcore/Farm.h

@ -80,7 +80,7 @@ public:
/**
* @brief Start a number of miners.
*/
bool start(std::string const& _sealer)
bool start(std::string const& _sealer, bool mixed)
{
WriteGuard l(x_minerWork);
if (!m_miners.empty() && m_lastSealer == _sealer)
@ -88,10 +88,23 @@ public:
if (!m_sealers.count(_sealer))
return false;
m_miners.clear();
if (!mixed)
{
m_miners.clear();
}
auto ins = m_sealers[_sealer].instances();
m_miners.reserve(ins);
for (unsigned i = 0; i < ins; ++i)
unsigned start = 0;
if (!mixed)
{
m_miners.reserve(ins);
}
else
{
start = m_miners.size();
ins += start;
m_miners.reserve(ins);
}
for (unsigned i = start; i < ins; ++i)
{
m_miners.push_back(std::shared_ptr<Miner>(m_sealers[_sealer].create(std::make_pair(this, i))));
m_miners.back()->setWork(m_work);

3
libethcore/Miner.h

@ -54,7 +54,8 @@ enum class MinerType
{
CPU,
CL,
CUDA
CUDA,
Mixed
};
struct MineInfo: public WorkingProgress {};

10
libstratum/EthStratumClient.cpp

@ -144,11 +144,15 @@ void EthStratumClient::connect_handler(const boost::system::error_code& ec, tcp:
{
cnote << "Starting farm";
if (m_minerType == MinerType::CPU)
p_farm->start("cpu");
p_farm->start("cpu", false);
else if (m_minerType == MinerType::CL)
p_farm->start("opencl");
p_farm->start("opencl", false);
else if (m_minerType == MinerType::CUDA)
p_farm->start("cuda");
p_farm->start("cuda", false);
else if (m_minerType == MinerType::Mixed) {
p_farm->start("cuda", false);
p_farm->start("opencl", true);
}
}
std::ostream os(&m_requestBuffer);
os << "{\"id\": 1, \"method\": \"mining.subscribe\", \"params\": []}\n";

10
libstratum/EthStratumClientV2.cpp

@ -116,11 +116,15 @@ void EthStratumClientV2::connect()
{
cnote << "Starting farm";
if (m_minerType == MinerType::CPU)
p_farm->start("cpu");
p_farm->start("cpu", false);
else if (m_minerType == MinerType::CL)
p_farm->start("opencl");
p_farm->start("opencl", false);
else if (m_minerType == MinerType::CUDA)
p_farm->start("cuda");
p_farm->start("cuda", false);
else if (m_minerType == MinerType::Mixed) {
p_farm->start("cuda", false);
p_farm->start("opencl", true);
}
}
std::ostream os(&m_requestBuffer);
os << "{\"id\": 1, \"method\": \"mining.subscribe\", \"params\": []}\n";

BIN
releases/ethminer-0.9.41-genoil-1.1.2.zip

Binary file not shown.
Loading…
Cancel
Save