Skip to content
This repository was archived by the owner on Apr 24, 2022. It is now read-only.

Commit 8cc147b

Browse files
committedJul 22, 2018
OpenCL tweaks and cleanup
- Reorganize kernels folder - Adjust default opencl global work size - Always use single search iteration - Add --cl-nobinary. Bypass binary kernel load attempt. - Remove unused isa kernel files
1 parent f8516eb commit 8cc147b

12 files changed

+28
-11526
lines changed
 

‎ethminer/main.cpp

+16-14
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,8 @@ class MinerCLI
331331

332332
#if ETH_ETHASHCL
333333

334-
app.add_option("--cl-kernel", m_clKernel,
334+
int clKernel = -1;
335+
app.add_option("--cl-kernel", clKernel,
335336
"Ignored parameter. Kernel is auto-selected.", true)
336337
->group(OpenCLGroup)
337338
->check(CLI::Range(2));
@@ -345,15 +346,11 @@ class MinerCLI
345346
"Select list of devices to mine on (default: use all available)")
346347
->group(OpenCLGroup);
347348

348-
app.add_set("--cl-parallel-hash", m_openclThreadsPerHash, {1, 2, 4, 8},
349+
int openclThreadsPerHash = -1;
350+
app.add_set("--cl-parallel-hash", openclThreadsPerHash, {1, 2, 4, 8},
349351
"ignored parameter", true)
350352
->group(OpenCLGroup);
351353

352-
app.add_option("--cl-iterations", m_openclIterations,
353-
"Number of outer iterations to perform before enqeueing on a new nonce", true)
354-
->group(OpenCLGroup)
355-
->check(CLI::Range(1,99999));
356-
357354
app.add_option("--cl-global-work", m_globalWorkSizeMultiplier,
358355
"Set the global work size multipler.", true)
359356
->group(OpenCLGroup);
@@ -362,6 +359,9 @@ class MinerCLI
362359
"Set the local work size", true)
363360
->group(OpenCLGroup);
364361

362+
app.add_flag("--cl-nobinary", m_noBinary,
363+
"Don't attempt to load binary kernel")
364+
->group(OpenCLGroup);
365365
#endif
366366

367367
#if ETH_ETHASHCUDA
@@ -498,6 +498,13 @@ class MinerCLI
498498
exit(-1);
499499
}
500500

501+
#if ETH_ETHASHCL
502+
if (clKernel >= 0)
503+
clog << "--cl-kernel ignored. Kernel is auto-selected\n";
504+
if (openclThreadsPerHash >= 0)
505+
clog << "--cl-parallel-hash ignored. No longer applies\n";
506+
#endif
507+
501508
if (hwmon_opt->count()) {
502509
m_show_hwmonitors = true;
503510
if (hwmon)
@@ -621,9 +628,6 @@ class MinerCLI
621628
m_miningThreads = m_openclDeviceCount;
622629
}
623630

624-
CLMiner::setNumberIterations(m_openclIterations);
625-
CLMiner::setThreadsPerHash(m_openclThreadsPerHash);
626-
627631
if (!CLMiner::configureGPU(
628632
m_localWorkSize,
629633
m_globalWorkSizeMultiplier,
@@ -633,7 +637,7 @@ class MinerCLI
633637
m_dagCreateDevice,
634638
m_noEval,
635639
m_exit,
636-
m_clKernel
640+
m_noBinary
637641
)) {
638642
stop_io_service();
639643
exit(1);
@@ -896,13 +900,11 @@ class MinerCLI
896900
unsigned m_miningThreads = UINT_MAX;
897901
bool m_shouldListDevices = false;
898902
#if ETH_ETHASHCL
899-
unsigned m_openclIterations = 1; ///< A numeric value for the number of iterations
900903
unsigned m_openclDeviceCount = 0;
901904
vector<unsigned> m_openclDevices;
902-
int m_openclThreadsPerHash = -1;
903905
unsigned m_globalWorkSizeMultiplier = CLMiner::c_defaultGlobalWorkSizeMultiplier;
904906
unsigned m_localWorkSize = CLMiner::c_defaultLocalWorkSize;
905-
int m_clKernel = -1;
907+
bool m_noBinary = false;
906908
#endif
907909
#if ETH_ETHASHCUDA
908910
unsigned m_cudaDeviceCount = 0;

‎libethash-cl/CLMiner.cpp

+5-9
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ namespace eth
1919

2020
unsigned CLMiner::s_workgroupSize = CLMiner::c_defaultLocalWorkSize;
2121
unsigned CLMiner::s_initialGlobalWorkSize = CLMiner::c_defaultGlobalWorkSizeMultiplier * CLMiner::c_defaultLocalWorkSize;
22-
int CLMiner::s_threadsPerHash = -1;
23-
unsigned CLMiner::s_kernelIterations = 1;
2422

2523
constexpr size_t c_maxSearchResults = 255;
2624

@@ -256,6 +254,7 @@ std::vector<cl::Device> getDevices(std::vector<cl::Platform> const& _platforms,
256254
unsigned CLMiner::s_platformId = 0;
257255
unsigned CLMiner::s_numInstances = 0;
258256
vector<int> CLMiner::s_devices(MAX_MINERS, -1);
257+
bool CLMiner::s_noBinary = false;
259258

260259
CLMiner::CLMiner(FarmFace& _farm, unsigned _index):
261260
Miner("cl-", _farm, _index)
@@ -449,19 +448,16 @@ void CLMiner::listDevices()
449448

450449
bool CLMiner::configureGPU(unsigned _localWorkSize, unsigned _globalWorkSizeMultiplier,
451450
unsigned _platformId, int epoch, unsigned _dagLoadMode, unsigned _dagCreateDevice,
452-
bool _noeval, bool _exit, int _kernel)
451+
bool _noeval, bool _exit, bool _nobinary)
453452
{
454453
s_noeval = _noeval;
455454
s_dagLoadMode = _dagLoadMode;
456455
s_dagCreateDevice = _dagCreateDevice;
457456
s_exit = _exit;
457+
s_noBinary = _nobinary;
458458

459459
if (_noeval)
460460
cwarn << "--no-eval not yet supported for AMD.";
461-
if (_kernel >= 0)
462-
cwarn << "--cl-kernel ignored. Auto-selecting kernel";
463-
if (s_threadsPerHash >= 0)
464-
cwarn << "--cl-parallel-hash ignored.";
465461

466462
s_platformId = _platformId;
467463

@@ -653,7 +649,7 @@ bool CLMiner::init(int epoch)
653649
the default kernel if loading fails for whatever reason */
654650
bool loadedBinary = false;
655651

656-
{
652+
if (!s_noBinary) {
657653
std::ifstream kernel_file;
658654
vector<unsigned char> bin_data;
659655
std::stringstream fname_strm;
@@ -750,7 +746,7 @@ bool CLMiner::init(int epoch)
750746
m_searchKernel.setArg(2, m_dag[0]);
751747
m_searchKernel.setArg(3, m_dagItems);
752748
m_searchKernel.setArg(6, ~0u);
753-
m_searchKernel.setArg(7, uint32_t(s_kernelIterations)); // Number of iterations
749+
m_searchKernel.setArg(7, 1u); // Number of iterations
754750

755751
// create mining buffers
756752
ETHCL_LOG("Creating mining buffer");

‎libethash-cl/CLMiner.h

+3-6
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class CLMiner: public Miner
5050
/// Default value of the local work size. Also known as workgroup size.
5151
static const unsigned c_defaultLocalWorkSize = 192;
5252
/// Default value of the global work size as a multiplier of the local work size
53-
static const unsigned c_defaultGlobalWorkSizeMultiplier = 18000;
53+
static const unsigned c_defaultGlobalWorkSizeMultiplier = 16392;
5454

5555
CLMiner(FarmFace& _farm, unsigned _index);
5656
~CLMiner() override;
@@ -60,17 +60,15 @@ class CLMiner: public Miner
6060
static void listDevices();
6161
static bool configureGPU(unsigned _localWorkSize, unsigned _globalWorkSizeMultiplier,
6262
unsigned _platformId, int epoch, unsigned _dagLoadMode, unsigned _dagCreateDevice,
63-
bool _noeval, bool _exit, int _kernel);
63+
bool _noeval, bool _exit, bool _nobinary);
6464
static void setNumInstances(unsigned _instances) { s_numInstances = std::min<unsigned>(_instances, getNumDevices()); }
65-
static void setThreadsPerHash(int _threadsPerHash){s_threadsPerHash = _threadsPerHash; }
6665
static void setDevices(const vector<unsigned>& _devices, unsigned _selectedDeviceCount)
6766
{
6867
for (unsigned i = 0; i < _selectedDeviceCount; i++)
6968
{
7069
s_devices[i] = _devices[i];
7170
}
7271
}
73-
static void setNumberIterations(unsigned _iterations) {s_kernelIterations = _iterations <= 1 ? 1 : _iterations;}
7472
protected:
7573
void kick_miner() override;
7674

@@ -94,8 +92,7 @@ class CLMiner: public Miner
9492

9593
static unsigned s_platformId;
9694
static unsigned s_numInstances;
97-
static int s_threadsPerHash;
98-
static unsigned s_kernelIterations;
95+
static bool s_noBinary;
9996
static vector<int> s_devices;
10097

10198
/// The local work size for the search

‎libethash-cl/CMakeLists.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
add_custom_command(
77
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ethash.h
88
COMMAND ${CMAKE_COMMAND} ARGS
9-
-DBIN2H_SOURCE_FILE="${CMAKE_CURRENT_SOURCE_DIR}/kernels/ethash.cl"
9+
-DBIN2H_SOURCE_FILE="${CMAKE_CURRENT_SOURCE_DIR}/kernels/cl/ethash.cl"
1010
-DBIN2H_VARIABLE_NAME=ethash_cl
1111
-DBIN2H_HEADER_FILE="${CMAKE_CURRENT_BINARY_DIR}/ethash.h"
1212
-P "${CMAKE_CURRENT_SOURCE_DIR}/bin2h.cmake"
1313
COMMENT "Generating OpenCL Kernel Byte Array"
14-
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/kernels/ethash.cl
14+
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/kernels/cl/ethash.cl
1515
)
16-
add_custom_target(clbin2h_stable DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/ethash.h ${CMAKE_CURRENT_SOURCE_DIR}/ethash.cl)
16+
add_custom_target(clbin2h_stable DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/ethash.h ${CMAKE_CURRENT_SOURCE_DIR}/cl/ethash.cl)
1717

1818
set(SOURCES
1919
CLMiner.h CLMiner.cpp

‎libethash-cl/kernels/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
SDIR=./src
1+
SDIR=./isa
22
BUILD=./bin
33

44
ASFLAGS=-I$(SDIR)
File renamed without changes.

‎libethash-cl/kernels/src/GCN3_ethash_GenerateDAG.isa

-5,422
This file was deleted.

‎libethash-cl/kernels/src/GCN5_ethash_GenerateDAG.isa

-6,071
This file was deleted.

0 commit comments

Comments
 (0)
This repository has been archived.