Loading...
Searching...
No Matches
fixed_size_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/fixed_size_memory_resource_impl.hpp>
10
11#include <cuda/memory_resource>
12
13#include <cstddef>
14
15RMM_NAMESPACE_BEGIN
16namespace mr {
22
32 : public cuda::mr::shared_resource<detail::fixed_size_memory_resource_impl> {
33 using shared_base = cuda::mr::shared_resource<detail::fixed_size_memory_resource_impl>;
34
35 public:
41 RMM_CONSTEXPR_FRIEND void get_property(fixed_size_memory_resource const&,
42 cuda::mr::device_accessible) noexcept
43 {
44 }
45
46 static constexpr std::size_t default_block_size = 1 << 20;
47
50 static constexpr std::size_t default_blocks_to_preallocate = 128;
51
64 cuda::mr::any_resource<cuda::mr::device_accessible> upstream,
65 // NOLINTNEXTLINE bugprone-easily-swappable-parameters
66 std::size_t block_size = default_block_size,
67 std::size_t blocks_to_preallocate = default_blocks_to_preallocate);
68
70
74 [[nodiscard]] device_async_resource_ref get_upstream_resource() const noexcept;
75
81 [[nodiscard]] std::size_t get_block_size() const noexcept;
82};
83
84static_assert(cuda::mr::resource_with<fixed_size_memory_resource, cuda::mr::device_accessible>,
85 "fixed_size_memory_resource does not satisfy the cuda::mr::resource concept");
86 // end of group
88} // namespace mr
89RMM_NAMESPACE_END
friend void get_property(fixed_size_memory_resource const &, cuda::mr::device_accessible) noexcept
Enables the cuda::mr::device_accessible property.
Definition fixed_size_memory_resource.hpp:41
static constexpr std::size_t default_block_size
Default allocation block size.
Definition fixed_size_memory_resource.hpp:46
std::size_t get_block_size() const noexcept
Get the size of blocks allocated by this memory resource.
fixed_size_memory_resource(cuda::mr::any_resource< cuda::mr::device_accessible > upstream, std::size_t block_size=default_block_size, std::size_t blocks_to_preallocate=default_blocks_to_preallocate)
Construct a new fixed_size_memory_resource that allocates memory from upstream.
static constexpr std::size_t default_blocks_to_preallocate
Definition fixed_size_memory_resource.hpp:50
device_async_resource_ref get_upstream_resource() const noexcept
device_async_resource_ref to the upstream resource
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.