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
90 changes: 48 additions & 42 deletions cpp/include/rmm/device_buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ namespace RMM_NAMESPACE {
* @brief RAII construct for device memory allocation
*
* This class allocates untyped and *uninitialized* device memory using a
* `device_async_resource_ref`. If not explicitly specified, the memory resource
* returned from `get_current_device_resource_ref()` is used.
* `cuda::mr::any_resource<cuda::mr::device_accessible>`. If not explicitly specified, the memory
* resource returned from `get_current_device_resource_ref()` is used.
*
* @note Unlike `std::vector` or `thrust::device_vector`, the device memory
* allocated by a `device_buffer` is uninitialized. Therefore, it is undefined
Expand Down Expand Up @@ -98,24 +98,26 @@ class device_buffer {
* resource supports streams.
* @param mr Memory resource to use for the device memory allocation.
*/
explicit device_buffer(std::size_t size,
cuda_stream_view stream,
device_async_resource_ref mr = mr::get_current_device_resource_ref());
explicit device_buffer(
std::size_t size,
cuda_stream_view stream,
cuda::mr::any_resource<cuda::mr::device_accessible> mr = mr::get_current_device_resource_ref());

/**
* @copydoc device_buffer(std::size_t, cuda_stream_view, device_async_resource_ref)
*
* @throws rmm::bad_alloc If the requested alignment cannot be satisfied by the provided
* memory resource.
* @throws rmm::invalid_argument If the requested alignment is not a power of two
*
* @param alignment Required alignment of the allocation. The actual alignment will be
* at least the requested alignment.
*/
explicit device_buffer(std::size_t size,
std::size_t alignment,
cuda_stream_view stream,
device_async_resource_ref mr = mr::get_current_device_resource_ref());
// clang-format off
/// @copydoc device_buffer(std::size_t, cuda_stream_view, cuda::mr::any_resource<cuda::mr::device_accessible>)
// clang-format on
///
/// @throws rmm::bad_alloc If the requested alignment cannot be satisfied by the provided
/// memory resource.
/// @throws rmm::invalid_argument If the requested alignment is not a power of two
///
/// @param alignment Required alignment of the allocation. The actual alignment will be
/// at least the requested alignment.
explicit device_buffer(
std::size_t size,
std::size_t alignment,
cuda_stream_view stream,
cuda::mr::any_resource<cuda::mr::device_accessible> mr = mr::get_current_device_resource_ref());

/**
* @brief Construct a new device buffer by copying from a raw pointer to an existing host or
Expand All @@ -140,26 +142,28 @@ class device_buffer {
* resource supports streams.
* @param mr Memory resource to use for the device memory allocation
*/
device_buffer(void const* source_data,
std::size_t size,
cuda_stream_view stream,
device_async_resource_ref mr = mr::get_current_device_resource_ref());
device_buffer(
void const* source_data,
std::size_t size,
cuda_stream_view stream,
cuda::mr::any_resource<cuda::mr::device_accessible> mr = mr::get_current_device_resource_ref());

/**
* @copydoc device_buffer(void const *, std::size_t, cuda_stream_view, device_async_resource_ref)
*
* @throws rmm::bad_alloc If the requested alignment cannot be satisfied by the provided
* memory resource.
* @throws rmm::invalid_argument If the requested alignment is not a power of two
*
* @param alignment Required alignment of the allocation. The actual alignment will be
* at least the requested alignment.
*/
explicit device_buffer(void const* source_data,
std::size_t size,
std::size_t alignment,
cuda_stream_view stream,
device_async_resource_ref mr = mr::get_current_device_resource_ref());
// clang-format off
/// @copydoc device_buffer(void const*, std::size_t, cuda_stream_view, cuda::mr::any_resource<cuda::mr::device_accessible>)
// clang-format on
///
/// @throws rmm::bad_alloc If the requested alignment cannot be satisfied by the provided
/// memory resource.
/// @throws rmm::invalid_argument If the requested alignment is not a power of two
///
/// @param alignment Required alignment of the allocation. The actual alignment will be
/// at least the requested alignment.
explicit device_buffer(
void const* source_data,
std::size_t size,
std::size_t alignment,
cuda_stream_view stream,
cuda::mr::any_resource<cuda::mr::device_accessible> mr = mr::get_current_device_resource_ref());
/**
* @brief Construct a new `device_buffer` by deep copying the contents of
* another `device_buffer`, optionally using the specified stream and memory
Expand All @@ -171,7 +175,8 @@ class device_buffer {
*
* @note The new buffer has the same alignment guarantees as the copied-from buffer. If you need
*to control the alignment of the new buffer explicitly, use `device_buffer(void const*,
* std::size_t, std::size_t, cuda_stream_view, device_async_resource_ref)`.
* std::size_t, std::size_t, cuda_stream_view,
*cuda::mr::any_resource<cuda::mr::device_accessible>)`.
*
* @note This function does not synchronize `stream`. `other` is copied on `stream`, so the
* caller is responsible for correct synchronization to ensure that `other` is valid when
Expand All @@ -185,9 +190,10 @@ class device_buffer {
* @param stream The stream to use for the allocation and copy
* @param mr The resource to use for allocating the new `device_buffer`
*/
device_buffer(device_buffer const& other,
cuda_stream_view stream,
device_async_resource_ref mr = mr::get_current_device_resource_ref());
device_buffer(
device_buffer const& other,
cuda_stream_view stream,
cuda::mr::any_resource<cuda::mr::device_accessible> mr = mr::get_current_device_resource_ref());

/**
* @brief Constructs a new `device_buffer` by moving the contents of another
Expand Down
25 changes: 14 additions & 11 deletions cpp/include/rmm/device_scalar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@ class device_scalar {
* @param stream Stream on which to perform asynchronous allocation.
* @param mr Optional, resource with which to allocate.
*/
explicit device_scalar(cuda_stream_view stream,
device_async_resource_ref mr = mr::get_current_device_resource_ref())
: _storage{1, stream, mr}
explicit device_scalar(
cuda_stream_view stream,
cuda::mr::any_resource<cuda::mr::device_accessible> mr = mr::get_current_device_resource_ref())
: _storage{1, stream, std::move(mr)}
{
}

Expand All @@ -107,10 +108,11 @@ class device_scalar {
* @param stream Optional, stream on which to perform allocation and copy.
* @param mr Optional, resource with which to allocate.
*/
explicit device_scalar(value_type const& initial_value,
cuda_stream_view stream,
device_async_resource_ref mr = mr::get_current_device_resource_ref())
: _storage{1, stream, mr}
explicit device_scalar(
value_type const& initial_value,
cuda_stream_view stream,
cuda::mr::any_resource<cuda::mr::device_accessible> mr = mr::get_current_device_resource_ref())
: _storage{1, stream, std::move(mr)}
{
set_value_async(initial_value, stream);
}
Expand All @@ -127,10 +129,11 @@ class device_scalar {
* @param stream The stream to use for the allocation and copy
* @param mr The resource to use for allocating the new `device_scalar`
*/
device_scalar(device_scalar const& other,
cuda_stream_view stream,
device_async_resource_ref mr = mr::get_current_device_resource_ref())
: _storage{other._storage, stream, mr}
device_scalar(
device_scalar const& other,
cuda_stream_view stream,
cuda::mr::any_resource<cuda::mr::device_accessible> mr = mr::get_current_device_resource_ref())
: _storage{other._storage, stream, std::move(mr)}
{
}

Expand Down
18 changes: 10 additions & 8 deletions cpp/include/rmm/device_uvector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,11 @@ class device_uvector {
* @param stream The stream on which to perform the allocation
* @param mr The resource used to allocate the device storage
*/
explicit device_uvector(size_type size,
cuda_stream_view stream,
device_async_resource_ref mr = mr::get_current_device_resource_ref())
: _storage{elements_to_bytes(size), std::alignment_of_v<T>, stream, mr}
explicit device_uvector(
size_type size,
cuda_stream_view stream,
cuda::mr::any_resource<cuda::mr::device_accessible> mr = mr::get_current_device_resource_ref())
: _storage{elements_to_bytes(size), std::alignment_of_v<T>, stream, std::move(mr)}
{
}

Expand All @@ -140,10 +141,11 @@ class device_uvector {
* @param stream The stream on which to perform the copy
* @param mr The resource used to allocate device memory for the new vector
*/
explicit device_uvector(device_uvector const& other,
cuda_stream_view stream,
device_async_resource_ref mr = mr::get_current_device_resource_ref())
: _storage{other._storage, stream, mr}
explicit device_uvector(
device_uvector const& other,
cuda_stream_view stream,
cuda::mr::any_resource<cuda::mr::device_accessible> mr = mr::get_current_device_resource_ref())
: _storage{other._storage, stream, std::move(mr)}
{
}

Expand Down
12 changes: 7 additions & 5 deletions cpp/include/rmm/exec_policy.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2020-2025, NVIDIA CORPORATION.
* SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION.
* SPDX-License-Identifier: Apache-2.0
*/

Expand Down Expand Up @@ -45,8 +45,9 @@ class exec_policy : public thrust_exec_policy_t {
* @param stream The stream on which to allocate temporary memory
* @param mr The resource to use for allocating temporary memory
*/
explicit exec_policy(cuda_stream_view stream = cuda_stream_default,
device_async_resource_ref mr = mr::get_current_device_resource_ref());
explicit exec_policy(
cuda_stream_view stream = cuda_stream_default,
cuda::mr::any_resource<cuda::mr::device_accessible> mr = mr::get_current_device_resource_ref());
};

/**
Expand All @@ -70,8 +71,9 @@ class exec_policy_nosync : public thrust_exec_policy_nosync_t {
* @param stream The stream on which to allocate temporary memory
* @param mr The resource to use for allocating temporary memory
*/
explicit exec_policy_nosync(cuda_stream_view stream = cuda_stream_default,
device_async_resource_ref mr = mr::get_current_device_resource_ref());
explicit exec_policy_nosync(
cuda_stream_view stream = cuda_stream_default,
cuda::mr::any_resource<cuda::mr::device_accessible> mr = mr::get_current_device_resource_ref());
};

/** @} */ // end of group
Expand Down
2 changes: 1 addition & 1 deletion cpp/include/rmm/mr/aligned_resource_adaptor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class RMM_EXPORT aligned_resource_adaptor
* if smaller).
* @param alignment_threshold Only allocations >= this size are aligned to `alignment`.
*/
explicit aligned_resource_adaptor(device_async_resource_ref upstream,
explicit aligned_resource_adaptor(cuda::mr::any_resource<cuda::mr::device_accessible> upstream,
// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)
std::size_t alignment = rmm::CUDA_ALLOCATION_ALIGNMENT,
std::size_t alignment_threshold = default_alignment_threshold);
Expand Down
4 changes: 2 additions & 2 deletions cpp/include/rmm/mr/arena_memory_resource.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ class RMM_EXPORT arena_memory_resource
/**
* @brief Construct an `arena_memory_resource`.
*
* @param upstream_mr The memory resource from which to allocate blocks for the global arena.
* @param upstream The resource from which to allocate blocks for the global arena.
* @param arena_size Size in bytes of the global arena. Defaults to half of the available
* memory on the current device.
* @param dump_log_on_failure If true, dump memory log when running out of memory.
*/
explicit arena_memory_resource(device_async_resource_ref upstream_mr,
explicit arena_memory_resource(cuda::mr::any_resource<cuda::mr::device_accessible> upstream,
std::optional<std::size_t> arena_size = std::nullopt,
bool dump_log_on_failure = false);

Expand Down
10 changes: 5 additions & 5 deletions cpp/include/rmm/mr/binning_memory_resource.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ class RMM_EXPORT binning_memory_resource
/**
* @brief Construct a new binning memory resource object.
*
* Initially has no bins, so simply uses the upstream_resource until bin resources are added
* Initially has no bins, so simply uses the upstream resource until bin resources are added
* with `add_bin`.
*
* @param upstream_resource The upstream memory resource used to allocate bin pools.
* @param upstream The resource used to allocate bin pools.
*/
explicit binning_memory_resource(device_async_resource_ref upstream_resource);
explicit binning_memory_resource(cuda::mr::any_resource<cuda::mr::device_accessible> upstream);

/**
* @brief Construct a new binning memory resource object with a range of initial bins.
Expand All @@ -60,11 +60,11 @@ class RMM_EXPORT binning_memory_resource
* and `max_size_exponent==22`, creates bins of sizes 256KiB, 512KiB, 1024KiB, 2048KiB and
* 4096KiB.
*
* @param upstream_resource The upstream memory resource used to allocate bin pools.
* @param upstream The resource used to allocate bin pools.
* @param min_size_exponent The minimum base-2 exponent bin size.
* @param max_size_exponent The maximum base-2 exponent bin size.
*/
binning_memory_resource(device_async_resource_ref upstream_resource,
binning_memory_resource(cuda::mr::any_resource<cuda::mr::device_accessible> upstream,
int8_t min_size_exponent, // NOLINT(bugprone-easily-swappable-parameters)
int8_t max_size_exponent);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class aligned_resource_adaptor_impl {
public:
static constexpr std::size_t default_alignment_threshold = 0;

aligned_resource_adaptor_impl(device_async_resource_ref upstream,
aligned_resource_adaptor_impl(cuda::mr::any_resource<cuda::mr::device_accessible> upstream,
std::size_t alignment,
std::size_t alignment_threshold);

Expand Down
5 changes: 3 additions & 2 deletions cpp/include/rmm/mr/detail/arena.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,8 +490,9 @@ class global_arena final {
* @param arena_size Size in bytes of the global arena. Defaults to half of the available memory
* on the current device.
*/
global_arena(device_async_resource_ref upstream_mr, std::optional<std::size_t> arena_size)
: upstream_mr_{upstream_mr}
global_arena(cuda::mr::any_resource<cuda::mr::device_accessible> upstream_mr,
std::optional<std::size_t> arena_size)
: upstream_mr_{std::move(upstream_mr)}
{
auto const size =
rmm::align_down(arena_size.value_or(default_size()), rmm::CUDA_ALLOCATION_ALIGNMENT);
Expand Down
2 changes: 1 addition & 1 deletion cpp/include/rmm/mr/detail/arena_memory_resource_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace detail {
*/
class arena_memory_resource_impl {
public:
arena_memory_resource_impl(device_async_resource_ref upstream_mr,
arena_memory_resource_impl(cuda::mr::any_resource<cuda::mr::device_accessible> upstream_mr,
std::optional<std::size_t> arena_size,
bool dump_log_on_failure);

Expand Down
5 changes: 3 additions & 2 deletions cpp/include/rmm/mr/detail/binning_memory_resource_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ namespace detail {
*/
class binning_memory_resource_impl {
public:
explicit binning_memory_resource_impl(device_async_resource_ref upstream);
explicit binning_memory_resource_impl(
cuda::mr::any_resource<cuda::mr::device_accessible> upstream);

binning_memory_resource_impl(device_async_resource_ref upstream,
binning_memory_resource_impl(cuda::mr::any_resource<cuda::mr::device_accessible> upstream,
int8_t min_size_exponent,
int8_t max_size_exponent);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ namespace detail {
template <typename ExceptionType>
class failure_callback_resource_adaptor_impl {
public:
failure_callback_resource_adaptor_impl(device_async_resource_ref upstream,
failure_callback_t callback,
void* callback_arg)
: upstream_mr_{upstream}, callback_{std::move(callback)}, callback_arg_{callback_arg}
failure_callback_resource_adaptor_impl(
cuda::mr::any_resource<cuda::mr::device_accessible> upstream,
failure_callback_t callback,
void* callback_arg)
: upstream_mr_{std::move(upstream)}, callback_{std::move(callback)}, callback_arg_{callback_arg}
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class fixed_size_memory_resource_impl final
static constexpr std::size_t default_block_size = 1 << 20;
static constexpr std::size_t default_blocks_to_preallocate = 128;

fixed_size_memory_resource_impl(device_async_resource_ref upstream,
fixed_size_memory_resource_impl(cuda::mr::any_resource<cuda::mr::device_accessible> upstream,
std::size_t block_size,
std::size_t blocks_to_preallocate);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace detail {
*/
class limiting_resource_adaptor_impl {
public:
limiting_resource_adaptor_impl(device_async_resource_ref upstream,
limiting_resource_adaptor_impl(cuda::mr::any_resource<cuda::mr::device_accessible> upstream,
std::size_t allocation_limit,
std::size_t alignment);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace detail {
class logging_resource_adaptor_impl {
public:
logging_resource_adaptor_impl(std::shared_ptr<rapids_logger::logger> logger,
device_async_resource_ref upstream,
cuda::mr::any_resource<cuda::mr::device_accessible> upstream,
bool auto_flush);

void* allocate_sync(std::size_t bytes, std::size_t alignment = alignof(std::max_align_t));
Expand Down
2 changes: 1 addition & 1 deletion cpp/include/rmm/mr/detail/pool_memory_resource_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class pool_memory_resource_impl final
public:
friend class stream_ordered_memory_resource<pool_memory_resource_impl, coalescing_free_list>;

pool_memory_resource_impl(device_async_resource_ref upstream,
pool_memory_resource_impl(cuda::mr::any_resource<cuda::mr::device_accessible> upstream,
std::size_t initial_pool_size,
std::optional<std::size_t> maximum_pool_size);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ namespace detail {
*/
class prefetch_resource_adaptor_impl {
public:
explicit prefetch_resource_adaptor_impl(device_async_resource_ref upstream);
explicit prefetch_resource_adaptor_impl(
cuda::mr::any_resource<cuda::mr::device_accessible> upstream);

~prefetch_resource_adaptor_impl() = default;

Expand Down
Loading
Loading