Skip to content

Commit 1c5a3c7

Browse files
authored
More cmake improvements and compilation fix to handle cudf nightly update (#85)
- Make cmake option prefix (`CUCASCADE_`) consistent for all options - Make `CXX` standard part of public interface and `CUDA` part of private interface. - Fix static_assert for RMM 26.x: handle removed polyfill namespace for newer versions - Fixed formatting. Authors: - Pradeep Garigipati (https://github.com/9prady9) Approvers: - Matthijs Brobbel (https://github.com/mbrobbel) URL: #85
1 parent 5d6b85d commit 1c5a3c7

5 files changed

Lines changed: 35 additions & 37 deletions

File tree

CMakeLists.txt

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ project(
2525
DESCRIPTION "GPU memory management and data representation library")
2626

2727
# Options
28-
option(BUILD_TESTS "Build the test suite" ON)
29-
option(BUILD_BENCHMARKS "Build the benchmark suite" ON)
28+
option(CUCASCADE_BUILD_TESTS "Build the test suite" ON)
29+
option(CUCASCADE_BUILD_BENCHMARKS "Build the benchmark suite" ON)
3030
option(CUCASCADE_BUILD_SHARED_LIBS "Build shared library" ON)
3131
option(CUCASCADE_BUILD_STATIC_LIBS "Build static library" ON)
3232

@@ -60,7 +60,7 @@ endif()
6060
# =============================================================================
6161
# Compiler warnings
6262
# =============================================================================
63-
option(WARNINGS_AS_ERRORS "Treat compiler warnings as errors" ON)
63+
option(CUCASCADE_WARNINGS_AS_ERRORS "Treat compiler warnings as errors" ON)
6464

6565
# Warning flags for C/C++
6666
set(CUCASCADE_CXX_WARNING_FLAGS
@@ -118,16 +118,14 @@ target_include_directories(cucascade_objects
118118
# Link dependencies to object library
119119
target_link_libraries(cucascade_objects PUBLIC ${CUCASCADE_PUBLIC_LINK_LIBS})
120120

121-
# Language standards set via properties (not compile features) to avoid
122-
# propagating cuda_std_* requirements to consumers without CUDA enabled.
123-
set_target_properties(cucascade_objects PROPERTIES CXX_STANDARD 20
124-
CXX_STANDARD_REQUIRED ON
125-
CXX_EXTENSIONS OFF
126-
CUDA_STANDARD 20
127-
CUDA_STANDARD_REQUIRED ON)
121+
# cxx_std_20 is PUBLIC so consumers know they need C++20 to use our headers.
122+
# cuda_std_20 is kept separate and applied PRIVATE to cucascade_objects to avoid
123+
# propagating it to consumers that have no CUDA compiler requirement.
124+
target_compile_features(cucascade_objects PUBLIC cxx_std_20)
125+
target_compile_features(cucascade_objects PRIVATE cuda_std_20)
128126

129-
# Position independent code (required for shared library)
130-
set_target_properties(cucascade_objects PROPERTIES POSITION_INDEPENDENT_CODE ON)
127+
set_target_properties(cucascade_objects PROPERTIES CXX_EXTENSIONS OFF
128+
POSITION_INDEPENDENT_CODE ON)
131129

132130
# =============================================================================
133131
# Static library
@@ -139,8 +137,7 @@ if(CUCASCADE_BUILD_STATIC_LIBS)
139137
target_include_directories(cucascade_static
140138
PUBLIC ${CUCASCADE_PUBLIC_INCLUDE_DIRS})
141139
target_link_libraries(cucascade_static PUBLIC ${CUCASCADE_PUBLIC_LINK_LIBS})
142-
target_compile_features(cucascade_static
143-
PUBLIC ${CUCASCADE_PUBLIC_COMPILE_FEATURES})
140+
target_compile_features(cucascade_static PUBLIC cxx_std_20)
144141

145142
set_target_properties(
146143
cucascade_static PROPERTIES OUTPUT_NAME cucascade EXPORT_NAME
@@ -157,8 +154,7 @@ if(CUCASCADE_BUILD_SHARED_LIBS)
157154
target_include_directories(cucascade_shared
158155
PUBLIC ${CUCASCADE_PUBLIC_INCLUDE_DIRS})
159156
target_link_libraries(cucascade_shared PUBLIC ${CUCASCADE_PUBLIC_LINK_LIBS})
160-
target_compile_features(cucascade_shared
161-
PUBLIC ${CUCASCADE_PUBLIC_COMPILE_FEATURES})
157+
target_compile_features(cucascade_shared PUBLIC cxx_std_20)
162158

163159
set_target_properties(
164160
cucascade_shared
@@ -239,14 +235,14 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cuCascadeConfig.cmake
239235
# =============================================================================
240236
# Tests
241237
# =============================================================================
242-
if(BUILD_TESTS)
238+
if(CUCASCADE_BUILD_TESTS)
243239
enable_testing()
244240
add_subdirectory(test)
245241
endif()
246242

247243
# =============================================================================
248244
# Benchmarks
249245
# =============================================================================
250-
if(BUILD_BENCHMARKS)
246+
if(CUCASCADE_BUILD_BENCHMARKS)
251247
add_subdirectory(benchmark)
252248
endif()

benchmark/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ set(BENCHMARK_SOURCES
4545

4646
# Create benchmark executable
4747
add_executable(cucascade_benchmarks ${BENCHMARK_SOURCES})
48-
set_target_properties(cucascade_benchmarks PROPERTIES CXX_STANDARD 20
49-
CXX_STANDARD_REQUIRED ON)
5048

5149
# Set include directories
5250
target_include_directories(

include/cucascade/memory/small_pinned_host_memory_resource.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <rmm/cuda_stream_view.hpp>
2323
#include <rmm/detail/cccl_adaptors.hpp>
2424
#include <rmm/mr/device_memory_resource.hpp>
25+
#include <rmm/version_config.hpp>
2526

2627
#include <array>
2728
#include <cstddef>
@@ -137,9 +138,17 @@ class small_pinned_host_memory_resource : public rmm::mr::device_memory_resource
137138
std::vector<fixed_multiple_blocks_allocation> owned_allocations_;
138139
};
139140

141+
// rmm::detail::polyfill::async_resource_with was removed in RMM 26.x;
142+
// use cuda::mr::resource_with directly for newer versions.
143+
#if RMM_VERSION_MAJOR >= 26
144+
static_assert(cuda::mr::resource_with<small_pinned_host_memory_resource,
145+
cuda::mr::device_accessible,
146+
cuda::mr::host_accessible>);
147+
#else
140148
static_assert(rmm::detail::polyfill::async_resource_with<small_pinned_host_memory_resource,
141149
cuda::mr::device_accessible,
142150
cuda::mr::host_accessible>);
151+
#endif
143152

144153
} // namespace memory
145154
} // namespace cucascade

src/data/representation_converter.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -508,12 +508,12 @@ static memory::column_metadata plan_column_copy(const cudf::column_view& col,
508508
memory::column_metadata offsets_meta{};
509509
offsets_meta.type_id = cudf::type_id::INT32;
510510
offsets_meta.num_rows = 1; // one offset value (0) for 0 strings
511-
offsets_meta.null_count = 0;
511+
offsets_meta.null_count = 0;
512512
offsets_meta.has_null_mask = false;
513-
offsets_meta.has_data = true;
514-
offsets_meta.data_size = sizeof(int32_t);
515-
current_offset = align_up_fast(current_offset, 8u);
516-
offsets_meta.data_offset = current_offset;
513+
offsets_meta.has_data = true;
514+
offsets_meta.data_size = sizeof(int32_t);
515+
current_offset = align_up_fast(current_offset, 8u);
516+
offsets_meta.data_offset = current_offset;
517517
current_offset += offsets_meta.data_size;
518518
offsets_meta.is_synthetic_empty_offsets = true;
519519
meta.children.push_back(std::move(offsets_meta));
@@ -558,11 +558,12 @@ static void collect_d2h_ops(const void* src,
558558
}
559559

560560
/**
561-
* @brief Zero a region in the host allocation (used for synthetic STRING offsets with no device source).
561+
* @brief Zero a region in the host allocation (used for synthetic STRING offsets with no device
562+
* source).
562563
*/
563564
static void zero_region(memory::fixed_multiple_blocks_allocation& alloc,
564-
std::size_t alloc_offset,
565-
std::size_t size)
565+
std::size_t alloc_offset,
566+
std::size_t size)
566567
{
567568
if (size == 0 || !alloc || alloc->size() == 0) { return; }
568569
const std::size_t block_size = alloc->block_size();
@@ -787,9 +788,7 @@ std::unique_ptr<idata_representation> convert_host_fast_to_gpu(
787788
{
788789
auto& fast_source = source.cast<host_data_representation>();
789790
const auto& fast_table = fast_source.get_host_table();
790-
if (!fast_table) {
791-
throw std::runtime_error("convert_host_fast_to_gpu: host table is null");
792-
}
791+
if (!fast_table) { throw std::runtime_error("convert_host_fast_to_gpu: host table is null"); }
793792
if (!fast_table->allocation) {
794793
throw std::runtime_error("convert_host_fast_to_gpu: host table allocation is null");
795794
}

test/CMakeLists.txt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,8 @@ set(TEST_SOURCES
4747

4848
# Create test executable
4949
add_executable(cucascade_tests ${TEST_SOURCES})
50-
set_target_properties(cucascade_tests PROPERTIES CXX_STANDARD 20
51-
CXX_STANDARD_REQUIRED ON
52-
CUDA_STANDARD 20
53-
CUDA_STANDARD_REQUIRED ON
54-
CUDA_ARCHITECTURES
55-
"${CMAKE_CUDA_ARCHITECTURES}")
50+
set_target_properties(cucascade_tests PROPERTIES CUDA_STANDARD 20
51+
CUDA_STANDARD_REQUIRED ON)
5652

5753
# Set include directories
5854
target_include_directories(

0 commit comments

Comments
 (0)