forked from buddy-compiler/buddy-benchmark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
131 lines (107 loc) · 5.03 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
##===- CMakeLists.txt - buddy-benchmark cmake root ------------*- cmake -*-===//
##
## Configure the buddy-benchmark build.
##
##===----------------------------------------------------------------------===//
cmake_minimum_required(VERSION 3.10)
#-------------------------------------------------------------------------------
# Project setup and globals
#-------------------------------------------------------------------------------
project(buddy-benchmark LANGUAGES CXX C)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
set(CMAKE_CXX_FLAGS "-no-pie")
set(CMAKE_C_FLAGS "-no-pie")
#-------------------------------------------------------------------------------
# BUDDY configuration
#-------------------------------------------------------------------------------
set(BuddyMLIR_DIR ${BUDDY_MLIR_BUILD_DIR}/cmake)
find_package(BuddyMLIR REQUIRED CONFIG)
if(CROSS_COMPILE_RVV)
set(RISCV_GNU_TOOLCHAIN ${BUDDY_MLIR_BUILD_DIR}/thirdparty/riscv-gnu-toolchain)
set(RISCV_GNU_TOOLCHAIN_SYSROOT ${RISCV_GNU_TOOLCHAIN}/sysroot)
set(BUDDY_OPT_ATTR +v,+m CACHE STRING "Target Architecture.")
set(BUDDY_OPT_TRIPLE riscv64 CACHE STRING "Target Triple.")
set(BUDDY_MLIR_CROSS_LIB_DIR ${BUDDY_MLIR_BUILD_CROSS_DIR}/lib)
else()
set(BUDDY_OPT_ATTR avx512f CACHE STRING "Target Architecture.")
set(BUDDY_OPT_TRIPLE x86_64-unknown-linux-gnu CACHE STRING "Target Triple.")
set(BUDDY_MLIR_LIB_DIR ${BUDDY_MLIR_BUILD_DIR}/lib)
endif()
message(STATUS "Configuring Target Architecture: ${BUDDY_OPT_ATTR}")
message(STATUS "Configuring Target Triple: ${BUDDY_OPT_TRIPLE}")
# BUDDY project.
set(BUDDY_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(BUDDY_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/bin)
set(BUDDY_MLIR_BINARY_DIR ${BUDDY_MLIR_BUILD_DIR}/bin)
set(BUDDY_BENCHMARK_DEEP_LEARNING_DIR ${BUDDY_SOURCE_DIR}/benchmarks/DeepLearning)
set(BUILD_TESTS OFF CACHE BOOL "Build tests")
set(BUILD_VALIDATION OFF CACHE BOOL "Build validations")
set(BUILD_CORRECTNESS OFF CACHE BOOL "Build correctness checking")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BUDDY_BINARY_DIR})
# Add BUDDY files to the include path
include_directories(${BUDDY_MAIN_INCLUDE_DIR})
include_directories(${BUDDY_MLIR_INTERFACE_DIR})
include_directories(${BUDDY_THIRDPARTY_INCLUDE_DIR})
# MLIR binary directory.
set(LLVM_MLIR_BINARY_DIR ${BUDDY_MLIR_BUILD_DIR}/../llvm/build/bin)
set(LLVM_MLIR_LIBRARY_DIR ${BUDDY_MLIR_BUILD_DIR}/../llvm/build/lib)
# Helper functions.
include(${BUDDY_SOURCE_DIR}/cmake/buddy-benchmark.cmake)
# -------------------------------------------------------------------------------
# Deploy google/benchmark
# -------------------------------------------------------------------------------
message(STATUS "Configuring benchmarks: google")
include(ExternalProject)
ExternalProject_Add(project_googlebenchmark
GIT_REPOSITORY https://github.com/google/benchmark.git
GIT_TAG "v1.6.0"
GIT_SHALLOW 1
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/vendor/benchmark
TIMEOUT 10
BUILD_BYPRODUCTS <INSTALL_DIR>/lib/${CMAKE_STATIC_LIBRARY_PREFIX}benchmark${CMAKE_STATIC_LIBRARY_SUFFIX}
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/vendor/benchmark
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DBENCHMARK_ENABLE_TESTING=OFF
-DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}
-DCMAKE_SYSTEM_PROCESSOR=${CMAKE_SYSTEM_PROCESSOR}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
UPDATE_COMMAND ""
TEST_COMMAND "")
ExternalProject_Get_Property(project_googlebenchmark INSTALL_DIR)
file(MAKE_DIRECTORY ${INSTALL_DIR}/include)
add_library(GoogleBenchmark STATIC IMPORTED)
target_include_directories(GoogleBenchmark INTERFACE ${INSTALL_DIR}/include)
set_property(TARGET GoogleBenchmark PROPERTY IMPORTED_LOCATION
"${INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}benchmark${CMAKE_STATIC_LIBRARY_SUFFIX}")
add_dependencies(GoogleBenchmark project_googlebenchmark)
find_package(Threads)
target_link_libraries(GoogleBenchmark INTERFACE Threads::Threads)
# -------------------------------------------------------------------------------
# Find OpenCV
# -------------------------------------------------------------------------------
if(DEFINED IMAGE_PROCESSING_BENCHMARKS OR OP_OPTIMIZATION_BENCHMARKS)
find_package(OpenCV REQUIRED CONFIG)
include_directories(${OpenCV_INCLUDE_DIRS})
endif()
# -------------------------------------------------------------------------------
# Find PNG
# -------------------------------------------------------------------------------
if(DEFINED IMAGE_PROCESSING_BENCHMARKS)
find_package(PNG REQUIRED)
include_directories(${PNG_INCLUDE_DIR})
endif()
# -------------------------------------------------------------------------------
# Hardware detection
# -------------------------------------------------------------------------------
include(${BUDDY_SOURCE_DIR}/cmake/check-simd.cmake)
check_simd()
# -------------------------------------------------------------------------------
# Subdirectory
# -------------------------------------------------------------------------------
add_subdirectory(benchmarks)
add_subdirectory(utils)
if(BUILD_VALIDATION)
add_subdirectory(validation)
endif()