Browse Source

added --opencl-devices flag

fixed some stuff in CUDA device picking
cl-refactor
Genoil 9 years ago
parent
commit
600dfeecef
  1. 2
      CMakeLists.txt
  2. 32
      ethminer/MinerAux.h
  3. 4
      libethash-cuda/ethash_cuda_miner.cpp
  4. 3
      libethcore/EthashGPUMiner.cpp
  5. 8
      libethcore/EthashGPUMiner.h
  6. BIN
      releases/ethminer-0.9.41-genoil-1.0.6a.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.0.5")
set(GENOIL_VERSION "1.0.6")
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()

32
ethminer/MinerAux.h

@ -186,6 +186,19 @@ public:
cerr << "Bad " << arg << " option: " << argv[i] << endl;
BOOST_THROW_EXCEPTION(BadArgument());
}
else if (arg == "--opencl-devices")
while (m_openclDeviceCount < 16 && i + 1 < argc)
{
try
{
m_openclDevices[m_openclDeviceCount++] = stol(argv[++i]);
}
catch (...)
{
i--;
break;
}
}
#if ETH_ETHASHCL || ETH_ETHASHCUDA || !ETH_TRUE
else if ((arg == "--cl-global-work" || arg == "--cuda-grid-size") && i + 1 < argc)
try {
@ -434,6 +447,12 @@ public:
else if (m_minerType == MinerType::CL)
{
#if ETH_ETHASHCL || !ETH_TRUE
if (m_openclDeviceCount > 0)
{
EthashGPUMiner::setDevices(m_openclDevices, m_openclDeviceCount);
m_miningThreads = m_openclDeviceCount;
}
if (!EthashGPUMiner::configureGPU(
m_localWorkSize,
m_globalWorkSizeMultiplier,
@ -453,13 +472,11 @@ public:
else if (m_minerType == MinerType::CUDA)
{
#if ETH_ETHASHCUDA || !ETH_TRUE
if (m_cudaDeviceCount == 0)
if (m_cudaDeviceCount > 0)
{
m_cudaDevices[0] = 0;
m_cudaDeviceCount = 1;
}
EthashCUDAMiner::setDevices(m_cudaDevices, m_cudaDeviceCount);
m_miningThreads = m_cudaDeviceCount;
}
EthashCUDAMiner::setNumInstances(m_miningThreads);
if (!EthashCUDAMiner::configureGPU(
@ -510,7 +527,7 @@ public:
<< "Simulation mode:" << 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
<< " --phone-home <on/off> When benchmarking, publish results (default: off)" << endl
#endif
<< "DAG creation mode:" << endl
<< " -D,--create-dag <number> Create the DAG in preparation for mining on given block and exit." << endl
@ -520,6 +537,7 @@ public:
<< " -U,--cuda When mining use the GPU via CUDA." << endl
<< " --opencl-platform <n> When mining using -G/--opencl use OpenCL platform n (default: 0)." << endl
<< " --opencl-device <n> When mining using -G/--opencl use OpenCL device n (default: 0)." << endl
<< " --opencl-devices <0 1 ..n> Select which OpenCL devices to mine on. Default is to use all" << endl
<< " -t, --mining-threads <n> Limit number of CPU/GPU miners to n (default: use everything available on selected platform)" << endl
<< " --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
@ -540,7 +558,7 @@ public:
<< " spin - Instruct CUDA to actively spin when waiting for results from the device." << endl
<< " yield - Instruct CUDA to yield its thread when waiting for results from the device." << endl
<< " sync - Instruct CUDA to block the CPU thread on a synchronization primitive when waiting for the results from the device." << endl
<< " --cuda-devices <0 1 ..n> Select which GPUs to mine on. Default is to use all" << endl
<< " --cuda-devices <0 1 ..n> Select which CUDA GPUs to mine on. Default is to use all" << endl
#endif
;
}
@ -898,6 +916,8 @@ private:
bool m_shouldListDevices = false;
bool m_clAllowCPU = false;
#if ETH_ETHASHCL || !ETH_TRUE
unsigned m_openclDeviceCount = 0;
unsigned m_openclDevices[16];
#if !ETH_ETHASHCUDA || !ETH_TRUE
unsigned m_globalWorkSizeMultiplier = ethash_cl_miner::c_defaultGlobalWorkSizeMultiplier;
unsigned m_localWorkSize = ethash_cl_miner::c_defaultLocalWorkSize;

4
libethash-cuda/ethash_cuda_miner.cpp

@ -141,10 +141,12 @@ bool ethash_cuda_miner::configureGPU(
unsigned devicesCount = getNumDevices();
for (unsigned int i = 0; i < devicesCount; i++)
{
if (_devices[i] != -1)
{
int deviceId = min((int)devicesCount - 1, _devices[i]);
cudaDeviceProp props;
CUDA_SAFE_CALL(cudaGetDeviceProperties(&props, _devices[i]));
CUDA_SAFE_CALL(cudaGetDeviceProperties(&props, deviceId));
if (props.totalGlobalMem >= requiredSize)
{
ETHCUDA_LOG(

3
libethcore/EthashGPUMiner.cpp

@ -103,6 +103,7 @@ private:
unsigned EthashGPUMiner::s_platformId = 0;
unsigned EthashGPUMiner::s_deviceId = 0;
unsigned EthashGPUMiner::s_numInstances = 0;
int EthashGPUMiner::s_devices[16] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
EthashGPUMiner::EthashGPUMiner(ConstructionInfo const& _ci):
GenericMiner<EthashProofOfWork>(_ci),
@ -147,7 +148,7 @@ void EthashGPUMiner::workLoop()
delete m_miner;
m_miner = new ethash_cl_miner;
unsigned device = instances() > 1 ? index() : s_deviceId;
unsigned device = s_devices[index()] > -1 ? s_devices[index()] : index();
EthashAux::FullType dag;
while (true)

8
libethcore/EthashGPUMiner.h

@ -55,6 +55,13 @@ public:
uint64_t _currentBlock
);
static void setNumInstances(unsigned _instances) { s_numInstances = std::min<unsigned>(_instances, getNumDevices()); }
static void setDevices(unsigned * _devices, unsigned _selectedDeviceCount)
{
for (unsigned i = 0; i < _selectedDeviceCount; i++)
{
s_devices[i] = _devices[i];
}
}
protected:
void kickOff() override;
@ -73,6 +80,7 @@ private:
static unsigned s_platformId;
static unsigned s_deviceId;
static unsigned s_numInstances;
static int s_devices[16];
};
}

BIN
releases/ethminer-0.9.41-genoil-1.0.6a.zip

Binary file not shown.
Loading…
Cancel
Save