Browse Source

Merge pull request #65 from ethereum-mining/opencl-cleanups

OpenCL cleanups
cl-refactor
Paweł Bylica 8 years ago
committed by GitHub
parent
commit
7b678d8a45
  1. 7
      ethminer/MinerAux.h
  2. 27
      libethash-cl/ethash_cl_miner.cpp
  3. 9
      libethash-cl/ethash_cl_miner.h
  4. 2
      libethcore/EthashGPUMiner.cpp
  5. 1
      libethcore/EthashGPUMiner.h

7
ethminer/MinerAux.h

@ -288,10 +288,6 @@ public:
else if ((arg == "--cl-extragpu-mem" || arg == "--cuda-extragpu-mem") && i + 1 < argc)
m_extraGPUMemory = 1000000 * stol(argv[++i]);
#endif
#if ETH_ETHASHCL
else if (arg == "--allow-opencl-cpu")
m_clAllowCPU = true;
#endif
#if ETH_ETHASHCUDA
else if (arg == "--cuda-devices")
{
@ -492,7 +488,6 @@ public:
m_globalWorkSizeMultiplier,
m_openclPlatform,
m_openclDevice,
m_clAllowCPU,
m_extraGPUMemory,
0,
m_dagLoadMode,
@ -584,7 +579,6 @@ public:
<< " --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. Should be combined with -G or -U flag" << endl
<< " -L, --dag-load-mode <mode> DAG generation mode." << endl
<< " parallel - load DAG on all GPUs at the same time (default)" << endl
@ -1030,7 +1024,6 @@ private:
unsigned m_openclDevice = 0;
unsigned m_miningThreads = UINT_MAX;
bool m_shouldListDevices = false;
bool m_clAllowCPU = false;
#if ETH_ETHASHCL
unsigned m_openclDeviceCount = 0;
unsigned m_openclDevices[16];

27
libethash-cl/ethash_cl_miner.cpp

@ -84,8 +84,6 @@ static std::atomic_flag s_logSpin = ATOMIC_FLAG_INIT;
#else
#define ETHCL_LOG(_contents) cout << "[OPENCL]:" << _contents << endl
#endif
// Types of OpenCL devices we are interested in
#define ETHCL_QUERIED_DEVICE_TYPES (CL_DEVICE_TYPE_GPU | CL_DEVICE_TYPE_ACCELERATOR)
static void addDefinition(string& _source, char const* _id, unsigned _value)
{
@ -154,7 +152,7 @@ std::vector<cl::Device> ethash_cl_miner::getDevices(std::vector<cl::Platform> co
try
{
_platforms[platform_num].getDevices(
s_allowCPU ? CL_DEVICE_TYPE_ALL : ETHCL_QUERIED_DEVICE_TYPES,
CL_DEVICE_TYPE_GPU | CL_DEVICE_TYPE_ACCELERATOR,
&devices
);
}
@ -167,14 +165,6 @@ std::vector<cl::Device> ethash_cl_miner::getDevices(std::vector<cl::Platform> co
return devices;
}
unsigned ethash_cl_miner::getNumPlatforms()
{
vector<cl::Platform> platforms = getPlatforms();
if (platforms.empty())
return 0;
return platforms.size();
}
unsigned ethash_cl_miner::getNumDevices(unsigned _platformId)
{
vector<cl::Platform> platforms = getPlatforms();
@ -194,14 +184,12 @@ bool ethash_cl_miner::configureGPU(
unsigned _platformId,
unsigned _localWorkSize,
unsigned _globalWorkSize,
bool _allowCPU,
unsigned _extraGPUMemory,
uint64_t _currentBlock
)
{
s_workgroupSize = _localWorkSize;
s_initialGlobalWorkSize = _globalWorkSize;
s_allowCPU = _allowCPU;
s_extraRequiredGPUMem = _extraGPUMemory;
// by default let's only consider the DAG of the first epoch
@ -230,23 +218,10 @@ bool ethash_cl_miner::configureGPU(
);
}
bool ethash_cl_miner::s_allowCPU = false;
unsigned ethash_cl_miner::s_extraRequiredGPUMem;
unsigned ethash_cl_miner::s_workgroupSize = ethash_cl_miner::c_defaultLocalWorkSize;
unsigned ethash_cl_miner::s_initialGlobalWorkSize = ethash_cl_miner::c_defaultGlobalWorkSizeMultiplier * ethash_cl_miner::c_defaultLocalWorkSize;
bool ethash_cl_miner::searchForAllDevices(function<bool(cl::Device const&)> _callback)
{
vector<cl::Platform> platforms = getPlatforms();
if (platforms.empty())
return false;
for (unsigned i = 0; i < platforms.size(); ++i)
if (searchForAllDevices(i, _callback))
return true;
return false;
}
bool ethash_cl_miner::searchForAllDevices(unsigned _platformId, function<bool(cl::Device const&)> _callback)
{
vector<cl::Platform> platforms = getPlatforms();

9
libethash-cl/ethash_cl_miner.h

@ -27,7 +27,7 @@
class ethash_cl_miner
{
private:
enum { c_maxSearchResults = 63, c_bufferCount = 2, c_hashBatchSize = 1024 };
enum { c_maxSearchResults = 63, c_bufferCount = 2 };
public:
struct search_hook
@ -43,10 +43,8 @@ public:
~ethash_cl_miner();
static bool searchForAllDevices(unsigned _platformId, std::function<bool(cl::Device const&)> _callback);
static bool searchForAllDevices(std::function<bool(cl::Device const&)> _callback);
static void doForAllDevices(unsigned _platformId, std::function<void(cl::Device const&)> _callback);
static void doForAllDevices(std::function<void(cl::Device const&)> _callback);
static unsigned getNumPlatforms();
static unsigned getNumDevices(unsigned _platformId = 0);
static std::string platform_info(unsigned _platformId = 0, unsigned _deviceId = 0);
static void listDevices();
@ -54,7 +52,6 @@ public:
unsigned _platformId,
unsigned _localWorkSize,
unsigned _globalWorkSize,
bool _allowCPU,
unsigned _extraGPUMemory,
uint64_t _currentBlock
);
@ -95,10 +92,6 @@ private:
static unsigned s_workgroupSize;
/// The initial global work size for the searches
static unsigned s_initialGlobalWorkSize;
/// The target milliseconds per batch for the search. If 0, then no adjustment will happen
static unsigned s_msPerBatch;
/// Allow CPU to appear as an OpenCL device or not. Default is false
static bool s_allowCPU;
/// GPU memory required for other things, like window rendering e.t.c.
/// User can set it via the --cl-extragpu-mem argument.
static unsigned s_extraRequiredGPUMem;

2
libethcore/EthashGPUMiner.cpp

@ -206,7 +206,6 @@ bool EthashGPUMiner::configureGPU(
unsigned _globalWorkSizeMultiplier,
unsigned _platformId,
unsigned _deviceId,
bool _allowCPU,
unsigned _extraGPUMemory,
uint64_t _currentBlock,
unsigned _dagLoadMode,
@ -225,7 +224,6 @@ bool EthashGPUMiner::configureGPU(
_platformId,
_localWorkSize,
_globalWorkSizeMultiplier * _localWorkSize,
_allowCPU,
_extraGPUMemory,
_currentBlock
)

1
libethcore/EthashGPUMiner.h

@ -53,7 +53,6 @@ public:
unsigned _globalWorkSizeMultiplier,
unsigned _platformId,
unsigned _deviceId,
bool _allowCPU,
unsigned _extraGPUMemory,
uint64_t _currentBlock,
unsigned _dagLoadMode,

Loading…
Cancel
Save