forked from etri/nest-compiler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
141 lines (121 loc) · 5.18 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
cmake_minimum_required(VERSION 3.5)
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
add_definitions(-fno-limit-debug-info)
endif()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/glow/cmake/modules")
project(NESTC C CXX)
option(NESTC_WITH_EVTA "Build the VTA backend" OFF)
option(NESTC_USE_VTASIM "Build the VTASIM" ON)
option(NESTC_EVTA_RUN_ON_ZCU102 "Run on ZCU102 board" OFF)
option(NESTC_EVTA_MULTI "use Multi-EVTA" OFF)
option(NESTC_USE_PRECOMPILED_EVTA_LIBRARY "use pre-compiled EVTA library" OFF)
option(NESTC_USE_PRECOMPILED_BUNDLE "use pre-compiled bundle code from nestc-data" OFF)
option(NESTC_OPENCL_TEST "Enable OpenCL TEST" OFF)
option(NESTC_CUDA_TEST "Enable CUDA TEST" OFF)
include(CTest)
include(NESTCTestSupport)
set(CMAKE_CXX_STANDARD 14)
set(CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(NESTC_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(NESTC_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
if(EXISTS ${NESTC_ROOT_DIR}/glow/tools/loader/Loader.h)
message(STATUS "Delete ${NESTC_ROOT_DIR}/glow/tools/loader/Loader.h")
execute_process(COMMAND ${CMAKE_COMMAND} -E remove -f ${NESTC_ROOT_DIR}/glow/tools/loader/Loader.h)
endif()
if(EXISTS ${NESTC_ROOT_DIR}/glow/tools/ClassGen/NodeBuilder.h)
message(STATUS "Delete ${NESTC_ROOT_DIR}/glow/tools/ClassGen/NodeBuilder.h")
execute_process(COMMAND ${CMAKE_COMMAND} -E remove -f ${NESTC_ROOT_DIR}/glow/tools/ClassGen/NodeBuilder.h)
endif()
if(EXISTS ${NESTC_ROOT_DIR}/glow/tools/ClassGen/MemberType.h)
message(STATUS "Delete ${NESTC_ROOT_DIR}/glow/tools/ClassGen/MemberType.h")
execute_process(COMMAND ${CMAKE_COMMAND} -E remove -f ${NESTC_ROOT_DIR}/glow/tools/ClassGen/MemberType.h)
endif()
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${NESTC_ROOT_DIR}/cmake/glow ${NESTC_ROOT_DIR}/glow)
if (NESTC_WITH_EVTA)
add_definitions(-DNESTC_WITH_VTAINTERPRETER=1)
set(NESTC_WITH_VTA ON)
else()
option(NESTC_WITH_VTAINTERPRETER "Build the VTAInterpreter backend" OFF)
set(NESTC_WITH_VTA OFF)
endif()
if (NESTC_WITH_EVTA)
message("NESTC WITH EVTA in graph cmake")
add_definitions(-DGLOW_WITH_VTA)
endif()
include_directories(BEFORE
${NESTC_ROOT_DIR}/
${NESTC_ROOT_DIR}/include
${NESTC_ROOT_DIR}/include/tools/loader
${NESTC_ROOT_DIR}/tools/ClassGen/
)
message(STATUS "START CMAKE TVM")
SET(USE_LLVM ON)
if(NESTC_OPENCL_TEST)
SET(USE_OPENCL ON)
endif()
if(NESTC_CUDA_TEST)
SET(USE_CUDA ON)
endif()
add_subdirectory(tvm)
if(NESTC_USE_PRECOMPILED_EVTA_LIBRARY)
include(FetchContent)
if(NESTC_EVTA_RUN_ON_ZCU102)
FetchContent_Populate(
VTALIB
URL https://gitlab.com/yongin.kwon/nestc-data/-/raw/master/lib/VTA/zcu102/21.12/vta.tar.gz
)
FetchContent_Populate(
ACL
URL https://gitlab.com/yongin.kwon/nestc-data/-/raw/master/lib/VTA/acl/acl.tar.gz
)
if(NESTC_EVTA_MULTI)
if(NESTC_EVTA_RUN_WITH_GENERIC_BUNDLE)
set(vtalib_location ${vtalib_SOURCE_DIR}/multi/generic)
else()
set(vtalib_location ${vtalib_SOURCE_DIR}/multi/acl)
endif()
else()
if(NESTC_EVTA_RUN_WITH_GENERIC_BUNDLE)
set(vtalib_location ${vtalib_SOURCE_DIR}/single/generic)
else()
set(vtalib_location ${vtalib_SOURCE_DIR}/single/acl)
endif()
endif()
link_directories(${acl_SOURCE_DIR})
else()
if(NESTC_EVTA_MULTI)
FetchContent_Populate(
VTALIB
URL https://gitlab.com/yongin.kwon/nestc-data/-/raw/master/lib/VTA/x86_sim/21.12/multi/vta.tar.gz
)
else()
FetchContent_Populate(
VTALIB
URL https://gitlab.com/yongin.kwon/nestc-data/-/raw/master/lib/VTA/x86_sim/21.12/single/vta.tar.gz
)
endif()
set(vtalib_location ${vtalib_SOURCE_DIR} )
endif()
link_directories(${vtalib_SOURCE_DIR})
add_library(VTABundle STATIC IMPORTED)
set_property(TARGET VTABundle PROPERTY IMPORTED_LOCATION
${vtalib_location}/libVTABundle.a )
add_library(vta_runtime STATIC IMPORTED)
set_target_properties( vta_runtime PROPERTIES IMPORTED_LOCATION
${vtalib_location}/libvta_runtime.a )
INCLUDE_DIRECTORIES(${vtalib_SOURCE_DIR}/include/Bundle/ ${vtalib_SOURCE_DIR}/include/simulator ${vtalib_SOURCE_DIR}/include/simulator/vta)
endif()
message(STATUS "START CMAKE GLOW")
add_subdirectory(glow)
get_property(NESTC_TEST_DEPENDS GLOBAL PROPERTY NESTC_TEST_DEPENDS)
get_property(ZCU102_TEST_DEPENDS GLOBAL PROPERTY ZCU102_TEST_DEPENDS)
get_property(MULTIEVTA_TEST_DEPENDS GLOBAL PROPERTY MULTIEVTA_TEST_DEPENDS)
add_custom_target(check_nestc COMMAND ${CMAKE_CTEST_COMMAND} -L NESTC
DEPENDS ${NESTC_TEST_DEPENDS} USES_TERMINAL)
add_custom_target(check_zcu102 COMMAND ${CMAKE_CTEST_COMMAND} -L ZCU102
DEPENDS ${ZCU102_TEST_DEPENDS} USES_TERMINAL)
add_custom_target(check_multievta COMMAND ${CMAKE_CTEST_COMMAND} -L MULTIEVTA
DEPENDS ${MULTIEVTA_TEST_DEPENDS} USES_TERMINAL)