-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
206 lines (161 loc) · 5.44 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
cmake_minimum_required(VERSION 3.1)
project(chill)
file(STRINGS ${CMAKE_SOURCE_DIR}/CHILL_VERSION CHILL_VERSION)
set(CMAKE_CXX_STANDARD 11)
message(STATUS "Configuring for chill ${CHILL_VERSION}")
if (DEFINED ENV{CHILLENV})
set(CHILLENV $ENV{CHILLENV})
endif ()
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
if (NOT DEFINED FRONTEND)
set(FRONTEND "Rose")
endif ()
# Rose/calculator_eval.cc
find_package(RoseBoost REQUIRED)
if (${FRONTEND} STREQUAL "Rose")
find_package(Rose REQUIRED)
elseif (${FRONTEND} STREQUAL "Clang")
find_package(LLVM CONFIG REQUIRED)
find_package(Clang REQUIRED)
else ()
message(FATAL_ERROR "Unrecognized frontend option ${FRONTEND}")
endif()
include(GTest)
include(CHiLLModule)
find_package(PythonLibs 2.7 REQUIRED)
find_package(IEGen REQUIRED)
string(TIMESTAMP build_date "\\\"%m/%d/%Y\\\"")
set(CORE_LIBS
m rt util omega_lib omega_basic codegen codegen_chill dl
${IEGen_LIBS})
add_chill_module(chill_io
chill_io.cc
)
add_chill_module(chill_core
dep.cc
irtools.cc
loop.cc
loop_basic.cc
loop_datacopy.cc
loop_extra.cc
loop_tile.cc
loop_unroll.cc
loop_stencil.cc
loop_ghostcells.cc
loop_sparse.cc
loop_omp.cc
loop_by_index.cc
omegatools.cc
stencil.cc
calculator_eval.cc
)
add_chill_module(chill_ir
ir_chill.cc
)
add_chill_module(chill_cuda
mem_mapping_utils.cc
loop_cuda.cc
loop_cuda_chill.cc
ir_cudachill.cc
)
set(PYTHON_SRC
chillmodule.cc
)
add_chill_module(chill_ast
chill_ast.cc
)
set(COMMON_FLAGS "-DCHILL_BUILD_DATE=\"${build_date}\" -DCHILL_BUILD_VERSION=\"\\\"${CHILL_VERSION}\\\"\"")
set(CMAKE_CXX_FLAGS "-DPYTHON ${COMMON_FLAGS} ${CMAKE_CXX_FLAGS}")
if (DEFINED OMEGAHOME)
link_directories(${OMEGAHOME}/lib)
set(OMEGA_INC ${OMEGAHOME}/include)
else ()
set(OMEGA_INC
${CMAKE_CURRENT_SOURCE_DIR}/omega/omega_lib/include
${CMAKE_CURRENT_SOURCE_DIR}/omega/basic/include
${CMAKE_CURRENT_SOURCE_DIR}/omega/code_gen/include
)
endif ()
set(CHILL_INC ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include/chill)
find_package(BISON)
find_package(FLEX)
FLEX_TARGET(ExprScanner parse_expr.ll ${CMAKE_CURRENT_BINARY_DIR}/parse_expr.yy.cc COMPILE_FLAGS
"--header-file=${CMAKE_CURRENT_BINARY_DIR}/parse_expr.ll.hh") # Hack to avoid generating header in root
BISON_TARGET(ExprParser parse_expr.yy ${CMAKE_CURRENT_BINARY_DIR}/parse_expr.tab.cc COMPILE_FLAGS "-t -d")
ADD_FLEX_BISON_DEPENDENCY(ExprScanner ExprParser)
include_directories(
${CHILL_INC}
${CMAKE_CURRENT_BINARY_DIR}
)
add_chill_module(parseRel
chill_run_util.cc
${FLEX_ExprScanner_OUTPUTS}
${BISON_ExprParser_OUTPUTS}
)
include_directories(
${CHILL_INC}
${OMEGA_INC}
${RoseBoost_INCLUDE_DIRS}
${Rose_INCLUDE_DIRS}
${IEGen_INCLUDE_DIRS}
${PYTHON_INCLUDE_DIRS})
set(chill-libs
parseRel omega_basic omega_lib codegen codegen_chill
chill_core chill_ir chill_parser chill_ast chill_printer chill_io)
add_subdirectory(omega/basic)
add_subdirectory(omega/omega_lib)
add_subdirectory(omega/code_gen)
add_subdirectory(omega/omega_calc)
add_subdirectory(src/printer)
add_subdirectory(src/scanner)
add_subdirectory(src/parser)
add_subdirectory(docs)
add_subdirectory(unittests)
# Executables
add_executable(chill
chill_run.cc
${PYTHON_SRC}
)
chill_link_libraries(chill
chill_io chill_ir chill_ast chill_parser chill_core chill_printer chill_scanner parseRel
${CORE_LIBS}
${PYTHON_LIBRARY}
)
add_dependencies(chill ${chill-libs})
target_compile_definitions(chill
PRIVATE
${FRONTEND_DEFINITIONS})
install(TARGETS chill
RUNTIME DESTINATION bin)
add_executable(cuda-chill
chill_run.cc
${PYTHON_SRC}
)
chill_link_libraries(cuda-chill
chill_cuda chill_io chill_ir chill_ast chill_parser chill_core chill_printer chill_scanner parseRel
${CORE_LIBS}
${PYTHON_LIBRARY})
add_dependencies(cuda-chill ${chill-libs} chill_cuda)
target_compile_definitions(cuda-chill
PRIVATE
CUDACHILL
${FRONTEND_DEFINITIONS})
install(TARGETS cuda-chill
RUNTIME DESTINATION bin)
# setup tests
set(TD_PATH ${CMAKE_BINARY_DIR}/test-chill/Testdriver.py)
set(EE_PATH ${CMAKE_BINARY_DIR}/tests/e2e)
add_custom_command(OUTPUT ${TD_PATH}
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/test-chill ${CMAKE_BINARY_DIR}/test-chill
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/examples ${CMAKE_BINARY_DIR}/tests/e2e
COMMAND ${CMAKE_BINARY_DIR}/test-chill/make_chill_testcases.sh chill tests/e2e/chill/testcases tests/e2e/chill/testcases/RIGHTANSWERS > /dev/null
COMMAND ${CMAKE_BINARY_DIR}/test-chill/make_chill_testcases.sh cuda-chill tests/e2e/cuda-chill/testcases tests/e2e/cuda-chill/testcases/RIGHTANSWERS > /dev/null
DEPENDS UnitTests
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
add_custom_target(check-all
COMMAND ${CMAKE_COMMAND} -E env "SRCDIR=${CMAKE_BINARY_DIR}" ${TD_PATH} ${CMAKE_BINARY_DIR}/tests/unittests ${CMAKE_BINARY_DIR}/test-chill
DEPENDS ${TD_PATH} chill cuda-chill
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)