sam_headroom_memory_resource.hpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION.
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/sam_headroom_memory_resource_impl.hpp>
10 
11 #include <cuda/memory_resource>
12 
13 #include <cstddef>
14 
15 namespace RMM_NAMESPACE {
16 namespace mr {
35 class RMM_EXPORT sam_headroom_memory_resource final
36  : public cuda::mr::shared_resource<detail::sam_headroom_memory_resource_impl> {
37  using shared_base = cuda::mr::shared_resource<detail::sam_headroom_memory_resource_impl>;
38 
39  public:
43  RMM_CONSTEXPR_FRIEND void get_property(sam_headroom_memory_resource const&,
44  cuda::mr::device_accessible) noexcept
45  {
46  }
47 
51  RMM_CONSTEXPR_FRIEND void get_property(sam_headroom_memory_resource const&,
52  cuda::mr::host_accessible) noexcept
53  {
54  }
55 
61  explicit sam_headroom_memory_resource(std::size_t headroom);
62 
64  ~sam_headroom_memory_resource() = default;
66  default;
68  default;
70  default;
72  default;
73 };
74 
75 // static property checks
76 static_assert(cuda::mr::synchronous_resource<sam_headroom_memory_resource>);
77 static_assert(cuda::mr::resource<sam_headroom_memory_resource>);
78 static_assert(
79  cuda::mr::synchronous_resource_with<sam_headroom_memory_resource, cuda::mr::device_accessible>);
80 static_assert(
81  cuda::mr::synchronous_resource_with<sam_headroom_memory_resource, cuda::mr::host_accessible>);
82 static_assert(cuda::mr::resource_with<sam_headroom_memory_resource, cuda::mr::device_accessible>);
83 static_assert(cuda::mr::resource_with<sam_headroom_memory_resource, cuda::mr::host_accessible>);
84  // end of group
86 } // namespace mr
87 } // namespace RMM_NAMESPACE
Resource that uses system memory resource to allocate memory with a headroom.
Definition: sam_headroom_memory_resource.hpp:36
sam_headroom_memory_resource & operator=(sam_headroom_memory_resource &&)=default
Default move assignment operator.
sam_headroom_memory_resource(sam_headroom_memory_resource const &)=default
Default copy constructor.
friend void get_property(sam_headroom_memory_resource const &, cuda::mr::device_accessible) noexcept
Enables the cuda::mr::device_accessible property.
Definition: sam_headroom_memory_resource.hpp:43
sam_headroom_memory_resource & operator=(sam_headroom_memory_resource const &)=default
Default copy assignment operator.
sam_headroom_memory_resource(std::size_t headroom)
Construct a headroom memory resource.
sam_headroom_memory_resource(sam_headroom_memory_resource &&)=default
Default move constructor.
friend void get_property(sam_headroom_memory_resource const &, cuda::mr::host_accessible) noexcept
Enables the cuda::mr::host_accessible property.
Definition: sam_headroom_memory_resource.hpp:51