Skip to content

Commit aec41e5

Browse files
author
jgtong
authored
Merge pull request #13 from oneapi-src/ethminer/code_update
[ethminer] Code updates
2 parents c9a5e23 + 8c3e573 commit aec41e5

File tree

7 files changed

+126
-83
lines changed

7 files changed

+126
-83
lines changed

ethminer/CLI11/include/CLI/App.hpp

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class App {
128128
Option *help_all_ptr_{nullptr};
129129

130130
/// This is the formatter for help printing. Default provided. INHERITABLE (same pointer)
131-
std::shared_ptr<FormatterBase> formatter_{new Formatter()};
131+
///std::shared_ptr<FormatterBase> formatter_{new Formatter()};
132132

133133
/// The error message printing function INHERITABLE
134134
std::function<std::string(const App *, const Error &e)> failure_message_ = FailureMessage::simple;
@@ -204,7 +204,7 @@ class App {
204204
Option *config_ptr_{nullptr};
205205

206206
/// This is the formatter for help printing. Default provided. INHERITABLE (same pointer)
207-
std::shared_ptr<Config> config_formatter_{new ConfigINI()};
207+
///std::shared_ptr<Config> config_formatter_{new ConfigINI()};
208208

209209
///@}
210210

@@ -233,8 +233,8 @@ class App {
233233
allow_windows_style_options_ = parent_->allow_windows_style_options_;
234234
group_ = parent_->group_;
235235
footer_ = parent_->footer_;
236-
formatter_ = parent_->formatter_;
237-
config_formatter_ = parent_->config_formatter_;
236+
///formatter_ = parent_->formatter_;
237+
///config_formatter_ = parent_->config_formatter_;
238238
require_subcommand_max_ = parent_->require_subcommand_max_;
239239
}
240240
}
@@ -319,22 +319,22 @@ class App {
319319
}
320320

321321
/// Set the help formatter
322-
App *formatter(std::shared_ptr<FormatterBase> fmt) {
323-
formatter_ = fmt;
324-
return this;
325-
}
322+
///App *formatter(std::shared_ptr<FormatterBase> fmt) {
323+
/// formatter_ = fmt;
324+
/// return this;
325+
///}
326326

327327
/// Set the help formatter
328-
App *formatter_fn(std::function<std::string(const App *, std::string, AppFormatMode)> fmt) {
329-
formatter_ = std::make_shared<FormatterLambda>(fmt);
330-
return this;
331-
}
328+
///App *formatter_fn(std::function<std::string(const App *, std::string, AppFormatMode)> fmt) {
329+
/// formatter_ = std::make_shared<FormatterLambda>(fmt);
330+
/// return this;
331+
///}
332332

333333
/// Set the config formatter
334-
App *config_formatter(std::shared_ptr<Config> fmt) {
335-
config_formatter_ = fmt;
336-
return this;
337-
}
334+
///App *config_formatter(std::shared_ptr<Config> fmt) {
335+
/// config_formatter_ = fmt;
336+
/// return this;
337+
///}
338338

339339
/// Check to see if this subcommand was parsed, true only if received on command line.
340340
bool parsed() const { return parsed_ > 0; }
@@ -1367,9 +1367,9 @@ class App {
13671367

13681368
/// Produce a string that could be read in as a config of the current values of the App. Set default_also to
13691369
/// include default arguments. Prefix will add a string to the beginning of each option.
1370-
std::string config_to_str(bool default_also = false, bool write_description = false) const {
1371-
return config_formatter_->to_config(this, default_also, write_description, "");
1372-
}
1370+
///std::string config_to_str(bool default_also = false, bool write_description = false) const {
1371+
/// return config_formatter_->to_config(this, default_also, write_description, "");
1372+
///}
13731373

13741374
/// Makes a help message, using the currently configured formatter
13751375
/// Will only do one subcommand at a time
@@ -1383,19 +1383,19 @@ class App {
13831383
auto selected_subcommands = get_subcommands();
13841384
if(!selected_subcommands.empty())
13851385
return selected_subcommands.at(0)->help(prev, mode);
1386-
else
1387-
return formatter_->make_help(this, prev, mode);
1386+
/// else
1387+
/// return formatter_->make_help(this, prev, mode);
13881388
}
13891389

13901390
///@}
13911391
/// @name Getters
13921392
///@{
13931393

13941394
/// Access the formatter
1395-
std::shared_ptr<FormatterBase> get_formatter() const { return formatter_; }
1395+
///std::shared_ptr<FormatterBase> get_formatter() const { return formatter_; }
13961396

13971397
/// Access the config formatter
1398-
std::shared_ptr<Config> get_config_formatter() const { return config_formatter_; }
1398+
///std::shared_ptr<Config> get_config_formatter() const { return config_formatter_; }
13991399

14001400
/// Get the app or subcommand description
14011401
std::string get_description() const { return description_; }
@@ -1624,24 +1624,24 @@ class App {
16241624
// The parse function is now broken into several parts, and part of process
16251625

16261626
/// Read and process an ini file (main app only)
1627-
void _process_ini() {
1628-
// Process an INI file
1629-
if(config_ptr_ != nullptr) {
1630-
if(*config_ptr_) {
1631-
config_ptr_->run_callback();
1632-
config_required_ = true;
1633-
}
1634-
if(!config_name_.empty()) {
1635-
try {
1636-
std::vector<ConfigItem> values = config_formatter_->from_file(config_name_);
1637-
_parse_config(values);
1638-
} catch(const FileError &) {
1639-
if(config_required_)
1640-
throw;
1641-
}
1642-
}
1643-
}
1644-
}
1627+
///void _process_ini() {
1628+
/// // Process an INI file
1629+
/// if(config_ptr_ != nullptr) {
1630+
/// if(*config_ptr_) {
1631+
/// config_ptr_->run_callback();
1632+
/// config_required_ = true;
1633+
/// }
1634+
/// if(!config_name_.empty()) {
1635+
/// try {
1636+
/// std::vector<ConfigItem> values = config_formatter_->from_file(config_name_);
1637+
/// _parse_config(values);
1638+
/// } catch(const FileError &) {
1639+
/// if(config_required_)
1640+
/// throw;
1641+
/// }
1642+
/// }
1643+
/// }
1644+
///}
16451645

16461646
/// Get envname options if not yet passed. Runs on *all* subcommands.
16471647
void _process_env() {
@@ -1751,8 +1751,8 @@ class App {
17511751

17521752
/// Process callbacks and such.
17531753
void _process() {
1754-
_process_ini();
1755-
_process_env();
1754+
///_process_ini();
1755+
///_process_env();
17561756
_process_callbacks();
17571757
_process_help_flags();
17581758
_process_requirements();
@@ -1835,7 +1835,7 @@ class App {
18351835
if(op->empty()) {
18361836
// Flag parsing
18371837
if(op->get_type_size() == 0) {
1838-
op->set_results(config_formatter_->to_flag(item));
1838+
///op->set_results(config_formatter_->to_flag(item));
18391839
} else {
18401840
op->set_results(item.inputs);
18411841
op->run_callback();

ethminer/CMakeLists.txt

Lines changed: 75 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -44,29 +44,57 @@ option(DEVBUILD "Log developer metrics" OFF)
4444

4545
option(GPU_AOT "Build AOT for Intel GPU" OFF)
4646
option(USE_NVIDIA_BACKEND "Build for NVIDIA backend" OFF)
47-
option(USE_AMDHIP_BACKEND "Build for AMD HIP backend" OFF)
47+
option(USE_AMD_BACKEND "Build for AMD HIP backend" OFF)
4848
option(USE_LOOP_UNROLLING "Build with loop unrolling SYCL only" OFF)
4949
option(USE_SM "Build for CUDA architecture" )
5050

51-
set(USE_DEFAULT_FLAGS ON)
52-
set(INTEL_GPU_CXX_FLAGS " -O2 -fsycl ")
53-
set(NVIDIA_GPU_CXX_FLAGS " -O3 -fsycl ")
54-
set(AMD_GPU_CXX_FLAGS " -O3 -fsycl ")
55-
set(ROCM_CXX_FLAGS " -O3" )
56-
set(NVCC_CXX_FLAGS " -O3 ")
51+
### SYCL RELATED FLAGS START HERE
52+
set(DEF_INTEL_GENERAL_CXX_FLAGS " -O2 -fsycl ")
53+
set(DEF_NVIDIA_GENERAL_CXX_FLAGS " -O3 -fsycl ")
54+
set(DEF_AMD_GENERAL_CXX_FLAGS " -O3 -fsycl ")
5755

58-
include_directories(${OPENSSL_INCLUDE_DIR} ${jsoncpp_DIR}/../../../include)
56+
set(DEF_INTEL_WL_CXX_FLAGS " ")
57+
set(DEF_NVIDIA_WL_CXX_FLAGS " ")
58+
set(DEF_AMD_WL_CXX_FLAGS " ")
5959

60-
if("${CMAKE_CXX_FLAGS}" STREQUAL "")
61-
message(STATUS "Using DEFAULT compilation flags for the application")
62-
string(APPEND CMAKE_CXX_FLAGS "${INTEL_GPU_CXX_FLAGS}") # Default flags for NV backend
63-
else()
64-
message(STATUS "OVERRIDING compilation flags")
65-
set(USE_DEFAULT_FLAGS OFF)
60+
if(NOT "${CMAKE_CXX_FLAGS}" STREQUAL "" AND NOT "${OVERRIDE_GENERAL_CXX_FLAGS}" STREQUAL "")
61+
message(FATAL_ERROR "Both CMAKE_CXX_FLAGS and OVERRIDE_GENERAL_CXX_FLAGS cannot be passed in together")
62+
elseif("${CMAKE_CXX_FLAGS}" STREQUAL "" AND "${OVERRIDE_GENERAL_CXX_FLAGS}" STREQUAL "")
63+
message(STATUS "Using DEFAULT compilation flags")
64+
set(INTEL_GPU_CXX_FLAGS "${DEF_INTEL_GENERAL_CXX_FLAGS} ${DEF_INTEL_WL_CXX_FLAGS}")
65+
set(NVIDIA_GPU_CXX_FLAGS "${DEF_NVIDIA_GENERAL_CXX_FLAGS} ${DEF_NVIDIA_WL_CXX_FLAGS}")
66+
set(AMD_GPU_CXX_FLAGS "${DEF_AMD_GENERAL_CXX_FLAGS} ${DEF_AMD_WL_CXX_FLAGS}")
67+
elseif(NOT "${OVERRIDE_GENERAL_CXX_FLAGS}" STREQUAL "")
68+
message(STATUS "OVERRIDING GENERAL compilation flags")
69+
set(INTEL_GPU_CXX_FLAGS "${OVERRIDE_GENERAL_CXX_FLAGS} ${DEF_INTEL_WL_CXX_FLAGS}")
70+
set(NVIDIA_GPU_CXX_FLAGS "${OVERRIDE_GENERAL_CXX_FLAGS} ${DEF_NVIDIA_WL_CXX_FLAGS}")
71+
set(AMD_GPU_CXX_FLAGS "${OVERRIDE_GENERAL_CXX_FLAGS} ${DEF_AMD_WL_CXX_FLAGS}")
72+
elseif(NOT "${CMAKE_CXX_FLAGS}" STREQUAL "")
73+
message(STATUS "OVERRIDING GENERAL and WORKLOAD SPECIFIC compilation flags")
74+
set(INTEL_GPU_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
75+
set(NVIDIA_GPU_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
76+
set(AMD_GPU_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
6677
endif()
78+
### END OF SYCL RELATED FLAGS
79+
80+
### NVCC RELATED FLAGS START HERE
81+
set(NVCC_WL_CXX_FLAGS " ")
82+
set(NVCC_DEF_CXX_FLAGS " -O3 ")
83+
set(NVCC_DEF_COMBINED_FLAGS "${NVCC_WL_CXX_FLAGS} ${NVCC_DEF_CXX_FLAGS} ")
84+
### END OF NVCC RELATED FLAGS
85+
86+
87+
### ROCM RELATED FLAGS START HERE
88+
set(ROCM_WL_CXX_FLAGS " ")
89+
set(ROCM_DEF_CXX_FLAGS " -O3 -D__HIP_PLATFORM_AMD__ " )
90+
set(ROCM_DEF_COMBINED_FLAGS " ${ROCM_WL_CXX_FLAGS} ${ROCM_DEF_CXX_FLAGS} ")
91+
### END OF ROCM RELATED FLAGS
92+
93+
include_directories(${OPENSSL_INCLUDE_DIR} ${jsoncpp_DIR}/../../../include)
6794

6895
# JIT compilation
69-
if(GPU_AOT)
96+
if(GPU_AOT)
97+
set(CMAKE_CXX_FLAGS "${INTEL_GPU_CXX_FLAGS}")
7098
if( (${GPU_AOT} STREQUAL "pvc") OR (${GPU_AOT} STREQUAL "PVC") )
7199
message(STATUS "Enabling Intel GPU AOT compilation for ${GPU_AOT}")
72100
string(APPEND CMAKE_CXX_FLAGS " -fsycl-targets=spir64_gen -Xs \"-device 0x0bd5 -revision_id 0x2f\" -Xs \"-options -ze-opt-large-register-file\" ") # Default flag for pvc
@@ -76,40 +104,56 @@ if(GPU_AOT)
76104
endif()
77105
elseif(USE_NVIDIA_BACKEND)
78106
message(STATUS "Enabling NVIDIA backend")
79-
if(USE_DEFAULT_FLAGS)
80-
set(CMAKE_CXX_FLAGS "${NVIDIA_GPU_CXX_FLAGS}") # Default flags for NV backend
81-
endif()
107+
set(CMAKE_CXX_FLAGS "${NVIDIA_GPU_CXX_FLAGS}")
82108
string(APPEND CMAKE_CXX_FLAGS " -fsycl-targets=nvptx64-nvidia-cuda ") # -O3 will be used, even though -O2 was set earlier
83109
if(USE_SM)
84110
message(STATUS "Building for SM_${USE_SM} architecture")
85111
string(APPEND CMAKE_CXX_FLAGS " -Xsycl-target-backend --cuda-gpu-arch=sm_${USE_SM}")
86112
endif()
87-
elseif(USE_AMDHIP_BACKEND)
88-
message(STATUS "Enabling AMD HIP backend for ${USE_AMDHIP_BACKEND} AMD architecture")
89-
if(USE_DEFAULT_FLAGS)
90-
set(CMAKE_CXX_FLAGS "${AMD_GPU_CXX_FLAGS}")
113+
elseif(USE_AMD_BACKEND)
114+
if ("${USE_AMD_ARCH}" STREQUAL "")
115+
message(FATAL_ERROR "Must specify AMD arch, e.g., -DUSE_AMD_ARCH=gfx90a")
91116
endif()
92-
string(APPEND CMAKE_CXX_FLAGS " -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend --offload-arch=${USE_AMDHIP_BACKEND} ")
93-
add_compile_options(-DUSE_AMDHIP_BACKEND)
117+
message(STATUS "Enabling AMD backend for ${USE_AMD_ARCH} AMD architecture")
118+
set(CMAKE_CXX_FLAGS "${AMD_GPU_CXX_FLAGS}")
119+
string(APPEND CMAKE_CXX_FLAGS " -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend --offload-arch=${USE_AMD_ARCH} ")
120+
add_compile_options(-DUSE_AMD_BACKEND)
94121
endif()
95122

96-
if(USE_AMDHIP_BACKEND)
123+
if(USE_AMD_BACKEND)
97124
message(STATUS "Using 64 thread shuffle function code path")
98125
else()
99126
message(STATUS "Using 32 thread shuffle function code path")
100127
endif()
101128

102129
if (ETHASHCUDA)
103-
if (USE_DEFAULT_FLAGS)
104-
message(STATUS "Using NVIDIA CUDA flags")
105-
set(CMAKE_CXX_FLAGS "${NVCC_CXX_FLAGS}")
130+
message(STATUS "Compiling for NVCC")
131+
if(NOT "${CMAKE_CXX_FLAGS}" STREQUAL "" AND NOT "${OVERRIDE_GENERAL_CXX_FLAGS}" STREQUAL "")
132+
message(FATAL_ERROR "Both CMAKE_CXX_FLAGS and OVERRIDE_GENERAL_CXX_FLAGS cannot be passed in together")
133+
elseif("${CMAKE_CXX_FLAGS}" STREQUAL "" AND "${OVERRIDE_GENERAL_CXX_FLAGS}" STREQUAL "")
134+
message(STATUS "Using DEFAULT compilation flags")
135+
set(CMAKE_CXX_FLAGS "${NVCC_DEF_COMBINED_FLAGS}")
136+
elseif(NOT "${OVERRIDE_GENERAL_CXX_FLAGS}" STREQUAL "")
137+
message(STATUS "OVERRIDING GENERAL compilation flags")
138+
set(CMAKE_CXX_FLAGS "${OVERRIDE_GENERAL_CXX_FLAGS}")
139+
string(APPEND CMAKE_CXX_FLAGS ${NVCC_WL_CXX_FLAGS})
140+
elseif(NOT "${CMAKE_CXX_FLAGS}" STREQUAL "")
141+
message(STATUS "OVERRIDING GENERAL and WORKLOAD SPECIFIC compilation flags")
106142
endif()
107143
endif()
108144

109145
if (ETHASHHIP)
110-
if (USE_DEFAULT_FLAGS)
111-
message(STATUS "Using ROCM flags")
112-
set(CMAKE_CXX_FLAGS "${ROCM_CXX_FLAGS}")
146+
if(NOT "${CMAKE_CXX_FLAGS}" STREQUAL "" AND NOT "${OVERRIDE_GENERAL_CXX_FLAGS}" STREQUAL "")
147+
message(FATAL_ERROR "Both CMAKE_CXX_FLAGS and OVERRIDE_GENERAL_CXX_FLAGS cannot be passed in together")
148+
elseif("${CMAKE_CXX_FLAGS}" STREQUAL "" AND "${OVERRIDE_GENERAL_CXX_FLAGS}" STREQUAL "")
149+
message(STATUS "Using DEFAULT compilation flags")
150+
set(CMAKE_CXX_FLAGS "${ROCM_DEF_COMBINED_FLAGS}")
151+
elseif(NOT "${OVERRIDE_GENERAL_CXX_FLAGS}" STREQUAL "")
152+
message(STATUS "OVERRIDING GENERAL compilation flags")
153+
set(CMAKE_CXX_FLAGS "${OVERRIDE_GENERAL_CXX_FLAGS}")
154+
string(APPEND CMAKE_CXX_FLAGS ${ROCM_WL_CXX_FLAGS})
155+
elseif(NOT "${CMAKE_CXX_FLAGS}" STREQUAL "")
156+
message(STATUS "OVERRIDING GENERAL and WORKLOAD SPECIFIC compilation flags")
113157
endif()
114158

115159
if (USE_ROCM_PATH)
@@ -187,9 +231,6 @@ include_directories(${Boost_INCLUDE_DIRS}/include ${OPENSSL_INCLUDE_DIR} ${jsonc
187231

188232
if (ETHASHCUDA)
189233
add_subdirectory(libethash-cuda)
190-
if (USE_DEFAULT_FLAGS)
191-
set(CMAKE_CXX_FLAGS "${NVCC_CXX_FLAGS}")
192-
endif()
193234
endif ()
194235
if (ETHASHHIP)
195236
add_subdirectory(libethash-hip)

ethminer/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ CC=/path/to/compiler/bin/clang cmake=/path/to/compiler/bin/clang++ .. -DUSE_NVID
8383
To compile the code for AMD, please use the following `cmake` command:
8484

8585
```
86-
CC=/path/to/compiler/bin/clang cmake=/path/to/compiler/bin/clang++ .. -DUSE_AMDHIP_BACKEND={gfx90a|gfx908} -DETHASHSYCL=ON
86+
CC=/path/to/compiler/bin/clang cmake=/path/to/compiler/bin/clang++ .. -DUSE_AMD_BACKEND=ON -DUSE_AMD_ARCH={gfx90a|gfx908} -DETHASHSYCL=ON
8787
8888
```
8989

ethminer/libdevcore/vector_ref.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <string>
2727
#include <type_traits>
2828
#include <vector>
29+
#include <cstdint>
2930

3031
namespace dev
3132
{

ethminer/libethash-sycl/SYCLMiner.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ along with ethminer. If not, see <http://www.gnu.org/licenses/>.
5151
#include <execinfo.h>
5252

5353
#include <iostream>
54+
#include <set>
5455

5556
using namespace dev;
5657
using namespace eth;
@@ -139,7 +140,7 @@ SYCLMiner::SYCLMiner(unsigned _index, SYSettings _settings, DeviceDescriptor & /
139140
d_header = sycl::malloc_device<hash32_t> (1, m_DefaultQueue);
140141
d_target = sycl::malloc_device<uint64_t> (1, m_DefaultQueue);
141142
keccak_round_constants = sycl::malloc_device<sycl::uint2>(24, m_DefaultQueue); // There's 24 constants to store
142-
#ifdef USE_AMDHIP_BACKEND
143+
#ifdef USE_AMD_BACKEND
143144
pdShuffleOffsets = sycl::malloc_device<int>(64, m_DefaultQueue);
144145
#else
145146
pdShuffleOffsets = sycl::malloc_device<int>(32, m_DefaultQueue);

ethminer/libethash-sycl/ethash_sycl_miner_kernel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ void ethash_calculate_dag_item(uint32_t start, sycl::nd_item<1> item_ct1, uint32
116116
else if (item_ct1.get_sub_group().get_local_id() < 32)
117117
shuffle_index = item_ct1.get_sub_group().shuffle(parent_index, t + 28);
118118

119-
#ifdef USE_AMDHIP_BACKEND // Shuffle on AMD GPUs is done over 64 threads
119+
#ifdef USE_AMD_BACKEND // Shuffle on AMD GPUs is done over 64 threads
120120
else if (item_ct1.get_sub_group().get_local_id() < 36)
121121
shuffle_index = item_ct1.get_sub_group().shuffle(parent_index, t + 32);
122122
else if (item_ct1.get_sub_group().get_local_id() < 40)
@@ -156,7 +156,7 @@ void ethash_calculate_dag_item(uint32_t start, sycl::nd_item<1> item_ct1, uint32
156156
w1 = w + 24;
157157
else if (iSubGroupThreadId < 32)
158158
w1 = w + 28;
159-
#ifdef USE_AMDHIP_BACKEND
159+
#ifdef USE_AMD_BACKEND
160160
else if (iSubGroupThreadId < 36)
161161
w1 = w + 32;
162162
else if (iSubGroupThreadId < 40)

ethminer/libethash-sycl/ethash_sycl_miner_kernel_globals.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ std::vector<int> const vShuffleOffsets({
5858
24,
5959
24,
6060
24,
61-
#ifdef USE_AMDHIP_BACKEND
61+
#ifdef USE_AMD_BACKEND
6262
32,
6363
32,
6464
32,

0 commit comments

Comments
 (0)