Loading...
Searching...
No Matches
limiting_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/limiting_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 {
36 : public cuda::mr::shared_resource<detail::limiting_resource_adaptor_impl> {
37 using shared_base = cuda::mr::shared_resource<detail::limiting_resource_adaptor_impl>;
38
39 public:
43 RMM_CONSTEXPR_FRIEND void get_property(limiting_resource_adaptor const&,
44 cuda::mr::device_accessible) noexcept
45 {
46 }
47
56 limiting_resource_adaptor(cuda::mr::any_resource<cuda::mr::device_accessible> upstream,
57 std::size_t allocation_limit,
58 std::size_t alignment = rmm::CUDA_ALLOCATION_ALIGNMENT);
59
61
65 [[nodiscard]] device_async_resource_ref get_upstream_resource() const noexcept;
66
76 [[nodiscard]] std::size_t get_allocated_bytes() const;
77
85 [[nodiscard]] std::size_t get_allocation_limit() const;
86};
87
88static_assert(cuda::mr::resource_with<limiting_resource_adaptor, cuda::mr::device_accessible>,
89 "limiting_resource_adaptor does not satisfy the cuda::mr::resource concept");
90 // end of group
92} // namespace mr
93RMM_NAMESPACE_END
limiting_resource_adaptor(cuda::mr::any_resource< cuda::mr::device_accessible > upstream, std::size_t allocation_limit, std::size_t alignment=rmm::CUDA_ALLOCATION_ALIGNMENT)
Construct a new limiting resource adaptor using upstream to satisfy allocation requests and limiting ...
device_async_resource_ref get_upstream_resource() const noexcept
device_async_resource_ref to the upstream resource
friend void get_property(limiting_resource_adaptor const &, cuda::mr::device_accessible) noexcept
Enables the cuda::mr::device_accessible property.
Definition limiting_resource_adaptor.hpp:43
std::size_t get_allocation_limit() const
Query the maximum number of bytes that this allocator is allowed to allocate. This is the limit on th...
std::size_t get_allocated_bytes() const
Query the number of bytes that have been allocated. Note that this can not be used to know how large ...
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.