-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
120 lines (95 loc) · 4.15 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
# ===- CMakeLists.txt - HANDS_ON_MLIR-mlir cmake root -----------------*- cmake
# -*-===//
#
# Configure the HANDS_ON_MLIR-mlir build.
#
# ===----------------------------------------------------------------------===//
cmake_minimum_required(VERSION 3.10)
if(POLICY CMP0077)
cmake_policy(SET CMP0077 NEW)
endif()
if(POLICY CMP0116)
cmake_policy(SET CMP0116 OLD)
endif()
if(POLICY CMP0074)
cmake_policy(SET CMP0074 OLD)
endif()
# -------------------------------------------------------------------------------
# Project setup and globals
# -------------------------------------------------------------------------------
project(Hands-on-MLIR LANGUAGES CXX C)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
# -------------------------------------------------------------------------------
# Options and settings
# -------------------------------------------------------------------------------
option(LLVM_INCLUDE_TOOLS "Generate build targets for the LLVM tools." ON)
option(LLVM_BUILD_TOOLS
"Build the LLVM tools. If OFF, just generate build targets." ON)
# -------------------------------------------------------------------------------
# MLIR/LLVM Configuration
# -------------------------------------------------------------------------------
find_package(MLIR REQUIRED CONFIG)
set(LLVM_MLIR_BINARY_DIR ${MLIR_DIR}/../../../bin)
set(LLVM_MLIR_SOURCE_DIR ${MLIR_DIR}/../../../../mlir)
list(APPEND CMAKE_MODULE_PATH "${MLIR_CMAKE_DIR}")
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
include(TableGen)
include(AddLLVM)
include(AddMLIR)
include(HandleLLVMOptions)
# -------------------------------------------------------------------------------
# HANDS_ON_MLIR configuration
# -------------------------------------------------------------------------------
# HANDS_ON_MLIR project.
set(HANDS_ON_MLIR_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(HANDS_ON_MLIR_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/bin)
set(HANDS_ON_MLIR_INCLUDE_DIR ${HANDS_ON_MLIR_SOURCE_DIR}/include/)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${HANDS_ON_MLIR_BINARY_DIR})
set(HANDS_ON_MLIR_EXAMPLES
OFF
CACHE BOOL "Build examples")
# Add MLIR and LLVM headers to the include path
include_directories(${LLVM_INCLUDE_DIRS})
include_directories(${MLIR_INCLUDE_DIRS})
# Add HANDS_ON_MLIR files to the include path
include_directories(${HANDS_ON_MLIR_MAIN_INCLUDE_DIR})
include_directories(${HANDS_ON_MLIR_INCLUDE_DIR})
include_directories(${HANDS_ON_MLIR_INCLUDE_DIR}/Dialect)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/Dialect)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/include)
include_directories(${HANDS_ON_MLIR_SOURCE_DIR}/lib)
include_directories(${HANDS_ON_MLIR_SOURCE_DIR}/thirdparty/half-2.2.0/include)
# -------------------------------------------------------------------------------
# CUDA configuration
# -------------------------------------------------------------------------------
if(ENABLE_CUDA)
add_compile_definitions(ENABLE_CUDA)
enable_language(CUDA)
set(CMAKE_CUDA_STANDARD 17)
set(CMAKE_CUDA_STANDARD_REQUIRED YES)
find_package(CUDAToolkit REQUIRED)
include_directories(${HANDS_ON_MLIR_SOURCE_DIR}/thirdparty/cutlass/include)
include_directories(
${HANDS_ON_MLIR_SOURCE_DIR}/thirdparty/TransformerEngine/transformer_engine/common/include
)
include_directories(
${HANDS_ON_MLIR_SOURCE_DIR}/thirdparty/cutlass/tools/library/include)
include_directories(
${HANDS_ON_MLIR_SOURCE_DIR}/thirdparty/cutlass/tools/util/include)
include_directories(${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
link_directories(${HANDS_ON_MLIR_SOURCE_DIR}/thirdparty/TransformerEngine/)
add_link_options(-ltransformer_engine)
endif()
# -------------------------------------------------------------------------------
# Hardware detection
# -------------------------------------------------------------------------------
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/check_simd.cmake)
check_simd()
# -------------------------------------------------------------------------------
# Directory setup
# -------------------------------------------------------------------------------
add_subdirectory(cmake)
add_subdirectory(include)
add_subdirectory(lib)
add_subdirectory(tools)