Loading...
Searching...
No Matches
aligned_resource_adaptor.hpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3 * SPDX-License-Identifier: Apache-2.0
4 */
5#pragma once
6
7#include <rmm/aligned.hpp>
8#include <rmm/detail/export.hpp>
9#include <rmm/mr/detail/aligned_resource_adaptor_impl.hpp>
10#include <rmm/resource_ref.hpp>
11
12#include <cuda/memory_resource>
13
14#include <cstddef>
15
16RMM_NAMESPACE_BEGIN
17namespace mr {
34 : public cuda::mr::shared_resource<detail::aligned_resource_adaptor_impl> {
35 using shared_base = cuda::mr::shared_resource<detail::aligned_resource_adaptor_impl>;
36
37 public:
41 RMM_CONSTEXPR_FRIEND void get_property(aligned_resource_adaptor const&,
42 cuda::mr::device_accessible) noexcept
43 {
44 }
45
49 static constexpr std::size_t default_alignment_threshold =
50 detail::aligned_resource_adaptor_impl::default_alignment_threshold;
51
62 explicit aligned_resource_adaptor(cuda::mr::any_resource<cuda::mr::device_accessible> upstream,
63 // NOLINTNEXTLINE(bugprone-easily-swappable-parameters)
64 std::size_t alignment = rmm::CUDA_ALLOCATION_ALIGNMENT,
65 std::size_t alignment_threshold = default_alignment_threshold);
66
67 ~aligned_resource_adaptor() = default;
68
72 [[nodiscard]] device_async_resource_ref get_upstream_resource() const noexcept;
73};
74
75static_assert(cuda::mr::resource_with<aligned_resource_adaptor, cuda::mr::device_accessible>,
76 "aligned_resource_adaptor does not satisfy the cuda::mr::resource concept");
77 // end of group
79} // namespace mr
80RMM_NAMESPACE_END
device_async_resource_ref get_upstream_resource() const noexcept
rmm::device_async_resource_ref to the upstream resource
friend void get_property(aligned_resource_adaptor const &, cuda::mr::device_accessible) noexcept
Enables the cuda::mr::device_accessible property.
Definition aligned_resource_adaptor.hpp:41
static constexpr std::size_t default_alignment_threshold
The default alignment threshold used by the adaptor (0 = always align).
Definition aligned_resource_adaptor.hpp:49
aligned_resource_adaptor(cuda::mr::any_resource< cuda::mr::device_accessible > upstream, std::size_t alignment=rmm::CUDA_ALLOCATION_ALIGNMENT, std::size_t alignment_threshold=default_alignment_threshold)
Construct an aligned resource adaptor using upstream to satisfy allocation requests.
cuda::mr::resource_ref< cuda::mr::device_accessible > device_async_resource_ref
Alias for a cuda::mr::resource_ref with the property cuda::mr::device_accessible.
Definition resource_ref.hpp:30
Memory Resource classes and adaptors.