-
Notifications
You must be signed in to change notification settings - Fork 15
/
CMakeLists.txt
359 lines (330 loc) · 14.3 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
cmake_minimum_required(VERSION 3.10...3.13.5 FATAL_ERROR)
project(benchmarks)
set(CMAKE_CXX_STANDARD 17)
set(CAF_TAG "master" CACHE STRING "CAF tag or branch name for bundled builds")
# -- includes ------------------------------------------------------------------
include(FetchContent) # For bundling CAF with the incubator
if(NOT CMAKE_CROSSCOMPILING)
# Check whether the user already provided flags that enable C++ >= 17.
try_compile(caf_has_cxx_17
"${CMAKE_CURRENT_BINARY_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/check-compiler-features.cpp")
# Try enabling C++17 mode if user-provided flags aren't sufficient.
if(NOT caf_has_cxx_17)
if(MSVC)
set(cxx_flag "/std:c++17")
else()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang"
AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5)
set(cxx_flag "-std=c++1z")
else()
set(cxx_flag "-std=c++17")
endif()
endif()
# Re-run compiler check.
try_compile(caf_has_cxx_17
"${CMAKE_CURRENT_BINARY_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/check-compiler-features.cpp"
COMPILE_DEFINITIONS "${cxx_flag}"
OUTPUT_VARIABLE cxx_check_output)
if(NOT caf_has_cxx_17)
MESSAGE(FATAL_ERROR "\nFatal error: unable activate C++17 mode!\
\nPlease see README.md for supported compilers.\
\n\ntry_compile output:\n${cxx_check_output}")
endif()
add_compile_options("${cxx_flag}")
endif()
endif()
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
add_custom_target(all_benchmarks ALL)
include_directories(${CAF_INCLUDE_DIRS})
# -- store paths to tools and scripts for sub directory files ------------------
set(TOOLS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/tools")
set(SCRIPTS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/scripts")
# -- utility -------------------------------------------------------------------
macro(add_xxx_benchmark benchname dir name src_ending bin_ending out_path)
set(OUT_FILE ${out_path}/${name}.${bin_ending})
set(SRC_FILE ${CMAKE_CURRENT_SOURCE_DIR}/src/${dir}/${name}.${src_ending})
set(CAF_${benchname}_SRC_FILES ${SRC_FILE} ${CAF_${benchname}_SRC_FILES})
set(CAF_${benchname}_${name}_OUT ${OUT_FILE})
set(CAF_${benchname}_OUT_FILES ${OUT_FILE} ${CAF_${benchname}_OUT_FILES})
add_custom_command(OUTPUT ${OUT_FILE}
COMMAND ${CAF_${benchname}_COMPILER}
${CAF_${benchname}_COMPILER_OPTS}
${SRC_FILE}
DEPENDS ${SRC_FILE} ${ARGN}
WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
VERBATIM)
endmacro()
# make files show up in GUI even if not building a particular benchmark
macro(add_dummy_target benchname src_ending)
# check all aditional dependency flags
set(globstr "${CMAKE_CURRENT_SOURCE_DIR}/src/${benchname}/*.${src_ending}")
foreach(additional_ending ${ARGN})
set(globstr ${globstr}
"${CMAKE_CURRENT_SOURCE_DIR}/src/${benchname}/*.${additional_ending}")
endforeach()
file(GLOB_RECURSE source_files ${globstr})
add_custom_target(caf_${benchname}_dummy SOURCES ${source_files})
endmacro()
# -- Scala ---------------------------------------------------------------------
# search for Scala compiler if not disabled by the user
if(NOT CAF_NO_SCALA_BENCHMARKS)
if(NOT CAF_SCALA_COMPILER)
set(CAF_SCALA_COMPILER "scalac")
endif()
execute_process(COMMAND "${CAF_SCALA_COMPILER}" "-version"
RESULT_VARIABLE ScalacResult
ERROR_VARIABLE ScalacVersionStr)
if(ScalacResult EQUAL 0)
string(REGEX REPLACE ".*version ([0-9]+\\.[0-9]+\\.[0-9]+).*" "\\1"
ScalacVersion "${ScalacVersionStr}")
if(ScalacVersion VERSION_LESS 2.10)
message(STATUS "Disable Scala benchmarks: version >= 2.10 required,"
"${ScalacVersion} found")
set(CAF_NO_SCALA_BENCHMARKS yes)
endif()
else()
message(STATUS "Disable Scala benchmarks: no running compiler found")
set(CAF_NO_SCALA_BENCHMARKS yes)
endif()
endif()
# add targets for Scala benchmarks
if(NOT CAF_NO_SCALA_BENCHMARKS)
message(STATUS "Add Scala benchmarks to build (found ${ScalacVersion})")
set(CLASS_PATH ${EXECUTABLE_OUTPUT_PATH}/org/caf/scala)
set(CAF_SCALA_COMPILER_OPTS -optimize)
macro(add_scala_benchmark name)
add_xxx_benchmark(SCALA scala ${name} scala class ${CLASS_PATH} ${ARGN})
endmacro()
add_scala_benchmark(utility)
add_scala_benchmark(actor_creation ${CAF_SCALA_utility_OUT})
add_scala_benchmark(mailbox_performance ${CAF_SCALA_utility_OUT})
add_scala_benchmark(mixed_case ${CAF_SCALA_utility_OUT})
add_scala_benchmark(mandelbrot ${CAF_SCALA_utility_OUT})
add_custom_target(scala_benchmarks
SOURCES ${CAF_SCALA_SRC_FILES}
DEPENDS ${CAF_SCALA_OUT_FILES})
add_dependencies(all_benchmarks scala_benchmarks)
else()
add_dummy_target(scala scala)
endif()
# -- SALSA ---------------------------------------------------------------------
if(NOT CAF_NO_SALSA_BENCHMARKS)
if(NOT CAF_SALSA_JAR)
# try find it in home directory
set(CAF_SALSA_JAR "$ENV{HOME}/SalsaLite.jar")
endif()
if(NOT EXISTS "${CAF_SALSA_JAR}")
message(STATUS "Disable SALSA benchmarks: salsa JAR file not found")
set(CAF_NO_SALSA_BENCHMARKS yes)
else()
if(NOT CAF_JAVA_BIN)
set(CAF_JAVA_BIN "java")
endif()
execute_process(COMMAND "${CAF_JAVA_BIN}" "-version"
RESULT_VARIABLE JavaResult
ERROR_VARIABLE JavaVersionStr)
if(JavaResult EQUAL 0)
string(REGEX REPLACE ".*version \"([0-9]+\\.[0-9]+\\.[0-9_]+)\".*" "\\1"
JavaVersion "${JavaVersionStr}")
else()
message(STATUS "Disable SALSA benchmarks: unable to run java")
set(CAF_NO_SALSA_BENCHMARKS yes)
endif()
if(NOT CAF_JAVA_COMPILER)
set(CAF_JAVA_COMPILER "javac")
endif()
execute_process(COMMAND "${CAF_JAVA_COMPILER}" "-version"
RESULT_VARIABLE JavacResult
ERROR_VARIABLE JavacVersionStr)
if(JavacResult EQUAL 0)
string(REGEX REPLACE ".*version \"([0-9]+\\.[0-9]+\\.[0-9_]+)\".*" "\\1"
JavacVersion "${JavacVersionStr}")
else()
message(STATUS "Disable SALSA benchmarks: unable to run java")
set(CAF_NO_SALSA_BENCHMARKS yes)
endif()
endif()
else()
set(CAF_SALSA_JAR "")
endif()
# add targets for SALSA benchmarks
if(NOT CAF_NO_SALSA_BENCHMARKS)
set(CLASS_PATH ${EXECUTABLE_OUTPUT_PATH}/org/caf/salsa)
set(JAVAC_OPTS -cp "${CAF_SALSA_JAR}:." -d ${EXECUTABLE_OUTPUT_PATH})
set(SALSA_OPTS -cp "${CAF_SALSA_JAR}:." salsa_lite.compiler.SalsaCompiler)
message(STATUS "Add SALSA benchmarks to build (found ${JavaVersion})")
set(SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/salsa)
macro(add_salsa_benchmark salsa_files java_files class_files)
add_custom_command(OUTPUT ${java_files}
COMMAND ${CAF_JAVA_BIN} ${SALSA_OPTS} ${salsa_files}
DEPENDS ${salsa_files}
WORKING_DIRECTORY ${SRC_DIR}
VERBATIM)
add_custom_command(OUTPUT ${class_files}
COMMAND ${CAF_JAVA_COMPILER} ${JAVAC_OPTS} ${java_files}
DEPENDS ${java_files}
WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
VERBATIM)
endmacro()
# actor creation
set(ACTOR_CREATION_SALSA_FILES ${SRC_DIR}/actor_creation.salsa)
set(ACTOR_CREATION_JAVA_FILES ${SRC_DIR}/actor_creation.java)
set(ACTOR_CREATION_CLASS_FILES ${CLASS_PATH}/actor_creation.class)
add_salsa_benchmark("${ACTOR_CREATION_SALSA_FILES}"
"${ACTOR_CREATION_JAVA_FILES}"
"${ACTOR_CREATION_CLASS_FILES}")
# mixed case
set(MIXED_CASE_SALSA_FILES ${SRC_DIR}/chain_link.salsa
${SRC_DIR}/chain_master.salsa
${SRC_DIR}/supervisor.salsa
${SRC_DIR}/worker.salsa
${SRC_DIR}/mixed_case.salsa)
set(MIXED_CASE_JAVA_FILES ${SRC_DIR}/chain_link.java
${SRC_DIR}/chain_master.java
${SRC_DIR}/supervisor.java
${SRC_DIR}/worker.java
${SRC_DIR}/mixed_case.java)
set(MIXED_CASE_CLASS_FILES ${CLASS_PATH}/chain_link.class
${CLASS_PATH}/chain_master.class
${CLASS_PATH}/supervisor.class
${CLASS_PATH}/worker.class
${CLASS_PATH}/mixed_case.class)
add_salsa_benchmark("${MIXED_CASE_SALSA_FILES}"
"${MIXED_CASE_JAVA_FILES}"
"${MIXED_CASE_CLASS_FILES}")
# mailbox performance
set(MAILBOX_PERFORMANCE_SALSA_FILES
${SRC_DIR}/sender.salsa
${SRC_DIR}/receiver.salsa
${SRC_DIR}/mailbox_performance.salsa)
set(MAILBOX_PERFORMANCE_JAVA_FILES
${SRC_DIR}/sender.java
${SRC_DIR}/receiver.java
${SRC_DIR}/mailbox_performance.java)
set(MAILBOX_PERFORMANCE_CLASS_FILES
${CLASS_PATH}/sender.class
${CLASS_PATH}/receiver.class
${CLASS_PATH}/mailbox_performance.class)
add_salsa_benchmark("${MAILBOX_PERFORMANCE_SALSA_FILES}"
"${MAILBOX_PERFORMANCE_JAVA_FILES}"
"${MAILBOX_PERFORMANCE_CLASS_FILES}")
# mandelbrot
set(MANDELBROT_SALSA_FILES
${SRC_DIR}/mandelbrot.salsa
${SRC_DIR}/mandelbrot_worker.salsa)
set(MANDELBROT_JAVA_FILES
${SRC_DIR}/mandelbrot.java
${SRC_DIR}/mandelbrot_worker.java)
set(MANDELBROT_CLASS_FILES
${CLASS_PATH}/mandelbrot.class
${CLASS_PATH}/mandelbrot_worker.class)
add_salsa_benchmark("${MANDELBROT_SALSA_FILES}"
"${MANDELBROT_JAVA_FILES}"
"${MANDELBROT_CLASS_FILES}")
file(GLOB_RECURSE SALSA_SOURCES "${SRC_DIR}/*.salsa")
add_custom_target(salsa_benchmarks
SOURCES ${SALSA_SOURCES}
DEPENDS ${ACTOR_CREATION_CLASS_FILES}
${MIXED_CASE_CLASS_FILES}
${MAILBOX_PERFORMANCE_CLASS_FILES}
${MANDELBROT_CLASS_FILES})
add_dependencies(all_benchmarks salsa_benchmarks)
else()
add_dummy_target(salsa salsa)
endif()
# -- Erlang --------------------------------------------------------------------
# search for Erlang compiler if not disabled by the user
if(NOT CAF_NO_ERLANG_BENCHMARKS)
if(NOT CAF_ERLANG_COMPILER)
set(CAF_ERLANG_COMPILER "erlc")
endif()
execute_process(COMMAND "${CAF_ERLANG_COMPILER}"
RESULT_VARIABLE ErlangResult
ERROR_VARIABLE ErlangVersionStr)
if(NOT ErlangResult EQUAL 0)
message(STATUS "Disable Erlang benchmarks: no running compiler found")
set(CAF_NO_ERLANG_BENCHMARKS yes)
endif()
endif()
# add target for Erlang benchmarks
if(NOT CAF_NO_ERLANG_BENCHMARKS)
message(STATUS "Add Erlang benchmarks to build")
set(CAF_ERLANG_COMPILER_OPTS "+native" "+{hipe, [o3]}")
macro(add_erlang_benchmark name)
add_xxx_benchmark(ERLANG erlang ${name} erl beam
"${EXECUTABLE_OUTPUT_PATH}" ${ARGN})
endmacro()
add_erlang_benchmark(actor_creation)
add_erlang_benchmark(mailbox_performance)
add_erlang_benchmark(mixed_case)
add_erlang_benchmark(mandelbrot)
add_custom_target(erlang_benchmarks
SOURCES ${CAF_ERLANG_SRC_FILES}
DEPENDS ${CAF_ERLANG_OUT_FILES})
add_dependencies(all_benchmarks erlang_benchmarks)
else()
add_dummy_target(erlang erl)
endif()
# -- Charm++ -------------------------------------------------------------------
if(NOT CAF_NO_CHARM_BENCHMARK)
if(NOT CAF_CHARM_COMPILER)
set(CAF_CHARM_COMPILER "charmc")
endif()
execute_process(COMMAND "${CAF_CHARM_COMPILER}" -v
RESULT_VARIABLE CharmResult
ERROR_VARIABLE CharmVersionStr)
if(NOT CharmResult EQUAL 0)
message(STATUS "Disable Charm++ benchmarks: no running compiler found")
set(CAF_NO_CHARM_BENCHMARK yes)
endif()
endif()
# add target for Charm++ benchmarks
if(NOT CAF_NO_CHARM_BENCHMARK)
message(STATUS "Add Charm++ benchmarks to build")
set(CAF_CHARM_PATH "${CMAKE_CURRENT_SOURCE_DIR}/charm")
set(CAF_CHARM_COMPILER_OPTS -optimize)
macro(add_charm_benchmark name)
set(longname charm_${name})
set(longpath ${CAF_CHARM_PATH}/${longname})
set(CAF_CHARM_SRC_FILES ${longpath}.ci
${longpath}.cpp ${CAF_CHARM_SRC_FILES})
add_custom_command(OUTPUT ${longpath}.def.h ${longpath}.decl.h
COMMAND ${CAF_CHARM_COMPILER} ${longpath}.ci
DEPENDS ${longpath}.ci
WORKING_DIRECTORY ${CAF_CHARM_PATH}
VERBATIM)
add_custom_command(OUTPUT ${longpath}.o
COMMAND ${CAF_CHARM_COMPILER} -c ${longpath}.cpp
DEPENDS ${longpath}.cpp ${longpath}.def.h ${longpath}.decl.h
WORKING_DIRECTORY ${CAF_CHARM_PATH}
VERBATIM)
set(exe_file ${EXECUTABLE_OUTPUT_PATH}/${longname})
set(CAF_CHARM_OUT_FILES ${exe_file} ${CAF_CHARM_OUT_FILES})
add_custom_command(OUTPUT ${exe_file}
COMMAND ${CAF_CHARM_COMPILER} ${longpath}.o
-o ${exe_file} -O3 -language charm++
DEPENDS ${longpath}.o
WORKING_DIRECTORY ${CAF_CHARM_PATH}
VERBATIM)
endmacro()
add_charm_benchmark(actor_creation)
add_charm_benchmark(mailbox_performance)
add_charm_benchmark(mixed_case)
add_charm_benchmark(mandelbrot)
add_custom_target(charm_benchmarks
SOURCES ${CAF_CHARM_SRC_FILES}
DEPENDS ${CAF_CHARM_OUT_FILES})
add_dependencies(all_benchmarks charm_benchmarks)
else()
add_dummy_target(charm cpp ci)
endif()
# -- CAF -----------------------------------------------------------------------
add_subdirectory(src/caf)
# -- Scripts -------------------------------------------------------------------
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/scripts/caf_run_benchmarks.in"
"${SCRIPTS_DIR}/caf_run_benchmarks" @ONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/scripts/run.in"
"${SCRIPTS_DIR}/run" @ONLY)