Skip to content

Commit

Permalink
-added support for custom DAG directory
Browse files Browse the repository at this point in the history
  • Loading branch information
Genoil committed Feb 2, 2016
1 parent a15e962 commit 6e4dbaf
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 22 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Expand Up @@ -2,7 +2,7 @@
cmake_minimum_required(VERSION 2.8.12)

set(PROJECT_VERSION "0.9.41")
set(GENOIL_VERSION "1.0.2")
set(GENOIL_VERSION "1.0.3")
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()
Expand Down
43 changes: 29 additions & 14 deletions ethminer/MinerAux.h
Expand Up @@ -265,18 +265,13 @@ class MinerCLI
else if (arg == "-U" || arg == "--cuda")
{
m_minerType = MinerType::CUDA;

cout << "Genoil's CUDA ethminer " << ETH_PROJECT_VERSION << endl;
cout << "=====================================================================" << endl;
cout << "Forked from github.com/ethereum/cpp-ethereum" << endl;
cout << "Ported from Tim Hughes' OpenCL kernel" << endl;
cout << "With contributions from RoBiK, tpruvot and sp_ " << endl << endl;
cout << "Please consider a donation to:" << endl;
cout << "ETH: 0xeb9310b185455f863f526dab3d245809f6854b4d" << endl << endl;;

}
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 == "--no-precompute")
m_precompute = false;
else if ((arg == "-D" || arg == "--create-dag") && i + 1 < argc)
Expand Down Expand Up @@ -342,8 +337,13 @@ class MinerCLI
}
catch (...)
{
cerr << "Bad " << arg << " option: " << argv[i] << endl;
BOOST_THROW_EXCEPTION(BadArgument());
if (argv[i][0] == 45) { // check next arg
i--;
}
else {
cerr << "Bad " << arg << " option: " << argv[i] << endl;
BOOST_THROW_EXCEPTION(BadArgument());
}
}
}
}
Expand All @@ -358,8 +358,13 @@ class MinerCLI
}
catch (...)
{
cerr << "Bad " << arg << " option: " << argv[i] << endl;
BOOST_THROW_EXCEPTION(BadArgument());
if (argv[i][0] == 45) { // check next arg
i--;
}
else {
cerr << "Bad " << arg << " option: " << argv[i] << endl;
BOOST_THROW_EXCEPTION(BadArgument());
}
}
}
}
Expand Down Expand Up @@ -471,7 +476,7 @@ class MinerCLI
<< " --benchmark-trial <seconds> Set the duration for each trial for the benchmark tests (default: 3)." << endl
<< " --benchmark-trials <n> Set the duration of warmup for the benchmark tests (default: 5)." << endl
<< "Simulation mode:" << endl
<< " -S,--simulation Mining test mode. Used to validate kernel optimizations." << endl
<< " -S [<n>],--simulation [<n>] Mining test mode. Used to validate kernel optimizations. Optionally specify block number." << endl
#if ETH_JSONRPC || !ETH_TRUE
<< " --phone-home <on/off> When benchmarking, publish results (default: on)" << endl
#endif
Expand All @@ -487,6 +492,7 @@ class MinerCLI
<< " --allow-opencl-cpu Allows CPU to be considered as an OpenCL device if the OpenCL platform supports it." << endl
<< " --list-devices List the detected OpenCL/CUDA devices and exit." << endl
<< " --current-block Let the miner know the current block number at configuration time. Will help determine DAG size and required GPU memory." << endl
<< " -R <s>, --dag-dir <s> Store/Load DAG files in/from the specified directory. Useful for running multiple instances with different configurations." << endl
#if ETH_ETHASHCL || !ETH_TRUE
<< " --cl-extragpu-mem Set the memory (in MB) you believe your GPU requires for stuff other than mining. Windows rendering e.t.c.." << endl
<< " --cl-local-work Set the OpenCL local work size. Default is " << toString(ethash_cl_miner::c_defaultLocalWorkSize) << endl
Expand Down Expand Up @@ -521,6 +527,7 @@ class MinerCLI
private:
void doInitDAG(unsigned _n)
{
EthashAux::setCustomDirName(s_dagDir);
h256 seedHash = EthashAux::seedHash(_n);
cout << "Initializing DAG for epoch beginning #" << (_n / 30000 * 30000) << " (seedhash " << seedHash.abridged() << "). This will take a while." << endl;
EthashAux::full(seedHash, true);
Expand All @@ -529,6 +536,7 @@ class MinerCLI

void doBenchmark(MinerType _m, bool _phoneHome, unsigned _warmupDuration = 15, unsigned _trialDuration = 3, unsigned _trials = 5)
{
EthashAux::setCustomDirName(s_dagDir);
Ethash::BlockHeader genesis;
genesis.setNumber(m_benchmarkBlock);
genesis.setDifficulty(1 << 18);
Expand Down Expand Up @@ -613,6 +621,8 @@ class MinerCLI

void doSimulation(MinerType _m, int difficulty = 20)
{
EthashAux::setCustomDirName(s_dagDir);

Ethash::BlockHeader genesis;
genesis.setNumber(m_benchmarkBlock);
genesis.setDifficulty(1 << 18);
Expand Down Expand Up @@ -704,6 +714,8 @@ class MinerCLI

void doFarm(MinerType _m, string const& _remote, unsigned _recheckPeriod)
{
EthashAux::setCustomDirName(s_dagDir);

map<string, GenericFarm<EthashProofOfWork>::SealerDescriptor> sealers;
sealers["cpu"] = GenericFarm<EthashProofOfWork>::SealerDescriptor{&EthashCPUMiner::instances, [](GenericMiner<EthashProofOfWork>::ConstructionInfo ci){ return new EthashCPUMiner(ci); }};
#if ETH_ETHASHCL
Expand Down Expand Up @@ -838,6 +850,7 @@ class MinerCLI
unsigned m_cudaSchedule = 4; // sync
#endif
uint64_t m_currentBlock = 0;
static char s_dagDir[256];
// default value is 350MB of GPU memory for other stuff (windows system rendering, e.t.c.)
unsigned m_extraGPUMemory = 350000000;

Expand All @@ -855,3 +868,5 @@ class MinerCLI
unsigned m_farmRecheckPeriod = 500;
bool m_precompute = true;
};

char MinerCLI::s_dagDir[256] = "";
8 changes: 8 additions & 0 deletions ethminer/main.cpp
Expand Up @@ -68,6 +68,14 @@ void version()

int main(int argc, char** argv)
{
cout << "Genoil's ethminer " << ETH_PROJECT_VERSION << endl;
cout << "=====================================================================" << endl;
cout << "Forked from github.com/ethereum/cpp-ethereum" << endl;
cout << "CUDA kernel ported from Tim Hughes' OpenCL kernel" << endl;
cout << "With contributions from RoBiK, tpruvot and sp_ " << endl << endl;
cout << "Please consider a donation to:" << endl;
cout << "ETH: 0xeb9310b185455f863f526dab3d245809f6854b4d" << endl << endl;

MinerCLI m(MinerCLI::OperationMode::Farm);

for (int i = 1; i < argc; ++i)
Expand Down
2 changes: 1 addition & 1 deletion libethash/ethash.h
Expand Up @@ -108,7 +108,7 @@ ethash_return_value_t ethash_light_compute(
* @return Newly allocated ethash_full handler or NULL in case of
* ERRNOMEM or invalid parameters used for @ref ethash_compute_full_data()
*/
ethash_full_t ethash_full_new(ethash_light_t light, ethash_callback_t callback);
ethash_full_t ethash_full_new(ethash_light_t light, const char * custom_dir_name, ethash_callback_t callback);

/**
* Frees a previously allocated ethash_full handler
Expand Down
12 changes: 8 additions & 4 deletions libethash/internal.c
Expand Up @@ -455,12 +455,16 @@ ethash_full_t ethash_full_new_internal(
return NULL;
}

ethash_full_t ethash_full_new(ethash_light_t light, ethash_callback_t callback)
ethash_full_t ethash_full_new(ethash_light_t light, const char * custom_dir_name, ethash_callback_t callback)
{
char strbuf[256];
if (!ethash_get_default_dirname(strbuf, 256)) {
return NULL;
}

if (strcmp(custom_dir_name, "") != 0)
strcpy(strbuf, custom_dir_name);
else
if (!ethash_get_default_dirname(strbuf, 256)) {
return NULL;
}
uint64_t full_size = ethash_get_datasize(light->block_number);
ethash_h256_t seedhash = ethash_get_seedhash(light->block_number);
return ethash_full_new_internal(strbuf, seedhash, full_size, light, callback);
Expand Down
14 changes: 13 additions & 1 deletion libethcore/EthashAux.cpp
Expand Up @@ -43,6 +43,7 @@ using namespace eth;
const char* DAGChannel::name() { return EthGreen "DAG"; }

EthashAux* dev::eth::EthashAux::s_this = nullptr;
char dev::eth::EthashAux::s_customDirName[256] = "";

const unsigned EthashProofOfWork::defaultLocalWorkSize = 64;
const unsigned EthashProofOfWork::defaultGlobalWorkSizeMultiplier = 4096; // * CL_DEFAULT_LOCAL_WORK_SIZE
Expand Down Expand Up @@ -70,6 +71,17 @@ uint64_t EthashAux::dataSize(uint64_t _blockNumber)
return ethash_get_datasize(_blockNumber);
}


void EthashAux::setCustomDirName(const char * custom_dir_name)
{
strcpy(s_customDirName, custom_dir_name);
}

char * EthashAux::customDirName()
{
return s_customDirName;
}

h256 EthashAux::seedHash(unsigned _number)
{
unsigned epoch = _number / ETHASH_EPOCH_LENGTH;
Expand Down Expand Up @@ -152,7 +164,7 @@ bytesConstRef EthashAux::LightAllocation::data() const
EthashAux::FullAllocation::FullAllocation(ethash_light_t _light, ethash_callback_t _cb)
{
// cdebug << "About to call ethash_full_new...";
full = ethash_full_new(_light, _cb);
full = ethash_full_new(_light, EthashAux::customDirName(), _cb);
// cdebug << "Called OK.";
if (!full)
{
Expand Down
6 changes: 5 additions & 1 deletion libethcore/EthashAux.h
Expand Up @@ -109,7 +109,8 @@ class EthashAux
static uint64_t number(h256 const& _seedHash);
static uint64_t cacheSize(BlockInfo const& _header);
static uint64_t dataSize(uint64_t _blockNumber);

static void setCustomDirName(const char * custom_dir_name);
static char * customDirName();
static LightType light(h256 const& _seedHash);

static const uint64_t NotGenerating = (uint64_t)-1;
Expand All @@ -130,6 +131,7 @@ class EthashAux
void killCache(h256 const& _s);

static EthashAux* s_this;
static char s_customDirName[256];

SharedMutex x_lights;
std::unordered_map<h256, std::shared_ptr<LightAllocation>> m_lights;
Expand All @@ -145,6 +147,8 @@ class EthashAux
Mutex x_epochs;
std::unordered_map<h256, unsigned> m_epochs;
h256s m_seedHashes;


};

}
Expand Down
Binary file added releases/ethminer-0.9.41-genoil-1.0.3.zip
Binary file not shown.

0 comments on commit 6e4dbaf

Please sign in to comment.