Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
fail-fast: false
matrix:
cuda: [12, 13]
rapids: [nightly, stable]
rapids: [nightly] # TODO: re-enable stable once it is fixed

env:
SCCACHE_GHA_ENABLED: true
Expand Down Expand Up @@ -47,7 +47,7 @@ jobs:
strategy:
matrix:
cuda: [12, 13]
rapids: [nightly, stable]
rapids: [nightly] # TODO: re-enable stable once it is fixed

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
Expand Down
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,11 @@ set(CUCASCADE_CXX_WARNING_FLAGS
-Wunused
-Wconversion
-Wsign-conversion
-Wnull-dereference
-Wdouble-promotion
-Wformat=2
-Wimplicit-fallthrough)

if(WARNINGS_AS_ERRORS)
if(CUCASCADE_WARNINGS_AS_ERRORS)
list(APPEND CUCASCADE_CXX_WARNING_FLAGS -Werror)
endif()

Expand Down
2 changes: 1 addition & 1 deletion benchmark/benchmark_disk_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "cucascade/memory/config.hpp"
#include "cucascade/memory/memory_reservation_manager.hpp"

#include <cucascade/cuda_utils.hpp>
#include <cucascade/error.hpp>

#include <cudf/column/column_factories.hpp>
#include <cudf/table/table.hpp>
Expand Down
4 changes: 2 additions & 2 deletions benchmark/benchmark_representation_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
#include "cucascade/data/representation_converter.hpp"
#include "cucascade/memory/memory_reservation_manager.hpp"

#include <cucascade/error.hpp>

#include <cudf/column/column_factories.hpp>
#include <cudf/table/table.hpp>
#include <cudf/types.hpp>

#include <cucascade/cuda_utils.hpp>

#include <rmm/cuda_stream.hpp>

#include <cuda_runtime_api.h>
Expand Down
125 changes: 2 additions & 123 deletions include/cucascade/cuda_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,126 +17,5 @@

#pragma once

#include <rmm/error.hpp>

#include <cuda_runtime_api.h>

#include <cassert>
#include <iostream>
#include <string>

// =============================================================================
// CUDA error-checking macros (replacements for rmm/detail/error.hpp macros)
// =============================================================================

#define CUCASCADE_STRINGIFY_DETAIL(x) #x
#define CUCASCADE_STRINGIFY(x) CUCASCADE_STRINGIFY_DETAIL(x)

/**
* @brief Error checking macro for CUDA runtime API functions.
*
* If the call does not return cudaSuccess, clears the error and throws
* rmm::cuda_error with file/line context.
*/
#define CUCASCADE_CUDA_TRY(call) \
do { \
cudaError_t const error = (call); \
if (cudaSuccess != error) { \
cudaGetLastError(); \
throw rmm::cuda_error{std::string{"CUDA error at: "} + __FILE__ + ":" + \
CUCASCADE_STRINGIFY(__LINE__) + ": " + cudaGetErrorName(error) + \
" " + cudaGetErrorString(error)}; \
} \
} while (0)

/**
* @brief Error checking macro for CUDA memory allocation calls.
*
* Throws rmm::out_of_memory when cudaErrorMemoryAllocation is returned,
* rmm::bad_alloc for other failures.
*
* Can be called with 1 or 2 arguments:
* - CUCASCADE_CUDA_TRY_ALLOC(cuda_call)
* - CUCASCADE_CUDA_TRY_ALLOC(cuda_call, num_bytes)
*/
#define CUCASCADE_CUDA_TRY_ALLOC(...) \
GET_CUCASCADE_CUDA_TRY_ALLOC_MACRO(__VA_ARGS__, CUCASCADE_CUDA_TRY_ALLOC_2, \
CUCASCADE_CUDA_TRY_ALLOC_1) \
(__VA_ARGS__)
#define GET_CUCASCADE_CUDA_TRY_ALLOC_MACRO(_1, _2, NAME, ...) NAME

#define CUCASCADE_CUDA_TRY_ALLOC_2(_call, num_bytes) \
do { \
cudaError_t const error = (_call); \
if (cudaSuccess != error) { \
cudaGetLastError(); \
auto const msg = std::string{"CUDA error (failed to allocate "} + \
std::to_string(num_bytes) + " bytes) at: " + __FILE__ + ":" + \
CUCASCADE_STRINGIFY(__LINE__) + ": " + cudaGetErrorName(error) + " " + \
cudaGetErrorString(error); \
if (cudaErrorMemoryAllocation == error) { throw rmm::out_of_memory{msg}; } \
throw rmm::bad_alloc{msg}; \
} \
} while (0)

#define CUCASCADE_CUDA_TRY_ALLOC_1(_call) \
do { \
cudaError_t const error = (_call); \
if (cudaSuccess != error) { \
cudaGetLastError(); \
auto const msg = std::string{"CUDA error at: "} + __FILE__ + ":" + \
CUCASCADE_STRINGIFY(__LINE__) + ": " + cudaGetErrorName(error) + " " + \
cudaGetErrorString(error); \
if (cudaErrorMemoryAllocation == error) { throw rmm::out_of_memory{msg}; } \
throw rmm::bad_alloc{msg}; \
} \
} while (0)

/**
* @brief Debug-only CUDA error check (like assert for CUDA calls).
*
* In Release builds, invokes the call without checking. In Debug builds,
* asserts that the call returns cudaSuccess.
*/
#ifdef NDEBUG
#define CUCASCADE_ASSERT_CUDA_SUCCESS(_call) \
do { \
(_call); \
} while (0);
#else
#define CUCASCADE_ASSERT_CUDA_SUCCESS(_call) \
do { \
cudaError_t const status__ = (_call); \
if (status__ != cudaSuccess) { \
std::cerr << "CUDA Error detected. " << cudaGetErrorName(status__) << " " \
<< cudaGetErrorString(status__) << std::endl; \
} \
/* NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-array-to-pointer-decay) */ \
assert(status__ == cudaSuccess); \
} while (0)
#endif

// =============================================================================
// NVTX range macro (replacement for rmm/detail/nvtx/ranges.hpp)
// =============================================================================

#if defined(CUCASCADE_NVTX)
#include <nvtx3/nvtx3.hpp>

namespace cucascade {
/**
* @brief Tag type for cuCascade's NVTX domain.
*/
struct cucascade_domain {
static constexpr char const* name{"cucascade"};
};
} // namespace cucascade

/**
* @brief Convenience macro for generating an NVTX range in the `cucascade` domain
* from the lifetime of a function.
*/
#define CUCASCADE_FUNC_RANGE() NVTX3_FUNC_RANGE_IN(cucascade::cucascade_domain)
#else
#define CUCASCADE_FUNC_RANGE()
#endif
// cuda_utils.hpp is deprecated — use <cucascade/error.hpp> directly.
#include <cucascade/error.hpp>
1 change: 0 additions & 1 deletion include/cucascade/data/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include <cucascade/memory/memory_space.hpp>

#include <rmm/cuda_stream_view.hpp>
#include <rmm/mr/device_memory_resource.hpp>

#include <concepts>
#include <cstddef>
Expand Down
9 changes: 4 additions & 5 deletions include/cucascade/data/data_batch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class idata_batch_probe {
virtual ~idata_batch_probe() = default;

/**
* @brief The function that is called everytime a data_batch transitions into a new batch_state.
* @brief The function that is called every time a data_batch transitions into a new batch_state.
*
* @note It is the implementer's responsibility that a call to this function returns quickly, as
* this function is called in a thread-safe manner, and will block other mutating changes
Expand Down Expand Up @@ -540,12 +540,11 @@ void data_batch::convert_to(representation_converter_registry& registry,
auto new_representation =
registry.convert<TargetRepresentation>(*_data, target_memory_space, stream);
auto old_representation = std::move(_data);
_data = std::move(new_representation);
_data = std::move(new_representation);

bool needs_sync =
old_representation != nullptr &&
(old_representation->get_current_tier() == memory::Tier::GPU ||
_data->get_current_tier() == memory::Tier::GPU);
old_representation != nullptr && (old_representation->get_current_tier() == memory::Tier::GPU ||
_data->get_current_tier() == memory::Tier::GPU);

lock.unlock();

Expand Down
13 changes: 7 additions & 6 deletions include/cucascade/memory/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
#pragma once

#include <rmm/error.hpp>
#include <rmm/mr/device_memory_resource.hpp>

#include <cuda/memory_resource>

#include <cstdint>
#include <cstring>
Expand Down Expand Up @@ -60,14 +61,14 @@ class memory_space_id {
};

using DeviceMemoryResourceFactoryFn =
std::function<std::unique_ptr<rmm::mr::device_memory_resource>(int device_id,
std::size_t capacity)>;
std::function<cuda::mr::any_resource<cuda::mr::device_accessible>(int device_id,
std::size_t capacity)>;

std::unique_ptr<rmm::mr::device_memory_resource> make_default_gpu_memory_resource(
cuda::mr::any_resource<cuda::mr::device_accessible> make_default_gpu_memory_resource(
int device_id, std::size_t capacity);

std::unique_ptr<rmm::mr::device_memory_resource> make_default_host_memory_resource(
int device_id, std::size_t capacity);
cuda::mr::any_resource<cuda::mr::device_accessible, cuda::mr::host_accessible>
make_default_host_memory_resource(int device_id, std::size_t capacity);

DeviceMemoryResourceFactoryFn make_default_allocator_for_tier(Tier tier);

Expand Down
Loading
Loading