cuda_async_managed_memory_resource.hpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 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/cuda_async_managed_memory_resource_impl.hpp>
10 
11 #include <cuda/memory_resource>
12 #include <cuda_runtime_api.h>
13 
14 #include <cstddef>
15 
16 namespace RMM_NAMESPACE {
17 namespace mr {
28 class RMM_EXPORT cuda_async_managed_memory_resource final
29  : public cuda::mr::shared_resource<detail::cuda_async_managed_memory_resource_impl> {
30  using shared_base = cuda::mr::shared_resource<detail::cuda_async_managed_memory_resource_impl>;
31 
32  public:
36  RMM_CONSTEXPR_FRIEND void get_property(cuda_async_managed_memory_resource const&,
37  cuda::mr::device_accessible) noexcept
38  {
39  }
40 
44  RMM_CONSTEXPR_FRIEND void get_property(cuda_async_managed_memory_resource const&,
45  cuda::mr::host_accessible) noexcept
46  {
47  }
48 
60 
66  [[nodiscard]] cudaMemPool_t pool_handle() const noexcept;
67 
70  default;
72  default;
74  default;
76  default;
77 };
78 
79 // static property checks
80 static_assert(cuda::mr::synchronous_resource<cuda_async_managed_memory_resource>);
81 static_assert(cuda::mr::resource<cuda_async_managed_memory_resource>);
82 static_assert(cuda::mr::synchronous_resource_with<cuda_async_managed_memory_resource,
83  cuda::mr::device_accessible>);
84 static_assert(cuda::mr::synchronous_resource_with<cuda_async_managed_memory_resource,
85  cuda::mr::host_accessible>);
86 static_assert(
87  cuda::mr::resource_with<cuda_async_managed_memory_resource, cuda::mr::device_accessible>);
88 static_assert(
89  cuda::mr::resource_with<cuda_async_managed_memory_resource, cuda::mr::host_accessible>);
90  // end of group
92 } // namespace mr
93 } // namespace RMM_NAMESPACE
Memory resource that uses cudaMallocFromPoolAsync/cudaFreeFromPoolAsync with a managed memory pool fo...
Definition: cuda_async_managed_memory_resource.hpp:29
cuda_async_managed_memory_resource()
Constructs a cuda_async_managed_memory_resource with the default managed memory pool for the current ...
cudaMemPool_t pool_handle() const noexcept
Returns the underlying native handle to the CUDA pool.
friend void get_property(cuda_async_managed_memory_resource const &, cuda::mr::device_accessible) noexcept
Enables the cuda::mr::device_accessible property.
Definition: cuda_async_managed_memory_resource.hpp:36
friend void get_property(cuda_async_managed_memory_resource const &, cuda::mr::host_accessible) noexcept
Enables the cuda::mr::host_accessible property.
Definition: cuda_async_managed_memory_resource.hpp:44