Skip to content

Commit 580182f

Browse files
authored
Remove ability to build kvikio without CUDA (#829)
This change supersedes #822 and makes CUDA a requirement for building kvikio. We have no compelling use case for this support outside of [legate](https://docs.nvidia.com/legate/latest/api/cpp/generated/group/group__io-kvikio.html), and after discussion with the team they are happy to sunset this support as well. Resolves #736 Resolves #485 Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Bradley Dice (https://github.com/bdice) URL: #829
1 parent 37e5270 commit 580182f

File tree

9 files changed

+66
-230
lines changed

9 files changed

+66
-230
lines changed

cpp/CMakeLists.txt

Lines changed: 64 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ option(KvikIO_BUILD_BENCHMARKS "Configure CMake to build benchmarks" ON)
4848
option(KvikIO_BUILD_EXAMPLES "Configure CMake to build examples" ON)
4949
option(KvikIO_BUILD_TESTS "Configure CMake to build tests" ON)
5050
option(KvikIO_REMOTE_SUPPORT "Configure CMake to build with remote IO support" ON)
51-
option(KvikIO_CUDA_SUPPORT "Configure CMake to build with CUDA support" ON)
5251

5352
# ##################################################################################################
5453
# * conda environment ------------------------------------------------------------------------------
@@ -72,66 +71,65 @@ if(KvikIO_REMOTE_SUPPORT)
7271
endif()
7372
endif()
7473

75-
set(cuFile_FOUND 0)
76-
if(KvikIO_CUDA_SUPPORT)
77-
rapids_find_package(
78-
CUDAToolkit REQUIRED
79-
BUILD_EXPORT_SET kvikio-exports
80-
INSTALL_EXPORT_SET kvikio-exports
74+
# CUDA is now required
75+
rapids_find_package(
76+
CUDAToolkit REQUIRED
77+
BUILD_EXPORT_SET kvikio-exports
78+
INSTALL_EXPORT_SET kvikio-exports
79+
)
80+
include(cmake/thirdparty/get_nvtx.cmake)
81+
82+
if(NOT TARGET CUDA::cuFile)
83+
set(cuFile_FOUND 0)
84+
message(
85+
WARNING "Cannot find cuFile - KvikIO will still work but won't use GPUDirect Storage (GDS)"
8186
)
82-
include(cmake/thirdparty/get_nvtx.cmake)
83-
84-
if(NOT TARGET CUDA::cuFile)
85-
message(
86-
WARNING "Cannot find cuFile - KvikIO will still work but won't use GPUDirect Storage (GDS)"
87-
)
88-
else()
89-
set(cuFile_FOUND 1)
90-
91-
# Check API support
92-
try_compile(
93-
cuFile_BATCH_API_FOUND SOURCE_FROM_CONTENT
94-
batch.cpp
95-
[[#include <cufile.h>
96-
int main() {
97-
cuFileBatchIOSetUp(nullptr, 0);
98-
return 0;
99-
}
100-
]]
101-
LINK_LIBRARIES CUDA::cuFile rt ${CMAKE_DL_LIBS}
102-
OUTPUT_VARIABLE batch_output
103-
)
104-
message(STATUS "Found cuFile Batch API: ${cuFile_BATCH_API_FOUND}")
105-
try_compile(
106-
cuFile_STREAM_API_FOUND SOURCE_FROM_CONTENT
107-
stream.cpp
108-
[[#include <cufile.h>
109-
int main() {
110-
CUfileHandle_t fh;
111-
CUstream stream;
112-
cuFileReadAsync(fh, nullptr, nullptr, nullptr, nullptr, nullptr, stream);
113-
return 0;
114-
}
115-
]]
116-
LINK_LIBRARIES CUDA::cuFile rt ${CMAKE_DL_LIBS}
117-
OUTPUT_VARIABLE stream_output
118-
)
119-
message(STATUS "Found cuFile Stream API: ${cuFile_STREAM_API_FOUND}")
120-
try_compile(
121-
cuFile_VERSION_API_FOUND SOURCE_FROM_CONTENT
122-
version.cpp
123-
[[#include <cufile.h>
124-
int main() {
125-
int version;
126-
cuFileGetVersion(&version);
127-
return 0;
128-
}
129-
]]
130-
LINK_LIBRARIES CUDA::cuFile rt ${CMAKE_DL_LIBS}
131-
OUTPUT_VARIABLE version_output
132-
)
133-
message(STATUS "Found cuFile Version API: ${cuFile_VERSION_API_FOUND}")
134-
endif()
87+
else()
88+
set(cuFile_FOUND 1)
89+
90+
# Check API support
91+
try_compile(
92+
cuFile_BATCH_API_FOUND SOURCE_FROM_CONTENT
93+
batch.cpp
94+
[[#include <cufile.h>
95+
int main() {
96+
cuFileBatchIOSetUp(nullptr, 0);
97+
return 0;
98+
}
99+
]]
100+
LINK_LIBRARIES CUDA::cuFile rt ${CMAKE_DL_LIBS}
101+
OUTPUT_VARIABLE batch_output
102+
)
103+
message(STATUS "Found cuFile Batch API: ${cuFile_BATCH_API_FOUND}")
104+
try_compile(
105+
cuFile_STREAM_API_FOUND SOURCE_FROM_CONTENT
106+
stream.cpp
107+
[[#include <cufile.h>
108+
int main() {
109+
CUfileHandle_t fh;
110+
CUstream stream;
111+
cuFileReadAsync(fh, nullptr, nullptr, nullptr, nullptr, nullptr, stream);
112+
return 0;
113+
}
114+
]]
115+
LINK_LIBRARIES CUDA::cuFile rt ${CMAKE_DL_LIBS}
116+
OUTPUT_VARIABLE stream_output
117+
)
118+
message(STATUS "Found cuFile Stream API: ${cuFile_STREAM_API_FOUND}")
119+
try_compile(
120+
cuFile_VERSION_API_FOUND SOURCE_FROM_CONTENT
121+
version.cpp
122+
[[#include <cufile.h>
123+
int main() {
124+
int version;
125+
cuFileGetVersion(&version);
126+
return 0;
127+
}
128+
]]
129+
LINK_LIBRARIES CUDA::cuFile rt ${CMAKE_DL_LIBS}
130+
OUTPUT_VARIABLE version_output
131+
)
132+
message(STATUS "Found cuFile Version API: ${cuFile_VERSION_API_FOUND}")
135133
endif()
136134

137135
include(cmake/thirdparty/get_thread_pool.cmake)
@@ -181,7 +179,7 @@ add_library(kvikio::kvikio ALIAS kvikio)
181179
target_include_directories(
182180
kvikio
183181
PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
184-
"$<BUILD_INTERFACE:$<$<BOOL:${KvikIO_CUDA_SUPPORT}>:${CUDAToolkit_INCLUDE_DIRS}>>"
182+
"$<BUILD_INTERFACE:${CUDAToolkit_INCLUDE_DIRS}>"
185183
INTERFACE "$<INSTALL_INTERFACE:include>"
186184
)
187185

@@ -195,7 +193,6 @@ target_link_libraries(
195193
target_compile_definitions(
196194
kvikio
197195
PUBLIC $<$<BOOL:${KvikIO_REMOTE_SUPPORT}>:KVIKIO_LIBCURL_FOUND>
198-
$<$<BOOL:${KvikIO_CUDA_SUPPORT}>:KVIKIO_CUDA_FOUND>
199196
$<$<BOOL:${cuFile_FOUND}>:KVIKIO_CUFILE_FOUND>
200197
$<$<BOOL:${cuFile_BATCH_API_FOUND}>:KVIKIO_CUFILE_BATCH_API_FOUND>
201198
$<$<BOOL:${cuFile_STREAM_API_FOUND}>:KVIKIO_CUFILE_STREAM_API_FOUND>
@@ -231,10 +228,7 @@ if(KvikIO_BUILD_EXAMPLES)
231228
add_subdirectory(examples)
232229
endif()
233230

234-
if(CUDAToolkit_FOUND
235-
AND KvikIO_BUILD_TESTS
236-
AND CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME
237-
)
231+
if(KvikIO_BUILD_TESTS AND CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
238232
include(cmake/thirdparty/get_gtest.cmake)
239233

240234
# include CTest module -- automatically calls enable_testing()
@@ -271,7 +265,6 @@ Provide targets for KvikIO.
271265

272266
set(final_code_string
273267
"
274-
set(KvikIO_CUDA_SUPPORT [=[${KvikIO_CUDA_SUPPORT}]=])
275268
set(KvikIO_CUFILE_SUPPORT [=[${cuFile_FOUND}]=])
276269
set(KvikIO_REMOTE_SUPPORT [=[${KvikIO_REMOTE_SUPPORT}]=])
277270
"
@@ -280,13 +273,11 @@ string(
280273
APPEND
281274
final_code_string
282275
[=[
283-
if(KvikIO_CUDA_SUPPORT)
284-
find_package(CUDAToolkit REQUIRED QUIET)
285-
target_include_directories(kvikio::kvikio INTERFACE ${CUDAToolkit_INCLUDE_DIRS})
276+
find_package(CUDAToolkit REQUIRED QUIET)
277+
target_include_directories(kvikio::kvikio INTERFACE ${CUDAToolkit_INCLUDE_DIRS})
286278

287-
if(KvikIO_CUFILE_SUPPORT AND NOT TARGET CUDA::cuFile)
288-
message(FATAL_ERROR "Compiled with cuFile support but cuFile not found")
289-
endif()
279+
if(KvikIO_CUFILE_SUPPORT AND NOT TARGET CUDA::cuFile)
280+
message(FATAL_ERROR "Compiled with cuFile support but cuFile not found")
290281
endif()
291282
]=]
292283
)

cpp/include/kvikio/nvtx.hpp

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,13 @@
1717

1818
#include <cstdint>
1919

20-
#ifdef KVIKIO_CUDA_FOUND
2120
#include <nvtx3/nvtx3.hpp>
22-
#endif
2321

2422
#include <kvikio/shim/cuda.hpp>
2523
#include <kvikio/utils.hpp>
2624

2725
namespace kvikio {
2826

29-
#ifdef KVIKIO_CUDA_FOUND
3027
/**
3128
* @brief Tag type for libkvikio's NVTX domain.
3229
*/
@@ -100,13 +97,7 @@ using nvtx_registered_string_type = nvtx3::registered_string_in<libkvikio_domain
10097
nvtx3::mark_in<kvikio::libkvikio_domain>(nvtx3::event_attributes{ \
10198
KVIKIO_REGISTER_STRING(message), nvtx3::payload{kvikio::convert_to_64bit(payload_v)}})
10299

103-
#endif
104-
105-
#ifdef KVIKIO_CUDA_FOUND
106100
using nvtx_color_type = nvtx3::color;
107-
#else
108-
using nvtx_color_type = int;
109-
#endif
110101

111102
/**
112103
* @brief Utility singleton class for NVTX annotation.
@@ -181,13 +172,7 @@ class NvtxManager {
181172
* }
182173
* ```
183174
*/
184-
#ifdef KVIKIO_CUDA_FOUND
185175
#define KVIKIO_NVTX_FUNC_RANGE(...) KVIKIO_NVTX_FUNC_RANGE_IMPL(__VA_ARGS__)
186-
#else
187-
#define KVIKIO_NVTX_FUNC_RANGE(...) \
188-
do { \
189-
} while (0)
190-
#endif
191176

192177
/**
193178
* @brief Convenience macro for generating an NVTX scoped range in the `libkvikio` domain to
@@ -206,13 +191,7 @@ class NvtxManager {
206191
* }
207192
* ```
208193
*/
209-
#ifdef KVIKIO_CUDA_FOUND
210194
#define KVIKIO_NVTX_SCOPED_RANGE(...) KVIKIO_NVTX_SCOPED_RANGE_IMPL(__VA_ARGS__)
211-
#else
212-
#define KVIKIO_NVTX_SCOPED_RANGE(message, payload, ...) \
213-
do { \
214-
} while (0)
215-
#endif
216195

217196
/**
218197
* @brief Convenience macro for generating an NVTX marker in the `libkvikio` domain to annotate a
@@ -232,12 +211,6 @@ class NvtxManager {
232211
* }
233212
* ```
234213
*/
235-
#ifdef KVIKIO_CUDA_FOUND
236214
#define KVIKIO_NVTX_MARKER(message, payload) KVIKIO_NVTX_MARKER_IMPL(message, payload)
237-
#else
238-
#define KVIKIO_NVTX_MARKER(message, payload) \
239-
do { \
240-
} while (0)
241-
#endif
242215

243216
} // namespace kvikio

cpp/include/kvikio/shim/cuda.hpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include <any>
1919
#include <functional>
2020

21-
#include <kvikio/shim/cuda_h_wrapper.hpp>
21+
#include <cuda.h>
2222
#include <kvikio/shim/utils.hpp>
2323
#include <stdexcept>
2424

@@ -134,10 +134,6 @@ class cudaAPI {
134134
*
135135
* @return The boolean answer
136136
*/
137-
#ifdef KVIKIO_CUDA_FOUND
138137
bool is_cuda_available();
139-
#else
140-
constexpr bool is_cuda_available() { return false; }
141-
#endif
142138

143139
} // namespace kvikio

cpp/include/kvikio/shim/cuda_h_wrapper.hpp

Lines changed: 0 additions & 95 deletions
This file was deleted.

cpp/include/kvikio/shim/cufile_h_wrapper.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
#include <sys/types.h>
1919

20-
#include <kvikio/shim/cuda_h_wrapper.hpp>
20+
#include <cuda.h>
2121

2222
/**
2323
* In order to support compilation when `cufile.h` isn't available, we

cpp/include/kvikio/utils.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,7 @@ template <typename T, std::enable_if_t<std::is_floating_point_v<T>>* = nullptr>
7373
* @param ptr Memory pointer to query
7474
* @return The boolean answer
7575
*/
76-
#ifdef KVIKIO_CUDA_FOUND
7776
bool is_host_memory(void const* ptr);
78-
#else
79-
constexpr bool is_host_memory(void const* ptr) { return true; }
80-
#endif
8177

8278
/**
8379
* @brief Return the device owning the pointer

0 commit comments

Comments
 (0)