1
- if (NOT CMAKE_BUILD_TYPE STREQUAL "Release" )
2
- message (WARNING
1
+ if (NOT CMAKE_BUILD_TYPE STREQUAL "Release" )
2
+ message (
3
+ WARNING
3
4
"Ginkgo is not being built in \" Release\" mode, benchmark performance "
4
- "will be affected" )
5
+ "will be affected"
6
+ )
5
7
endif ()
6
8
7
9
function (ginkgo_benchmark_add_tuning_maybe name )
8
10
if (GINKGO_BENCHMARK_ENABLE_TUNING)
9
- target_sources (${name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} /../utils/tuning_variables.cpp)
11
+ target_sources (
12
+ ${name}
13
+ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} /../utils/tuning_variables.cpp
14
+ )
10
15
endif ()
11
16
endfunction ()
12
17
13
18
function (ginkgo_benchmark_cusparse_linops type def)
14
19
add_library (cusparse_linops_${type} utils/cuda_linops.cpp)
15
20
if (CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA" )
16
21
# remove false positive CUDA warnings when calling one<T>() and zero<T>()
17
- target_compile_options (cusparse_linops_${type}
18
- PRIVATE
19
- $<$<COMPILE_LANGUAGE:CUDA>:--expt-relaxed-constexpr>)
22
+ target_compile_options (
23
+ cusparse_linops_${type}
24
+ PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--expt-relaxed-constexpr>
25
+ )
20
26
endif ()
21
27
if (GINKGO_CUDA_CUSTOM_THRUST_NAMESPACE)
22
- target_compile_definitions (cusparse_linops_${type} PRIVATE THRUST_CUB_WRAPPED_NAMESPACE=gko)
28
+ target_compile_definitions (
29
+ cusparse_linops_${type}
30
+ PRIVATE THRUST_CUB_WRAPPED_NAMESPACE=gko
31
+ )
23
32
endif ()
24
33
# make the dependency public to catch issues
25
34
target_compile_definitions (cusparse_linops_${type} PUBLIC ${def} )
26
- target_compile_definitions (cusparse_linops_${type} PRIVATE GKO_COMPILING_CUDA)
27
- target_link_libraries (cusparse_linops_${type} PRIVATE Ginkgo::ginkgo CUDA::cudart CUDA::cublas CUDA::cusparse)
35
+ target_compile_definitions (
36
+ cusparse_linops_${type}
37
+ PRIVATE GKO_COMPILING_CUDA
38
+ )
39
+ target_link_libraries (
40
+ cusparse_linops_${type}
41
+ PRIVATE Ginkgo::ginkgo CUDA::cudart CUDA::cublas CUDA::cusparse
42
+ )
28
43
ginkgo_compile_features(cusparse_linops_${type} )
29
44
endfunction ()
30
45
31
46
function (ginkgo_benchmark_hipsparse_linops type def)
32
47
add_library (hipsparse_linops_${type} utils/hip_linops.hip.cpp)
33
- set_source_files_properties (utils/hip_linops.hip.cpp PROPERTIES LANGUAGE HIP)
48
+ set_source_files_properties (
49
+ utils/hip_linops.hip.cpp
50
+ PROPERTIES LANGUAGE HIP
51
+ )
34
52
if (GINKGO_CUDA_CUSTOM_THRUST_NAMESPACE)
35
- target_compile_definitions (hipsparse_linops_${type} PRIVATE THRUST_CUB_WRAPPED_NAMESPACE=gko)
53
+ target_compile_definitions (
54
+ hipsparse_linops_${type}
55
+ PRIVATE THRUST_CUB_WRAPPED_NAMESPACE=gko
56
+ )
36
57
endif ()
37
58
target_compile_definitions (hipsparse_linops_${type} PUBLIC ${def} )
38
- target_compile_definitions (hipsparse_linops_${type} PRIVATE GKO_COMPILING_HIP)
39
- target_include_directories (hipsparse_linops_${type} SYSTEM PRIVATE ${HIPBLAS_INCLUDE_DIRS} ${HIPSPARSE_INCLUDE_DIRS} )
40
- target_link_libraries (hipsparse_linops_${type} PRIVATE Ginkgo::ginkgo ${HIPSPARSE_LIBRARIES} )
59
+ target_compile_definitions (
60
+ hipsparse_linops_${type}
61
+ PRIVATE GKO_COMPILING_HIP
62
+ )
63
+ target_include_directories (
64
+ hipsparse_linops_${type}
65
+ SYSTEM
66
+ PRIVATE ${HIPBLAS_INCLUDE_DIRS} ${HIPSPARSE_INCLUDE_DIRS}
67
+ )
68
+ target_link_libraries (
69
+ hipsparse_linops_${type}
70
+ PRIVATE Ginkgo::ginkgo ${HIPSPARSE_LIBRARIES}
71
+ )
41
72
ginkgo_compile_features(hipsparse_linops_${type} )
42
73
endfunction ()
43
74
44
75
function (ginkgo_benchmark_onemkl_linops type def)
45
76
add_library (onemkl_linops_${type} utils/dpcpp_linops.dp.cpp)
46
77
# make the dependency public to catch issues
47
78
target_compile_definitions (onemkl_linops_${type} PUBLIC ${def} )
48
- target_link_libraries (onemkl_linops_${type} PRIVATE Ginkgo::ginkgo MKL::MKL_DPCPP)
79
+ target_link_libraries (
80
+ onemkl_linops_${type}
81
+ PRIVATE Ginkgo::ginkgo MKL::MKL_DPCPP
82
+ )
49
83
ginkgo_compile_features(onemkl_linops_${type} )
50
84
endfunction ()
51
85
52
-
53
86
# gersemi: off
54
87
# Generates an executable for one precision. Each executable will be linked to
55
88
# `ginkgo`, `gflags` and `nlohmann-json`.
@@ -62,45 +95,50 @@ endfunction()
62
95
# building (to compile for a specific type)
63
96
# All remaining arguments will be treated as source files
64
97
# gersemi: on
65
- function (ginkgo_add_single_benchmark_executable name use_lib_linops macro_def type )
98
+ function (
99
+ ginkgo_add_single_benchmark_executable
100
+ name
101
+ use_lib_linops
102
+ macro_def
103
+ type
104
+ )
66
105
add_executable ("${name} " ${ARGN} )
67
106
target_link_libraries ("${name} " ginkgo gflags nlohmann_json::nlohmann_json)
68
107
# always include the device timer
69
- if (GINKGO_BUILD_CUDA)
108
+ if (GINKGO_BUILD_CUDA)
70
109
target_compile_definitions ("${name} " PRIVATE HAS_CUDA_TIMER=1)
71
110
target_link_libraries ("${name} " cuda_timer)
72
111
endif ()
73
- if (GINKGO_BUILD_HIP)
112
+ if (GINKGO_BUILD_HIP)
74
113
target_compile_definitions ("${name} " PRIVATE HAS_HIP_TIMER=1)
75
114
target_link_libraries ("${name} " hip_timer)
76
115
endif ()
77
- if (GINKGO_BUILD_SYCL)
116
+ if (GINKGO_BUILD_SYCL)
78
117
target_compile_definitions ("${name} " PRIVATE HAS_DPCPP_TIMER=1)
79
118
target_link_libraries ("${name} " dpcpp_timer)
80
119
endif ()
81
- if (GINKGO_BUILD_MPI)
120
+ if (GINKGO_BUILD_MPI)
82
121
target_compile_definitions (${name} PRIVATE HAS_MPI_TIMER=1)
83
122
target_link_libraries (${name} mpi_timer)
84
123
endif ()
85
124
target_compile_definitions ("${name} " PRIVATE "${macro_def} " )
86
125
ginkgo_benchmark_add_tuning_maybe("${name} " )
87
126
if ("${use_lib_linops} " )
88
- if (GINKGO_BUILD_CUDA)
127
+ if (GINKGO_BUILD_CUDA)
89
128
target_compile_definitions ("${name} " PRIVATE HAS_CUDA=1)
90
129
target_link_libraries ("${name} " cusparse_linops_${type} )
91
130
endif ()
92
- if (GINKGO_BUILD_HIP)
131
+ if (GINKGO_BUILD_HIP)
93
132
target_compile_definitions ("${name} " PRIVATE HAS_HIP=1)
94
133
target_link_libraries ("${name} " hipsparse_linops_${type} )
95
134
endif ()
96
- if (GINKGO_BUILD_SYCL)
135
+ if (GINKGO_BUILD_SYCL)
97
136
target_compile_definitions ("${name} " PRIVATE HAS_DPCPP=1)
98
137
target_link_libraries ("${name} " onemkl_linops_${type} )
99
138
endif ()
100
139
endif ()
101
140
endfunction (ginkgo_add_single_benchmark_executable)
102
141
103
-
104
142
# gersemi: off
105
143
# Generates an executable for each supported precision. Each executable will be
106
144
# linked to `ginkgo`, `gflags` and `nlohmann-json`.
@@ -112,17 +150,20 @@ endfunction(ginkgo_add_single_benchmark_executable)
112
150
# gersemi: on
113
151
function (ginkgo_add_typed_benchmark_executables name use_lib_linops)
114
152
ginkgo_add_single_benchmark_executable(
115
- "${name} " "${use_lib_linops} " "GKO_BENCHMARK_USE_DOUBLE_PRECISION" "d" ${ARGN} )
153
+ "${name} " "${use_lib_linops} " "GKO_BENCHMARK_USE_DOUBLE_PRECISION" "d" ${ARGN}
154
+ )
116
155
ginkgo_add_single_benchmark_executable(
117
- "${name} _single" "${use_lib_linops} " "GKO_BENCHMARK_USE_SINGLE_PRECISION" "s" ${ARGN} )
156
+ "${name} _single" "${use_lib_linops} " "GKO_BENCHMARK_USE_SINGLE_PRECISION" "s" ${ARGN}
157
+ )
118
158
ginkgo_add_single_benchmark_executable(
119
- "${name} _dcomplex" "${use_lib_linops} " "GKO_BENCHMARK_USE_DOUBLE_COMPLEX_PRECISION" "z" ${ARGN} )
159
+ "${name} _dcomplex" "${use_lib_linops} " "GKO_BENCHMARK_USE_DOUBLE_COMPLEX_PRECISION" "z" ${ARGN}
160
+ )
120
161
ginkgo_add_single_benchmark_executable(
121
- "${name} _scomplex" "${use_lib_linops} " "GKO_BENCHMARK_USE_SINGLE_COMPLEX_PRECISION" "c" ${ARGN} )
162
+ "${name} _scomplex" "${use_lib_linops} " "GKO_BENCHMARK_USE_SINGLE_COMPLEX_PRECISION" "c" ${ARGN}
163
+ )
122
164
endfunction (ginkgo_add_typed_benchmark_executables)
123
165
124
-
125
- if (GINKGO_BUILD_CUDA)
166
+ if (GINKGO_BUILD_CUDA)
126
167
ginkgo_benchmark_cusparse_linops(d GKO_BENCHMARK_USE_DOUBLE_PRECISION)
127
168
ginkgo_benchmark_cusparse_linops(s GKO_BENCHMARK_USE_SINGLE_PRECISION)
128
169
ginkgo_benchmark_cusparse_linops(z GKO_BENCHMARK_USE_DOUBLE_COMPLEX_PRECISION)
@@ -131,7 +172,7 @@ if (GINKGO_BUILD_CUDA)
131
172
target_link_libraries (cuda_timer PRIVATE ginkgo CUDA::cudart)
132
173
ginkgo_compile_features(cuda_timer)
133
174
endif ()
134
- if (GINKGO_BUILD_HIP)
175
+ if (GINKGO_BUILD_HIP)
135
176
ginkgo_benchmark_hipsparse_linops(d GKO_BENCHMARK_USE_DOUBLE_PRECISION)
136
177
ginkgo_benchmark_hipsparse_linops(s GKO_BENCHMARK_USE_SINGLE_PRECISION)
137
178
ginkgo_benchmark_hipsparse_linops(z GKO_BENCHMARK_USE_DOUBLE_COMPLEX_PRECISION)
@@ -142,7 +183,7 @@ if (GINKGO_BUILD_HIP)
142
183
ginkgo_compile_features(hip_timer)
143
184
endif ()
144
185
145
- if (GINKGO_BUILD_SYCL)
186
+ if (GINKGO_BUILD_SYCL)
146
187
ginkgo_benchmark_onemkl_linops(d GKO_BENCHMARK_USE_DOUBLE_PRECISION)
147
188
ginkgo_benchmark_onemkl_linops(s GKO_BENCHMARK_USE_SINGLE_PRECISION)
148
189
ginkgo_benchmark_onemkl_linops(z GKO_BENCHMARK_USE_DOUBLE_COMPLEX_PRECISION)
@@ -154,7 +195,7 @@ if (GINKGO_BUILD_SYCL)
154
195
ginkgo_compile_features(dpcpp_timer)
155
196
endif ()
156
197
157
- if (GINKGO_BUILD_MPI)
198
+ if (GINKGO_BUILD_MPI)
158
199
add_library (mpi_timer ${Ginkgo_SOURCE_DIR} /benchmark/utils/mpi_timer.cpp)
159
200
target_link_libraries (mpi_timer PRIVATE ginkgo)
160
201
ginkgo_compile_features(mpi_timer)
@@ -169,14 +210,16 @@ add_subdirectory(solver)
169
210
add_subdirectory (sparse_blas)
170
211
add_subdirectory (spmv)
171
212
add_subdirectory (tools)
172
- if (GINKGO_BUILD_TESTS)
213
+ if (GINKGO_BUILD_TESTS)
173
214
add_subdirectory (test )
174
215
endif ()
175
216
176
217
configure_file (run_all_benchmarks.sh run_all_benchmarks.sh COPYONLY )
177
218
178
219
add_custom_target (benchmark)
179
220
add_custom_command (
180
- TARGET benchmark POST_BUILD
221
+ TARGET benchmark
222
+ POST_BUILD
181
223
COMMAND bash run_all_benchmarks.sh >/dev/null
182
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} )
224
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
225
+ )
0 commit comments