-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
221 lines (177 loc) · 4.35 KB
/
CMakeLists.txt
File metadata and controls
221 lines (177 loc) · 4.35 KB
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
cmake_minimum_required(VERSION 3.18)
project(GPUMan
VERSION 0.9.1
DESCRIPTION "GPU memory manager for multi-tenant CUDA workloads"
LANGUAGES C CXX
)
# -----------------------
# Build configuration
# -----------------------
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Default build type
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/include/gpuman/version.hpp.in
${CMAKE_CURRENT_BINARY_DIR}/generated/version.hpp
@ONLY
)
# -----------------------
# Dependencies
# -----------------------
include(FetchContent)
# Tabulate
FetchContent_Declare(
tabulate
GIT_REPOSITORY https://github.com/p-ranav/tabulate.git
)
FetchContent_MakeAvailable(tabulate)
# Argparse
FetchContent_Declare(
argparse
GIT_REPOSITORY https://github.com/p-ranav/argparse.git
)
FetchContent_MakeAvailable(argparse)
# JSON for Modern C++
FetchContent_Declare(
json
URL https://github.com/nlohmann/json/releases/download/v3.12.0/json.tar.xz
)
FetchContent_MakeAvailable(json)
# NVML (comes with NVIDIA driver)
find_library(NVML_LIBRARY
NAMES nvidia-ml
PATHS /usr/lib /usr/lib/x86_64-linux-gnu
REQUIRED
)
# -----------------------
# GPUMan proclist library
# -----------------------
add_library(gpuman_proclist
src/proclist/procfile.cpp
src/proclist/proclist_manager.cpp
)
target_include_directories(gpuman_proclist
PUBLIC
${PROJECT_SOURCE_DIR}/include
)
target_link_libraries(gpuman_proclist
PUBLIC
nlohmann_json::nlohmann_json
)
# -----------------------
# GPUMan ipc library
# -----------------------
add_library(gpuman_ipc
src/ipc/message.cpp
src/ipc/socket.cpp
)
target_include_directories(gpuman_ipc
PUBLIC
${PROJECT_SOURCE_DIR}/include
)
target_link_libraries(gpuman_ipc
PUBLIC
nlohmann_json::nlohmann_json
)
# -----------------------
# GPUMan core library
# -----------------------
add_library(gpuman_core
src/core/process.cpp
src/core/resource_monitor.cpp
)
target_include_directories(gpuman_core
PUBLIC
${PROJECT_SOURCE_DIR}/include
)
target_link_libraries(gpuman_core
PUBLIC
${NVML_LIBRARY}
gpuman_proclist
)
# -----------------------
# GPUMan CLI executable
# -----------------------
add_executable(gpuman
src/cli/cli.cpp
src/cli/handlers.cpp
)
target_include_directories(gpuman
PUBLIC
${PROJECT_SOURCE_DIR}/include
PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/generated
)
target_link_libraries(gpuman
PRIVATE
argparse
tabulate
gpuman_proclist
gpuman_ipc
)
# -----------------------
# GPUMan daemon executable
# -----------------------
add_executable(gpumand
src/daemon/daemon.cpp
src/daemon/handlers.cpp
)
target_include_directories(gpumand
PUBLIC
${PROJECT_SOURCE_DIR}/include
PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/generated
)
target_link_libraries(gpumand
PRIVATE
gpuman_proclist
gpuman_ipc
gpuman_core
)
# -----------------------
# Common compile options
# -----------------------
add_library(warnings INTERFACE)
target_compile_options(warnings INTERFACE -Wall -Wextra -Wpedantic)
target_link_libraries(gpuman_proclist PRIVATE warnings)
target_link_libraries(gpuman_ipc PRIVATE warnings)
target_link_libraries(gpuman_core PRIVATE warnings)
target_link_libraries(gpuman PRIVATE warnings)
target_link_libraries(gpumand PRIVATE warnings)
# -----------------------
# Optional CUDA test workload
# -----------------------
option(BUILD_CUDA_TESTS "Build CUDA test workloads" ON)
if(BUILD_CUDA_TESTS)
enable_language(CUDA)
function(add_cuda_test name)
add_executable(${name}
tests/${name}.cu
)
set_target_properties(${name} PROPERTIES
CUDA_SEPARABLE_COMPILATION ON
CUDA_STANDARD 14
)
endfunction()
add_cuda_test(cuda_mem_leak)
add_cuda_test(cuda_mem_stable)
add_cuda_test(cuda_mem_stable_high)
endif()
# -----------------------
# Installation rules
# -----------------------
include(GNUInstallDirs)
install(TARGETS gpuman
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(TARGETS gpumand
RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
)
install(FILES systemd/gpumand.service
DESTINATION /lib/systemd/system
)