-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
194 lines (170 loc) · 5.84 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
cmake_minimum_required(VERSION 3.17)
project(lightning-kit)
#
# CMake common settings
#
set(CMAKE_CXX_STANDARD 20)
#
# Dependent libraries
#
find_package(Threads REQUIRED)
find_package(PkgConfig REQUIRED)
# DPDK
pkg_check_modules(LIBDPDK libdpdk)
# DOCA
pkg_check_modules(LIBDOCAGPU doca-gpu)
# CUDA
find_package(CUDAToolkit)
# AVX
include(FindAVX.cmake)
if(CUDAToolkit_FOUND)
set(LNG_WITH_CUDA 1)
add_compile_definitions(LNG_WITH_CUDA=1)
set(CMAKE_CUDA_ARCHITECTURES 80)
enable_language(CUDA)
endif()
if(LIBDOCAGPU_FOUND)
set(LNG_WITH_DOCA 1)
add_compile_definitions(LNG_WITH_DOCA=1)
endif()
if(LIBDPDK_FOUND)
set(LNG_WITH_DPDK 1)
add_compile_definitions(LNG_WITH_DPDK=1)
endif()
#
# Version
#
execute_process(COMMAND git describe --tags
OUTPUT_VARIABLE GIT_DESCRIBE_RESULT
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
string(STRIP "${GIT_DESCRIBE_RESULT}" LNG_KIT_VERSION_S)
message(STATUS "Version: ${LNG_KIT_VERSION_S}")
add_definitions("-DLNG_KIT_VERSION=\"${LNG_KIT_VERSION_S}\"")
string(REPLACE "v" "" LNG_KIT_VERSION "${LNG_KIT_VERSION_S}")
file(GENERATE OUTPUT ${PROJECT_BINARY_DIR}/VERSION CONTENT "${LNG_KIT_VERSION_S}")
#
# Build main library
#
set(LNG_CORE_SRC
src/actor.cc
src/receiver-actor.cc
src/receiver-actor.cu
src/event.cc
src/log.cc
src/runtime.cc
src/stream.cc
src/system.cc
)
if(LNG_WITH_CUDA AND LNG_WITH_DOCA)
list(APPEND LNG_CORE_SRC
src/receiver-actor-gpu.cc
src/protocol_tcp.cu
src/protocol_udp.cu)
endif()
if(LNG_WITH_DOCA)
list(APPEND LNG_CORE_SRC
src/doca-common-util.cc
src/doca-common-util-internal.cc
src/doca-stream.cc
src/doca-tcp-util.cc
src/doca-udp-util.cc
)
endif()
add_library(lng-core ${LNG_CORE_SRC})
set(LNG_CORE_INCLUDE_DIRECTORIES_PUBLIC ${PROJECT_SOURCE_DIR}/include)
set(LNG_CORE_INCLUDE_DIRECTORIES_PRIVATE ${PROJECT_SOURCE_DIR}/src)
set(LNG_CORE_COMPILE_OPTIONS_PUBLIC ${LATEST_AVX_FLAGS})
set(LNG_CORE_COMPILE_OPTIONS_PRIVATE)
set(LNG_CORE_LINK_LIBRARIES_PUBLIC Threads::Threads)
set(LNG_CORE_LINK_LIBRARIES_PRIVATE)
if(LNG_WITH_CUDA)
list(APPEND LNG_CORE_COMPILE_OPTIONS_PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:-lineinfo --default-stream per-thread --diag-suppress 177,550,1217,3010>)
list(APPEND LNG_CORE_LINK_LIBRARIES_PRIVATE CUDA::cudart)
set_target_properties(lng-core
PROPERTIES
CUDA_SEPARABLE_COMPILATION ON
CUDA_RESOLVE_DEVICE_SYMBOLS ON
)
endif()
if(LNG_WITH_DOCA)
list(APPEND LNG_CORE_COMPILE_OPTIONS_PUBLIC ${LIBDOCAGPU_STATIC_CFLAGS} "-Wno-volatile" "-Wno-deprecated-declarations")
list(APPEND LNG_CORE_LINK_LIBRARIES_PUBLIC ${LIBDOCAGPU_STATIC_LDFLAGS})
list(APPEND LNG_CORE_LINK_LIBRARIES_PRIVATE ${LIBDOCAGPU_LIBDIR}/libdoca_gpunetio_device.a)
endif()
if(LNG_WITH_DPDK)
list(APPEND LNG_CORE_COMPILE_OPTIONS_PUBLIC ${LIBDPDK_STATIC_CFLAGS})
list(APPEND LNG_CORE_LINK_LIBRARIES_PUBLIC ${LIBDPDK_STATIC_LDFLAGS})
endif()
target_include_directories(lng-core
PUBLIC ${LNG_CORE_INCLUDE_DIRECTORIES_PUBLIC}
PRIVATE ${LNG_CORE_INCLUDE_DIRECTORIES_PRIVATE})
target_compile_options(lng-core
PUBLIC ${LNG_CORE_COMPILE_OPTIONS_PUBLIC}
PRIVATE ${LNG_CORE_COMPILE_OPTIONS_PRIVATE})
target_link_libraries(lng-core
PUBLIC ${LNG_CORE_LINK_LIBRARIES_PUBLIC}
PRIVATE ${LNG_CORE_LINK_LIBRARIES_PRIVATE})
#
# Test
#
add_executable(test_basic test/basic.cc)
target_link_libraries(test_basic lng-core)
if(LNG_WITH_DOCA OR LNG_WITH_DPDK)
add_executable(test_dpdk_echo_udp test/dpdk_echo_udp.cc)
target_link_libraries(test_dpdk_echo_udp lng-core ${LIBDPDK_STATIC_LDFLAGS})
add_executable(test_dpdk_build_frame_tcp test/dpdk_build_frame_tcp.cc)
target_link_libraries(test_dpdk_build_frame_tcp lng-core ${LIBDPDK_STATIC_LDFLAGS})
add_executable(test_dpdk_gpu_build_frame_udp test/dpdk_gpu_build_frame_udp.cc)
target_include_directories(
test_dpdk_gpu_build_frame_udp
PRIVATE
${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}
)
target_link_libraries(test_dpdk_gpu_build_frame_udp lng-core ${LIBDPDK_STATIC_LDFLAGS})
add_executable(test_dpdk_gpu_build_frame_tcp test/dpdk_gpu_build_frame_tcp.cc)
target_include_directories(
test_dpdk_gpu_build_frame_tcp
PRIVATE
${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}
)
target_link_libraries(test_dpdk_gpu_build_frame_tcp lng-core ${LIBDPDK_STATIC_LDFLAGS})
endif()
if(LNG_WITH_DOCA)
add_executable(test_doca_echo_udp test/doca_echo_udp.cc)
target_link_libraries(test_doca_echo_udp lng-core ${LIBDPDK_STATIC_LDFLAGS})
add_executable(test_doca_build_frame_tcp test/doca_build_frame_tcp.cc)
target_link_libraries(test_doca_build_frame_tcp lng-core ${LIBDPDK_STATIC_LDFLAGS})
add_executable(test_doca_build_frame_udp test/doca_build_frame_udp.cc)
target_link_libraries(test_doca_build_frame_udp lng-core ${LIBDPDK_STATIC_LDFLAGS})
endif()
# if(LNG_WITH_NVIDIA)
# add_executable(test_tcp test/test_tcp.cc)
# target_link_libraries(test_tcp lng-core ${LIBDOCAGPU_STATIC_LDFLAGS})
# endif()
#
# Install
#
install(TARGETS lng-core DESTINATION lib)
install(DIRECTORY include DESTINATION .)
install(FILES
${PROJECT_BINARY_DIR}/VERSION
DESTINATION .)
install(FILES
${PROJECT_SOURCE_DIR}/LICENSE
DESTINATION license)
install(FILES
${PROJECT_SOURCE_DIR}/thirdparty_notice.txt
DESTINATION license)
#
# Packaging
#
set(CPACK_GENERATOR "TGZ")
set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
set(CPACK_PACKAGE_VERSION ${LNG_KIT_VERSION})
set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-unknown)
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-x86-64-linux)
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-arm-64-linux)
endif()
include(CPack)