-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
165 lines (124 loc) · 4.06 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
cmake_minimum_required(VERSION 3.16)
project(HaliVerExperiments)
include(CTest)
set(CMAKE_CXX_STANDARD 11) # or newer
set(CMAKE_CXX_STANDARD_REQUIRED YES)
set(CMAKE_CXX_EXTENSIONS NO)
set(CMAKE_PREFIX_PATH /haliver)
find_package(Halide REQUIRED)
set(OUTFILE halide.out)
function(build_unit_test)
set(options)
set(oneValueArgs TARGET DIR)
set(multiValueArgs LABELS)
cmake_parse_arguments(UT "${options}" "${oneValueArgs}"
"${multiValueArgs}" ${ARGN} )
add_executable(${UT_TARGET} ${UT_DIR}/${UT_TARGET}.cpp)
target_link_libraries(${UT_TARGET} PRIVATE Halide::Halide)
add_custom_command(
OUTPUT ${UT_TARGET}_front.pvl
COMMAND ./${UT_TARGET} ${UT_TARGET}_front front
DEPENDS ${UT_TARGET}
VERBATIM
)
add_test(NAME ${UT_TARGET}_front.pvl
COMMAND vct --backend-option --conditionalizePermissions --silicon-quiet ${UT_TARGET}_front.pvl
)
set_tests_properties(${UT_TARGET}_front.pvl PROPERTIES
LABELS ${UT_DIR}:front:${UT_LABELS}
)
foreach(V RANGE 3)
add_custom_command(
OUTPUT ${UT_TARGET}_${V}.c
COMMAND ./${UT_TARGET} ${UT_TARGET}_${V} ${V}
DEPENDS ${UT_TARGET}
VERBATIM
)
add_test(NAME ${UT_TARGET}_${V}.c
COMMAND vct --backend-option --conditionalizePermissions --silicon-quiet ${UT_TARGET}_${V}.c
)
set_tests_properties(${UT_TARGET}_${V}.c PROPERTIES
LABELS ${UT_DIR}:back:${UT_LABELS}
)
endforeach()
foreach(V RANGE 3)
add_custom_command(
OUTPUT ${UT_TARGET}_${V}_mem.c
COMMAND ./${UT_TARGET} ${UT_TARGET}_${V}_mem ${V} mem
DEPENDS ${UT_TARGET}
VERBATIM
)
add_test(NAME ${UT_TARGET}_${V}_mem.c
COMMAND vct --backend-option --conditionalizePermissions --silicon-quiet ${UT_TARGET}_${V}_mem.c
)
set_tests_properties(${UT_TARGET}_${V}_mem.c PROPERTIES
LABELS ${UT_DIR}:back:${UT_LABELS}:mem
)
endforeach()
add_custom_target(
${UT_TARGET}_pvl ALL
DEPENDS ${UT_TARGET}_front.pvl ${UT_TARGET}_0.c
${UT_TARGET}_1.c ${UT_TARGET}_2.c ${UT_TARGET}_3.c
)
add_custom_target(
${UT_TARGET}_pvl_mem ALL
DEPENDS ${UT_TARGET}_0_mem.c
${UT_TARGET}_1_mem.c ${UT_TARGET}_2_mem.c ${UT_TARGET}_3_mem.c
)
endfunction()
function(build_single_unit_test)
set(options)
set(oneValueArgs TARGET DIR)
set(multiValueArgs LABELS)
cmake_parse_arguments(UT "${options}" "${oneValueArgs}"
"${multiValueArgs}" ${ARGN} )
add_executable(${UT_TARGET} ${UT_DIR}/${UT_TARGET}.cpp)
target_link_libraries(${UT_TARGET} PRIVATE Halide::Halide)
add_custom_command(
OUTPUT ${UT_TARGET}_mem.c
COMMAND ./${UT_TARGET} ${UT_TARGET}_mem
DEPENDS ${UT_TARGET}
VERBATIM
)
add_custom_target(
${UT_TARGET}_pvl ALL
DEPENDS ${UT_TARGET}_mem.c
)
add_test(NAME ${UT_TARGET}_mem.c
COMMAND vct --backend-option --conditionalizePermissions --silicon-quiet ${UT_TARGET}_mem.c
)
set_tests_properties(${UT_TARGET}_mem.c PROPERTIES
LABELS ${UT_DIR}:back:${UT_LABELS}
)
endfunction()
build_unit_test(TARGET blur DIR src)
build_unit_test(TARGET hist DIR src)
build_unit_test(TARGET conv_layer DIR src)
build_unit_test(TARGET gemm DIR src)
build_unit_test(TARGET auto_viz DIR src)
# build_single_unit_test(TARGET bgu DIR bgu)
build_single_unit_test(TARGET bilateral_grid DIR src)
build_single_unit_test(TARGET camera_pipe DIR src)
build_single_unit_test(TARGET depthwise_separable_conv DIR src)
function(build_lesson)
set(options)
set(oneValueArgs TARGET DIR)
set(multiValueArgs)
cmake_parse_arguments(UT "${options}" "${oneValueArgs}"
"${multiValueArgs}" ${ARGN} )
add_executable(${UT_TARGET} ${UT_DIR}/${UT_TARGET}.cpp)
target_link_libraries(${UT_TARGET} PRIVATE Halide::Halide)
add_custom_command(
OUTPUT ${UT_TARGET}_all_files
COMMAND ./${UT_TARGET}
DEPENDS ${UT_TARGET}
VERBATIM
)
add_custom_target(
${UT_TARGET}_all ALL
DEPENDS ${UT_TARGET}_all_files
)
endfunction()
build_lesson(TARGET lesson1 DIR tutorial)
build_lesson(TARGET lesson2 DIR tutorial)
build_lesson(TARGET lesson3 DIR tutorial)