forked from rapidsai/rmm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
217 lines (171 loc) · 7.68 KB
/
CMakeLists.txt
File metadata and controls
217 lines (171 loc) · 7.68 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
# =============================================================================
# cmake-format: off
# SPDX-FileCopyrightText: Copyright (c) 2018-2025, NVIDIA CORPORATION.
# SPDX-License-Identifier: Apache-2.0
# cmake-format: on
# =============================================================================
# Build options
option(DISABLE_DEPRECATION_WARNING "Disable warnings generated from deprecated declarations." OFF)
option(CODE_COVERAGE "Enable generating code coverage with gcov." OFF)
include(rapids-test)
rapids_test_init()
# Ensure tests are using the conda env, so they have the correct release/debug compile flags
rapids_cmake_support_conda_env(conda_env)
# This function takes in a test name and test source and handles setting all of the associated
# properties and linking to build the test
function(ConfigureTestInternal TEST_NAME)
add_executable(${TEST_NAME} ${ARGN})
target_include_directories(${TEST_NAME} PRIVATE "$<BUILD_INTERFACE:${RMM_SOURCE_DIR}>")
target_link_libraries(
${TEST_NAME} PRIVATE GTest::gmock GTest::gtest GTest::gmock_main GTest::gtest_main pthread rmm
$<TARGET_NAME_IF_EXISTS:conda_env>)
set_target_properties(
${TEST_NAME}
PROPERTIES POSITION_INDEPENDENT_CODE ON
RUNTIME_OUTPUT_DIRECTORY "$<BUILD_INTERFACE:${RMM_BINARY_DIR}/gtests>"
CUDA_ARCHITECTURES "${CMAKE_CUDA_ARCHITECTURES}"
INSTALL_RPATH "\$ORIGIN/../../../lib"
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
CUDA_STANDARD 17
CUDA_STANDARD_REQUIRED ON)
target_compile_definitions(
${TEST_NAME} PUBLIC "RMM_LOG_ACTIVE_LEVEL=RAPIDS_LOGGER_LOG_LEVEL_${RMM_LOGGING_LEVEL}")
target_compile_options(
${TEST_NAME}
PRIVATE
"$<$<COMPILE_LANGUAGE:CXX>:-Wall;-Werror;-Wno-unknown-pragmas;-Wno-error=deprecated-declarations>"
"$<$<COMPILE_LANGUAGE:CUDA>:-Werror=all-warnings;-Xcompiler=-Wall,-Werror,-Wno-error=deprecated-declarations>"
)
if(DISABLE_DEPRECATION_WARNING)
target_compile_options(
${TEST_NAME} PUBLIC $<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler=-Wno-deprecated-declarations>)
target_compile_options(${TEST_NAME}
PUBLIC $<$<COMPILE_LANGUAGE:CXX>:-Wno-deprecated-declarations>)
endif()
if(CODE_COVERAGE)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(KEEP_DIR ${CMAKE_CURRENT_BINARY_DIR}/tmp)
make_directory(${KEEP_DIR})
target_compile_options(${TEST_NAME} PUBLIC $<$<COMPILE_LANGUAGE:CUDA>:--keep
--keep-dir=${KEEP_DIR}>)
target_compile_options(
${TEST_NAME}
PUBLIC
$<$<COMPILE_LANGUAGE:CUDA>:-O0
-Xcompiler=--coverage,-fprofile-abs-path,-fkeep-inline-functions,-fno-elide-constructors>)
target_compile_options(
${TEST_NAME} PUBLIC $<$<COMPILE_LANGUAGE:CXX>:-O0 --coverage -fprofile-abs-path
-fkeep-inline-functions -fno-elide-constructors>)
target_link_options(${TEST_NAME} PRIVATE --coverage)
target_link_libraries(${TEST_NAME} PRIVATE gcov)
endif()
# Add coverage-generated files to clean target
list(APPEND COVERAGE_CLEAN_FILES "**/*.gcno" "**/*.gcda")
set_property(
TARGET ${TEST_NAME}
APPEND
PROPERTY ADDITIONAL_CLEAN_FILES ${COVERAGE_CLEAN_FILES})
endif()
endfunction()
# Wrapper around `ConfigureTestInternal` that builds tests both with and without per thread default
# stream
function(ConfigureTest TEST_NAME)
set(options LINK_DRIVER)
set(one_value GPUS PERCENT)
set(multi_value)
cmake_parse_arguments(_RMM_TEST "${options}" "${one_value}" "${multi_value}" ${ARGN})
if(NOT DEFINED _RMM_TEST_GPUS AND NOT DEFINED _RMM_TEST_PERCENT)
set(_RMM_TEST_GPUS 1)
set(_RMM_TEST_PERCENT 5)
endif()
if(NOT DEFINED _RMM_TEST_GPUS)
set(_RMM_TEST_GPUS 1)
endif()
if(NOT DEFINED _RMM_TEST_PERCENT)
set(_RMM_TEST_PERCENT 100)
endif()
set(cudart_link_libs $<COMPILE_ONLY:rmm> CUDA::cudart_static)
# Test with legacy default stream.
ConfigureTestInternal(${TEST_NAME} ${_RMM_TEST_UNPARSED_ARGUMENTS})
target_link_libraries(${TEST_NAME} PRIVATE ${cudart_link_libs})
if(_RMM_TEST_LINK_DRIVER)
target_link_libraries(${TEST_NAME} PRIVATE CUDA::cuda_driver)
endif()
# Test with per-thread default stream.
string(REGEX REPLACE "_TEST$" "_PTDS_TEST" PTDS_TEST_NAME "${TEST_NAME}")
ConfigureTestInternal("${PTDS_TEST_NAME}" ${_RMM_TEST_UNPARSED_ARGUMENTS})
target_compile_definitions("${PTDS_TEST_NAME}" PUBLIC CUDA_API_PER_THREAD_DEFAULT_STREAM)
target_link_libraries(${PTDS_TEST_NAME} PRIVATE ${cudart_link_libs})
if(_RMM_TEST_LINK_DRIVER)
target_link_libraries(${PTDS_TEST_NAME} PRIVATE CUDA::cuda_driver)
endif()
foreach(name ${TEST_NAME} ${PTDS_TEST_NAME} ${NS_TEST_NAME})
rapids_test_add(
NAME ${name}
COMMAND ${TEST_NAME}
GPUS ${_RMM_TEST_GPUS}
PERCENT ${_RMM_TEST_PERCENT}
INSTALL_COMPONENT_SET testing)
endforeach()
endfunction()
# test sources
# device mr_ref tests
ConfigureTest(DEVICE_MR_REF_TEST mr/mr_ref_tests.cpp mr/mr_ref_multithreaded_tests.cpp GPUS 1
PERCENT 100)
# general adaptor tests
ConfigureTest(ADAPTOR_TEST mr/adaptor_tests.cpp)
# pool mr tests
ConfigureTest(POOL_MR_TEST mr/pool_mr_tests.cpp GPUS 1 PERCENT 100)
ConfigureTest(HWDECOMPRESS_TEST mr/hwdecompress_tests.cpp LINK_DRIVER)
# cuda_async mr tests
ConfigureTest(CUDA_ASYNC_MR_TEST mr/cuda_async_mr_tests.cpp GPUS 1 PERCENT 60)
# cuda_async managed mr tests (available with CUDA 13+ runtime/driver)
ConfigureTest(CUDA_ASYNC_MANAGED_MR_TEST mr/cuda_async_managed_mr_tests.cpp)
# thrust allocator tests
ConfigureTest(THRUST_ALLOCATOR_TEST mr/thrust_allocator_tests.cu GPUS 1 PERCENT 60)
# polymorphic allocator tests
ConfigureTest(POLYMORPHIC_ALLOCATOR_TEST mr/polymorphic_allocator_tests.cpp)
# stream allocator adaptor tests
ConfigureTest(STREAM_ADAPTOR_TEST mr/stream_allocator_adaptor_tests.cpp)
# statistics adaptor tests
ConfigureTest(STATISTICS_TEST mr/statistics_mr_tests.cpp)
# tracking adaptor tests
ConfigureTest(TRACKING_TEST mr/tracking_mr_tests.cpp)
# out-of-memory callback adaptor tests
ConfigureTest(FAILURE_CALLBACK_TEST mr/failure_callback_mr_tests.cpp)
# prefetch adaptor tests
ConfigureTest(PREFETCH_ADAPTOR_TEST mr/prefetch_resource_adaptor_tests.cpp)
# aligned adaptor tests
ConfigureTest(ALIGNED_TEST mr/aligned_mr_tests.cpp)
# limiting adaptor tests
ConfigureTest(LIMITING_TEST mr/limiting_mr_tests.cpp)
# host mr_ref tests
ConfigureTest(HOST_MR_REF_TEST mr/host_mr_ref_tests.cpp)
# pinned host pool mr tests
ConfigureTest(PINNED_HOST_POOL_MR_TEST mr/pinned_host_pool_mr_tests.cpp)
# CUDA stream tests
ConfigureTest(CUDA_STREAM_TEST cuda_stream_tests.cpp cuda_stream_pool_tests.cpp)
# device buffer tests
ConfigureTest(DEVICE_BUFFER_TEST device_buffer_tests.cu)
# device scalar tests
ConfigureTest(DEVICE_SCALAR_TEST device_scalar_tests.cpp)
# uvector tests
ConfigureTest(DEVICE_UVECTOR_TEST device_uvector_tests.cpp GPUS 1 PERCENT 60)
# prefetch tests
ConfigureTest(PREFETCH_TEST prefetch_tests.cpp)
# logger tests
ConfigureTest(LOGGER_TEST logger_tests.cpp)
# arena MR tests
ConfigureTest(ARENA_MR_TEST mr/arena_mr_tests.cpp GPUS 1 PERCENT 100)
# binning MR tests
ConfigureTest(BINNING_MR_TEST mr/binning_mr_tests.cpp)
# callback memory resource tests
ConfigureTest(CALLBACK_MR_TEST mr/callback_mr_tests.cpp)
# system memory resource tests
ConfigureTest(SYSTEM_MR_TEST mr/system_mr_tests.cu GPUS 1 PERCENT 100)
# container multidevice tests
ConfigureTest(CONTAINER_MULTIDEVICE_TEST container_multidevice_tests.cu)
# error macros tests
ConfigureTest(ERROR_MACROS_TEST error_macros_tests.cpp)
rapids_test_install_relocatable(INSTALL_COMPONENT_SET testing DESTINATION bin/gtests/librmm)