Loading...
Searching...
No Matches
binning_memory_resource.hpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3 * SPDX-License-Identifier: Apache-2.0
4 */
5#pragma once
6
7#include <rmm/detail/export.hpp>
8#include <rmm/mr/detail/binning_memory_resource_impl.hpp>
10
11#include <cuda/memory_resource>
12
13#include <cstddef>
14#include <optional>
15
16RMM_NAMESPACE_BEGIN
17namespace mr {
23
31 : public cuda::mr::shared_resource<detail::binning_memory_resource_impl> {
32 using shared_base = cuda::mr::shared_resource<detail::binning_memory_resource_impl>;
33
34 public:
40 RMM_CONSTEXPR_FRIEND void get_property(binning_memory_resource const&,
41 cuda::mr::device_accessible) noexcept
42 {
43 }
44
53 explicit binning_memory_resource(cuda::mr::any_resource<cuda::mr::device_accessible> upstream);
54
67 binning_memory_resource(cuda::mr::any_resource<cuda::mr::device_accessible> upstream,
68 int8_t min_size_exponent, // NOLINT(bugprone-easily-swappable-parameters)
69 int8_t max_size_exponent);
70
71 ~binning_memory_resource() = default;
72
76 [[nodiscard]] device_async_resource_ref get_upstream_resource() const noexcept;
77
93 void add_bin(std::size_t allocation_size,
94 std::optional<device_async_resource_ref> bin_resource = std::nullopt);
95};
96
97static_assert(cuda::mr::resource_with<binning_memory_resource, cuda::mr::device_accessible>,
98 "binning_memory_resource does not satisfy the cuda::mr::resource concept");
99 // end of group
101} // namespace mr
102RMM_NAMESPACE_END
void add_bin(std::size_t allocation_size, std::optional< device_async_resource_ref > bin_resource=std::nullopt)
Add a bin allocator to this resource.
binning_memory_resource(cuda::mr::any_resource< cuda::mr::device_accessible > upstream, int8_t min_size_exponent, int8_t max_size_exponent)
Construct a new binning memory resource object with a range of initial bins.
device_async_resource_ref get_upstream_resource() const noexcept
device_async_resource_ref to the upstream resource
binning_memory_resource(cuda::mr::any_resource< cuda::mr::device_accessible > upstream)
Construct a new binning memory resource object.
friend void get_property(binning_memory_resource const &, cuda::mr::device_accessible) noexcept
Enables the cuda::mr::device_accessible property.
Definition binning_memory_resource.hpp:40
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.