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 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376
|
# -*- mode: cmake -*-
cmake_minimum_required(VERSION 3.19.6)
# Add path for custom CMake modules.
list(APPEND CMAKE_MODULE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
# Load utility modules.
include(SwiftBenchmarkUtils)
set(SWIFT_BENCHMARK_BUILT_STANDALONE FALSE)
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
set(SWIFT_BENCHMARK_BUILT_STANDALONE TRUE)
endif()
if(SWIFT_BENCHMARK_SUBCMAKE_BUILD)
precondition(SWIFT_BENCHMARK_BUILT_STANDALONE
MESSAGE "If we are a subcmake build, we must be built standalone")
endif()
include(AddSwiftBenchmarkSuite)
#===-----------------------------------------------------------------------===#
# Declarative Description of Benchmarks
#===-----------------------------------------------------------------------===#
set(SWIFT_BENCH_MODULES
single-source/Ackermann
single-source/AngryPhonebook
single-source/AnyHashableWithAClass
single-source/Array2D
single-source/ArrayAppend
single-source/ArrayInClass
single-source/ArrayLiteral
single-source/ArrayOfGenericPOD
single-source/ArrayOfGenericRef
single-source/ArrayOfPOD
single-source/ArrayOfRef
single-source/ArrayRemoveAll
single-source/ArraySetElement
single-source/ArraySubscript
single-source/AsyncTree
single-source/BinaryFloatingPointConversionFromBinaryInteger
single-source/BinaryFloatingPointProperties
single-source/BitCount
single-source/Breadcrumbs
single-source/BucketSort
single-source/BufferFill
single-source/BufferFind
single-source/ByteSwap
single-source/COWTree
single-source/COWArrayGuaranteedParameterOverhead
single-source/CString
single-source/CSVParsing
single-source/Calculator
single-source/CaptureProp
single-source/ChaCha
single-source/ChainedFilterMap
single-source/CharacterLiteralsLarge
single-source/CharacterLiteralsSmall
single-source/CharacterProperties
single-source/CharacterRecognizer
single-source/Chars
single-source/ClassArrayGetter
single-source/CodableTest
single-source/Combos
single-source/CountAlgo
single-source/DataBenchmarks
single-source/DeadArray
single-source/DevirtualizeProtocolComposition
single-source/DictOfArraysToArrayOfDicts
single-source/DictTest
single-source/DictTest2
single-source/DictTest3
single-source/DictTest4
single-source/DictTest4Legacy
single-source/DictionaryBridge
single-source/DictionaryBridgeToObjC
single-source/DictionaryCompactMapValues
single-source/DictionaryCopy
single-source/DictionaryGroup
single-source/DictionaryKeysContains
single-source/DictionaryLiteralTest
single-source/DictionaryOfAnyHashableStrings
single-source/DictionaryRemove
single-source/DictionarySubscriptDefault
single-source/DictionarySwap
single-source/Differentiation
single-source/Diffing
single-source/DiffingMyers
single-source/DropFirst
single-source/DropLast
single-source/DropWhile
single-source/ErrorHandling
single-source/Exclusivity
single-source/ExistentialPerformance
single-source/Fibonacci
single-source/FindStringNaive
single-source/FlattenDistanceFromTo
single-source/FlattenList
single-source/FloatingPointConversion
single-source/FloatingPointParsing
single-source/FloatingPointPrinting
single-source/Hanoi
single-source/Hash
single-source/Histogram
single-source/HTTP2StateMachine
single-source/IndexPathTest
single-source/InsertCharacter
single-source/IntegerParsing
single-source/Integrate
single-source/IterateData
single-source/Join
single-source/KeyPathPerformanceTests
single-source/LazyFilter
single-source/LinkedList
single-source/LuhnAlgoEager
single-source/LuhnAlgoLazy
single-source/MapReduce
single-source/Memset
single-source/MirrorTest
single-source/MonteCarloE
single-source/MonteCarloPi
single-source/NSDictionaryCastToSwift
single-source/NSErrorTest
single-source/NSStringConversion
single-source/NaiveRangeReplaceableCollectionConformance
single-source/NibbleSort
single-source/NIOChannelPipeline
single-source/NopDeinit
single-source/ObjectAllocation
single-source/ObjectiveCBridging
single-source/ObjectiveCBridgingStubs
single-source/ObjectiveCNoBridgingStubs
single-source/ObserverClosure
single-source/ObserverForwarderStruct
single-source/ObserverPartiallyAppliedMethod
single-source/ObserverUnappliedMethod
single-source/OpaqueConsumingUsers
single-source/OpenClose
single-source/Phonebook
single-source/PointerArithmetics
single-source/PolymorphicCalls
single-source/PopFront
single-source/PopFrontGeneric
single-source/Prefix
single-source/PrefixWhile
single-source/Prims
single-source/PrimsNonStrongRef
single-source/ProtocolConformance
single-source/ProtocolDispatch
single-source/ProtocolDispatch2
single-source/QueueTest
single-source/RC4
single-source/RGBHistogram
single-source/Radix2CooleyTukey
single-source/RandomShuffle
single-source/RandomTree
single-source/RandomValues
single-source/RangeAssignment
single-source/RangeIteration
single-source/RangeOverlaps
single-source/RangeReplaceableCollectionPlusDefault
single-source/RecursiveOwnedParameter
single-source/ReduceInto
single-source/RemoveWhere
single-source/ReversedCollections
single-source/RomanNumbers
single-source/SIMDRandomMask
single-source/SIMDReduceInteger
# Disabled while layout prespecializations are experimental
#single-source/SimpleArraySpecialization
single-source/SequenceAlgos
single-source/SetTests
single-source/SevenBoom
single-source/Sim2DArray
single-source/SortArrayInClass
single-source/SortIntPyramids
single-source/SortLargeExistentials
single-source/SortLettersInPlace
single-source/SortStrings
single-source/StackPromo
single-source/StaticArray
single-source/StrComplexWalk
single-source/StrToInt
single-source/StringBuilder
single-source/StringComparison
single-source/StringDistance
single-source/StringEdits
single-source/StringEnum
single-source/StringInterpolation
single-source/StringMatch
single-source/StringRemoveDupes
single-source/StringRepeating
single-source/StringReplaceSubrange
single-source/StringSplitting
single-source/StringSwitch
single-source/StringTests
single-source/StringWalk
single-source/SubstringTest
single-source/Suffix
single-source/SuperChars
single-source/TwoSum
single-source/TypeFlood
single-source/UTF8Decode
single-source/UTF16Decode
single-source/Walsh
single-source/WordCount
single-source/XorLoop
cxx-source/CreateObjects
cxx-source/CxxSetToCollection
cxx-source/CxxStringConversion
cxx-source/CxxVectorSum
cxx-source/ReadAccessor
)
set(SWIFT_MULTISOURCE_SWIFT_BENCHES
multi-source/PrimsSplit
)
set(PrimsSplit_sources
multi-source/PrimsSplit/Prims.swift
multi-source/PrimsSplit/Prims_main.swift)
set(BENCH_DRIVER_LIBRARY_FLAGS)
if (SWIFT_RUNTIME_ENABLE_LEAK_CHECKER)
set(BENCH_DRIVER_LIBRARY_FLAGS -DSWIFT_RUNTIME_ENABLE_LEAK_CHECKER)
endif()
set(BENCH_LIBRARY_MODULES
utils/TestsUtils
# Disabled while layout prespecializations are experimental
#utils/SimpleArray
)
set(BENCH_DRIVER_LIBRARY_MODULES
utils/DriverUtils
)
#===-----------------------------------------------------------------------===#
# Build Configuration
#===-----------------------------------------------------------------------===#
# You have to delete CMakeCache.txt in the swift build to force a
# reconfiguration.
set(SWIFT_EXTRA_BENCH_CONFIGS CACHE STRING
"A semicolon separated list of benchmark configurations. \
Available configurations: <Optlevel>_SINGLEFILE, <Optlevel>_MULTITHREADED")
# Syntax for an optset: <optimization-level>_<configuration>
# where "_<configuration>" is optional.
if(NOT SWIFT_OPTIMIZATION_LEVELS)
set(SWIFT_OPTIMIZATION_LEVELS "Onone" "O" "Osize"
${SWIFT_EXTRA_BENCH_CONFIGS})
endif()
set(SWIFT_BENCHMARK_EXTRA_FLAGS "" CACHE STRING
"Extra options to pass to swiftc when building the benchmarks")
set(SWIFT_BENCHMARK_UNOPTIMIZED_DRIVER NO CACHE BOOL
"Build the benchmark driver utilities without optimization (default: no)")
if (SWIFT_BENCHMARK_BUILT_STANDALONE)
# This option's value must match the value of the same option used when
# building the swift runtime.
option(SWIFT_RUNTIME_ENABLE_LEAK_CHECKER
"Should the runtime be built with support for non-thread-safe leak detecting entrypoints"
FALSE)
endif()
set(SWIFT_BENCHMARK_NUM_O_ITERATIONS "" CACHE STRING
"Number of iterations to perform when running -O benchmarks via cmake")
set(SWIFT_BENCHMARK_NUM_ONONE_ITERATIONS "" CACHE STRING
"Number of iterations to perform when running -Onone benchmarks via cmake")
# Options for the default (= empty) configuration
set(BENCHOPTS "-whole-module-optimization")
option(SWIFT_BENCHMARK_GENERATE_OPT_VIEW
"Produce optimization view for benchmarks"
FALSE)
set(SWIFT_BENCHMARK_OPT_VIEWER "" CACHE FILEPATH
"Path to opt-viewer")
option(SWIFT_BENCHMARK_GENERATE_DEBUG_INFO
"Produce debug info for benchmarks"
TRUE)
if(SWIFT_BENCHMARK_OPT_VIEWER)
# If the path to the opt-viewer was specified manually and we have no access
# to the LLVM tree, assume we have the modules for the opt-viewer installed.
if(SWIFT_BENCHMARK_BUILT_STANDALONE)
set(LLVM_HAVE_OPT_VIEWER_MODULES 1)
endif()
else()
set (SWIFT_BENCHMARK_OPT_VIEWER
"${LLVM_BUILD_MAIN_SRC_DIR}/tools/opt-viewer/opt-viewer.py")
endif()
# Options for other configurations
set(BENCHOPTS_MULTITHREADED
"-whole-module-optimization" "-num-threads" "4")
set(BENCHOPTS_SINGLEFILE "")
option(SWIFT_BENCHMARK_USE_OS_LIBRARIES
"Runtime link against the Swift libraries on the target (/usr/lib/swift)."
FALSE)
configure_build()
#===-----------------------------------------------------------------------===#
# SDK Configuration
#===-----------------------------------------------------------------------===#
configure_sdks()
#===---------------------------------------------------------------------===#
# Statement of Configuration for Build Users
#===---------------------------------------------------------------------===#
message("--")
message("-- Swift Benchmark Suite:")
message("-- SWIFT_BENCHMARK_BUILT_STANDALONE = ${SWIFT_BENCHMARK_BUILT_STANDALONE}")
message("-- SWIFT_BENCHMARK_USE_OS_LIBRARIES = ${SWIFT_BENCHMARK_USE_OS_LIBRARIES}")
message("-- SWIFT_EXEC = ${SWIFT_EXEC}")
message("-- SWIFT_LIBRARY_PATH = ${SWIFT_LIBRARY_PATH}")
if (SWIFT_RPATH_BASE)
message("-- SWIFT_RPATH_BASE = ${SWIFT_RPATH_BASE}")
endif()
if (SWIFT_RPATH)
message("-- SWIFT_RPATH = ${SWIFT_RPATH}")
message("--- ** WARNING ** Benchmarking against Swift-in-the-OS")
endif()
message("-- CLANG_EXEC = ${CLANG_EXEC}")
message("-- SWIFT_BENCHMARK_EXTRA_FLAGS = ${SWIFT_BENCHMARK_EXTRA_FLAGS}")
message("-- SWIFT_OPTIMIZATION_LEVELS = ${SWIFT_OPTIMIZATION_LEVELS}")
message("-- ONLY_PLATFORMS = ${ONLY_PLATFORMS}")
message("-- PAGE_ALIGNMENT_OPTION = ${PAGE_ALIGNMENT_OPTION}")
message("-- found platforms: ${platforms}")
message("-- found sdks:")
foreach(sdk ${sdks})
message("-- ${sdk}")
endforeach()
#===---------------------------------------------------------------------===#
# Build Rule Generation
#===---------------------------------------------------------------------===#
set(executable_targets)
set(srcdir "${CMAKE_CURRENT_SOURCE_DIR}")
if(SWIFT_BENCHMARK_BUILT_STANDALONE)
set(swift-bin-dir "${CMAKE_BINARY_DIR}/bin")
else()
get_filename_component(swift-bin-dir "${SWIFT_EXEC}" DIRECTORY)
endif()
set(benchmark-bin-dir "${CMAKE_CURRENT_BINARY_DIR}/bin")
set(benchmark-lib-dir "${CMAKE_CURRENT_BINARY_DIR}/lib")
set(benchmark-lib-swift-dir "${CMAKE_CURRENT_BINARY_DIR}/lib/swift")
file(MAKE_DIRECTORY "${swift-bin-dir}")
file(MAKE_DIRECTORY "${benchmark-bin-dir}")
file(MAKE_DIRECTORY "${benchmark-lib-dir}")
file(MAKE_DIRECTORY "${benchmark-lib-swift-dir}")
# Compile the perf test suite for each platform
foreach(platform ${platforms})
swift_benchmark_compile(PLATFORM ${platform})
endforeach()
add_subdirectory(scripts)
|