-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
84 lines (64 loc) · 3.04 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
cmake_minimum_required(VERSION 3.13.0)
project(brainstorm LANGUAGES CXX CUDA)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
include(cmake/utils/Utils.cmake)
include(cmake/utils/FindCUDA.cmake)
include(cmake/config/brainstorm.cmake)
# include(cmake/config/tvm.cmake) include(cmake/config/nnfusion.cmake)
brt_option(PTX_INFO "print ptx info for each cuda kernel" OFF)
include(cmake/modules/CUDA.cmake)
include(cmake/modules/Torch.cmake)
# IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) SET(CMAKE_INSTALL_PREFIX CACHE
# PATH <comment> FORCE) ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
# thirdparty libraries
# add_subdirectory(3rdparty/tvm)
# include directories
include_directories(${CMAKE_INCLUDE_PATH})
include_directories(include)
include_directories(SYSTEM 3rdparty/dmlc-core/include)
include_directories(SYSTEM 3rdparty/dlpack/include)
# include_directories(SYSTEM 3rdparty/tvm/include)
set(BRT_LINKER_LIBS "")
set(WARNING_FLAG -Wall)
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
message(STATUS "Build in Debug mode")
set(CMAKE_C_FLAGS "-O0 -g ${WARNING_FLAG} -fPIC ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "-O0 -g ${WARNING_FLAG} -fPIC ${CMAKE_CXX_FLAGS}")
set(CMAKE_CUDA_FLAGS
"-O0 -g -Xcompiler=-Wall -Xcompiler=-fPIC ${CMAKE_CUDA_FLAGS}")
else()
set(CMAKE_C_FLAGS "-O2 ${WARNING_FLAG} -fPIC ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "-O2 ${WARNING_FLAG} -fPIC ${CMAKE_CXX_FLAGS}")
set(CMAKE_CUDA_FLAGS
"-O2 -Xcompiler=-Wall -Xcompiler=-fPIC ${CMAKE_CUDA_FLAGS}")
set(BRT_VISIBILITY_FLAG "")
if(HIDE_PRIVATE_SYMBOLS)
message(STATUS "Hide private symbols...")
set(BRT_VISIBILITY_FLAG "-fvisibility=hidden")
endif(HIDE_PRIVATE_SYMBOLS)
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_CXX_COMPILER_VERSION
VERSION_GREATER 7.0)
set(CMAKE_CXX_FLAGS "-faligned-new ${CMAKE_CXX_FLAGS}")
endif()
list(APPEND BRT_LINKER_LIBS ${CMAKE_DL_LIBS})
set(CMAKE_CXX_FLAGS "-std=c++14 ${CMAKE_CXX_FLAGS}")
set(CMAKE_CUDA_STANDARD 14)
file(GLOB_RECURSE BRT_SOURCE CMAKE_CONFIGURE_DEPENDS "src/*.cc" "src/*.cu")
# remove srcs of extension for other frameworks, they will be compiled by python
brt_src_exclude(BRT_SOURCE "backend/torch")
file(GLOB_RECURSE BRT_INCLUDE CMAKE_CONFIGURE_DEPENDS "src/*.h" "include/*.h")
list(APPEND BRT_SRCS ${BRT_SOURCE} ${BRT_INCLUDE})
add_compile_definitions("USE_CUDA" "USE_CUBLAS")
add_library(brt SHARED ${BRT_SRCS})
target_include_directories(
brt PUBLIC "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
target_link_libraries(brt PUBLIC ${BRT_LINKER_LIBS})
# set_target_properties(brt PROPERTIES LINKER_LANGUAGE CXX)
file(GLOB_RECURSE BRT_TORCHSCRIPT_SOURCE CMAKE_CONFIGURE_DEPENDS "src/backend/torch/script.cc")
add_library(brt_torchscript SHARED ${BRT_TORCHSCRIPT_SOURCE})
target_compile_features(brt_torchscript PRIVATE cxx_std_14)
target_link_libraries(brt_torchscript "${TORCH_LIBRARIES}")
target_include_directories(brt_torchscript PUBLIC "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>" "${TORCH_INCLUDE_DIR}")
add_subdirectory(benchmark)
add_subdirectory(sample/cpp)