-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
50 lines (42 loc) · 1.55 KB
/
CMakeLists.txt
File metadata and controls
50 lines (42 loc) · 1.55 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
cmake_minimum_required(VERSION 3.25)
include(FetchContent)
project(PyGpuBench CXX CUDA)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CUDA_ARCHITECTURES "80;90")
FetchContent_Declare(
nanobind
QUIET
GIT_REPOSITORY https://github.com/wjakob/nanobind.git
GIT_TAG v2.9.2
)
find_package(CUDAToolkit REQUIRED)
message(STATUS "CUDA Toolkit Version: ${CUDAToolkit_VERSION}")
find_package(Python COMPONENTS Interpreter Development.Module OPTIONAL_COMPONENTS Development.SABIModule)
FetchContent_MakeAvailable(nanobind)
nanobind_add_module(_pygpubench
STABLE_ABI
csrc/binding.cpp
csrc/manager.cpp
csrc/clear_l2.cu
csrc/check.cu
csrc/landlock.cpp
)
target_link_libraries(_pygpubench PUBLIC Python::Module CUDA::cudart)
# set a bunch of hardening options to make it harder to tamper with the executable
target_compile_options(_pygpubench PUBLIC -fPIC -pie -fstack-protector-strong -fcf-protection=full -ftrivial-auto-var-init=zero -Wl,-z,relro,-z,now )
target_compile_definitions(_pygpubench PUBLIC -D_GLIBCXX_ASSERTIONS -D_FORTIFY_SOURCE=3)
# make sure we pick up cuda libraries from within the current python env, if available
set(RPATH_LIST
"$ORIGIN"
"$ORIGIN/../nvidia/cuda_runtime/lib"
)
list(JOIN RPATH_LIST ":" WHEEL_RPATH)
set_target_properties(_pygpubench PROPERTIES
INSTALL_RPATH "${WHEEL_RPATH}"
BUILD_WITH_INSTALL_RPATH OFF
INSTALL_RPATH_USE_LINK_PATH FALSE
)
install(TARGETS _pygpubench
LIBRARY DESTINATION pygpubench
)