|
|
@ -97,11 +97,11 @@ public: |
|
|
|
if ((arg == "-F" || arg == "--farm") && i + 1 < argc) |
|
|
|
{ |
|
|
|
mode = OperationMode::Farm; |
|
|
|
farmURL = argv[++i]; |
|
|
|
m_farmURL = argv[++i]; |
|
|
|
} |
|
|
|
else if (arg == "--farm-recheck" && i + 1 < argc) |
|
|
|
try { |
|
|
|
farmRecheckPeriod = stol(argv[++i]); |
|
|
|
m_farmRecheckPeriod = stol(argv[++i]); |
|
|
|
} |
|
|
|
catch (...) |
|
|
|
{ |
|
|
@ -110,7 +110,7 @@ public: |
|
|
|
} |
|
|
|
else if (arg == "--opencl-platform" && i + 1 < argc) |
|
|
|
try { |
|
|
|
openclPlatform = stol(argv[++i]); |
|
|
|
m_openclPlatform = stol(argv[++i]); |
|
|
|
} |
|
|
|
catch (...) |
|
|
|
{ |
|
|
@ -119,8 +119,8 @@ public: |
|
|
|
} |
|
|
|
else if (arg == "--opencl-device" && i + 1 < argc) |
|
|
|
try { |
|
|
|
openclDevice = stol(argv[++i]); |
|
|
|
miningThreads = 1; |
|
|
|
m_openclDevice = stol(argv[++i]); |
|
|
|
m_miningThreads = 1; |
|
|
|
} |
|
|
|
catch (...) |
|
|
|
{ |
|
|
@ -128,17 +128,16 @@ public: |
|
|
|
throw BadArgument(); |
|
|
|
} |
|
|
|
else if (arg == "--list-devices") |
|
|
|
{ |
|
|
|
ProofOfWork::GPUMiner::listDevices(); |
|
|
|
exit(0); |
|
|
|
} |
|
|
|
m_shouldListDevices = true; |
|
|
|
else if (arg == "--allow-opencl-cpu") |
|
|
|
m_clAllowCPU = true; |
|
|
|
else if (arg == "--phone-home" && i + 1 < argc) |
|
|
|
{ |
|
|
|
string m = argv[++i]; |
|
|
|
if (isTrue(m)) |
|
|
|
phoneHome = true; |
|
|
|
m_phoneHome = true; |
|
|
|
else if (isFalse(m)) |
|
|
|
phoneHome = false; |
|
|
|
m_phoneHome = false; |
|
|
|
else |
|
|
|
{ |
|
|
|
cerr << "Bad " << arg << " option: " << m << endl; |
|
|
@ -147,7 +146,7 @@ public: |
|
|
|
} |
|
|
|
else if (arg == "--benchmark-warmup" && i + 1 < argc) |
|
|
|
try { |
|
|
|
benchmarkWarmup = stol(argv[++i]); |
|
|
|
m_benchmarkWarmup = stol(argv[++i]); |
|
|
|
} |
|
|
|
catch (...) |
|
|
|
{ |
|
|
@ -156,7 +155,7 @@ public: |
|
|
|
} |
|
|
|
else if (arg == "--benchmark-trial" && i + 1 < argc) |
|
|
|
try { |
|
|
|
benchmarkTrial = stol(argv[++i]); |
|
|
|
m_benchmarkTrial = stol(argv[++i]); |
|
|
|
} |
|
|
|
catch (...) |
|
|
|
{ |
|
|
@ -165,7 +164,7 @@ public: |
|
|
|
} |
|
|
|
else if (arg == "--benchmark-trials" && i + 1 < argc) |
|
|
|
try { |
|
|
|
benchmarkTrials = stol(argv[++i]); |
|
|
|
m_benchmarkTrials = stol(argv[++i]); |
|
|
|
} |
|
|
|
catch (...) |
|
|
|
{ |
|
|
@ -175,21 +174,10 @@ public: |
|
|
|
else if (arg == "-C" || arg == "--cpu") |
|
|
|
m_minerType = MinerType::CPU; |
|
|
|
else if (arg == "-G" || arg == "--opencl") |
|
|
|
{ |
|
|
|
if (!ProofOfWork::GPUMiner::configureGPU()) |
|
|
|
{ |
|
|
|
cout << "No GPU device with sufficient memory was found. Defaulting to CPU" << endl; |
|
|
|
m_minerType = MinerType::CPU; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
m_minerType = MinerType::GPU; |
|
|
|
miningThreads = 1; |
|
|
|
} |
|
|
|
} |
|
|
|
m_minerType = MinerType::GPU; |
|
|
|
else if (arg == "--no-precompute") |
|
|
|
{ |
|
|
|
precompute = false; |
|
|
|
m_precompute = false; |
|
|
|
} |
|
|
|
else if ((arg == "-D" || arg == "--create-dag") && i + 1 < argc) |
|
|
|
{ |
|
|
@ -197,7 +185,7 @@ public: |
|
|
|
mode = OperationMode::DAGInit; |
|
|
|
try |
|
|
|
{ |
|
|
|
initDAG = stol(m); |
|
|
|
m_initDAG = stol(m); |
|
|
|
} |
|
|
|
catch (...) |
|
|
|
{ |
|
|
@ -247,7 +235,7 @@ public: |
|
|
|
else if ((arg == "-t" || arg == "--mining-threads") && i + 1 < argc) |
|
|
|
{ |
|
|
|
try { |
|
|
|
miningThreads = stol(argv[++i]); |
|
|
|
m_miningThreads = stol(argv[++i]); |
|
|
|
} |
|
|
|
catch (...) |
|
|
|
{ |
|
|
@ -262,20 +250,29 @@ public: |
|
|
|
|
|
|
|
void execute() |
|
|
|
{ |
|
|
|
if (m_shouldListDevices) |
|
|
|
{ |
|
|
|
ProofOfWork::GPUMiner::listDevices(); |
|
|
|
exit(0); |
|
|
|
} |
|
|
|
|
|
|
|
if (m_minerType == MinerType::CPU) |
|
|
|
ProofOfWork::CPUMiner::setNumInstances(miningThreads); |
|
|
|
ProofOfWork::CPUMiner::setNumInstances(m_miningThreads); |
|
|
|
else if (m_minerType == MinerType::GPU) |
|
|
|
{ |
|
|
|
ProofOfWork::GPUMiner::setDefaultPlatform(openclPlatform); |
|
|
|
ProofOfWork::GPUMiner::setDefaultDevice(openclDevice); |
|
|
|
ProofOfWork::GPUMiner::setNumInstances(miningThreads); |
|
|
|
ProofOfWork::GPUMiner::setNumInstances(m_miningThreads); |
|
|
|
if (!ProofOfWork::GPUMiner::configureGPU(m_openclPlatform, m_openclDevice, m_clAllowCPU)) |
|
|
|
{ |
|
|
|
cout << "No GPU device with sufficient memory was found. Can't GPU mine. Remove the -G argument" << endl; |
|
|
|
exit(1); |
|
|
|
} |
|
|
|
} |
|
|
|
if (mode == OperationMode::DAGInit) |
|
|
|
doInitDAG(initDAG); |
|
|
|
doInitDAG(m_initDAG); |
|
|
|
else if (mode == OperationMode::Benchmark) |
|
|
|
doBenchmark(m_minerType, phoneHome, benchmarkWarmup, benchmarkTrial, benchmarkTrials); |
|
|
|
doBenchmark(m_minerType, m_phoneHome, m_benchmarkWarmup, m_benchmarkTrial, m_benchmarkTrials); |
|
|
|
else if (mode == OperationMode::Farm) |
|
|
|
doFarm(m_minerType, farmURL, farmRecheckPeriod); |
|
|
|
doFarm(m_minerType, m_farmURL, m_farmRecheckPeriod); |
|
|
|
} |
|
|
|
|
|
|
|
static void streamHelp(ostream& _out) |
|
|
@ -441,7 +438,7 @@ private: |
|
|
|
cnote << "Grabbing DAG for" << newSeedHash; |
|
|
|
if (!(dag = EthashAux::full(newSeedHash, true, [&](unsigned _pc){ cout << "\rCreating DAG. " << _pc << "% done..." << flush; return 0; }))) |
|
|
|
BOOST_THROW_EXCEPTION(DAGCreationFailure()); |
|
|
|
if (precompute) |
|
|
|
if (m_precompute) |
|
|
|
EthashAux::computeFull(sha3(newSeedHash), true); |
|
|
|
if (hh != current.headerHash) |
|
|
|
{ |
|
|
@ -490,22 +487,23 @@ private: |
|
|
|
|
|
|
|
/// Mining options
|
|
|
|
MinerType m_minerType = MinerType::CPU; |
|
|
|
unsigned openclPlatform = 0; |
|
|
|
unsigned openclDevice = 0; |
|
|
|
unsigned miningThreads = UINT_MAX; |
|
|
|
unsigned dagChunks = 1; |
|
|
|
unsigned m_openclPlatform = 0; |
|
|
|
unsigned m_openclDevice = 0; |
|
|
|
unsigned m_miningThreads = UINT_MAX; |
|
|
|
bool m_shouldListDevices = false; |
|
|
|
bool m_clAllowCPU = false; |
|
|
|
|
|
|
|
/// DAG initialisation param.
|
|
|
|
unsigned initDAG = 0; |
|
|
|
unsigned m_initDAG = 0; |
|
|
|
|
|
|
|
/// Benchmarking params
|
|
|
|
bool phoneHome = true; |
|
|
|
unsigned benchmarkWarmup = 3; |
|
|
|
unsigned benchmarkTrial = 3; |
|
|
|
unsigned benchmarkTrials = 5; |
|
|
|
bool m_phoneHome = true; |
|
|
|
unsigned m_benchmarkWarmup = 3; |
|
|
|
unsigned m_benchmarkTrial = 3; |
|
|
|
unsigned m_benchmarkTrials = 5; |
|
|
|
|
|
|
|
/// Farm params
|
|
|
|
string farmURL = "http://127.0.0.1:8545"; |
|
|
|
unsigned farmRecheckPeriod = 500; |
|
|
|
bool precompute = true; |
|
|
|
string m_farmURL = "http://127.0.0.1:8545"; |
|
|
|
unsigned m_farmRecheckPeriod = 500; |
|
|
|
bool m_precompute = true; |
|
|
|
}; |
|
|
|