Loading...
Searching...
No Matches
cuda_async_memory_resource.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/cuda_async_memory_resource_impl.hpp>
10
11#include <cuda/memory_resource>
12#include <cuda_runtime_api.h>
13
14#include <cstddef>
15#include <cstdint>
16#include <optional>
17
18RMM_NAMESPACE_BEGIN
19namespace mr {
25
30class RMM_EXPORT cuda_async_memory_resource final
31 : public cuda::mr::shared_resource<detail::cuda_async_memory_resource_impl> {
32 using shared_base = cuda::mr::shared_resource<detail::cuda_async_memory_resource_impl>;
33
34 public:
47 enum class allocation_handle_type : std::int32_t {
48 none = cudaMemHandleTypeNone,
49 posix_file_descriptor =
50 cudaMemHandleTypePosixFileDescriptor,
52 win32 =
53 cudaMemHandleTypeWin32,
54 win32_kmt = cudaMemHandleTypeWin32Kmt,
56 fabric = 0x8
57 };
58
62 RMM_CONSTEXPR_FRIEND void get_property(cuda_async_memory_resource const&,
63 cuda::mr::device_accessible) noexcept
64 {
65 }
66
86 // NOLINTNEXTLINE(bugprone-easily-swappable-parameters)
87 cuda_async_memory_resource(std::optional<std::size_t> initial_pool_size = {},
88 std::optional<std::size_t> release_threshold = {},
89 std::optional<allocation_handle_type> export_handle_type = {});
90
96 [[nodiscard]] cudaMemPool_t pool_handle() const noexcept;
97
98 ~cuda_async_memory_resource() = default;
100 default;
102 default;
104 default;
106 default;
107};
108
109// static property checks
110static_assert(cuda::mr::synchronous_resource<cuda_async_memory_resource>);
111static_assert(cuda::mr::resource<cuda_async_memory_resource>);
112static_assert(
113 cuda::mr::synchronous_resource_with<cuda_async_memory_resource, cuda::mr::device_accessible>);
114static_assert(cuda::mr::resource_with<cuda_async_memory_resource, cuda::mr::device_accessible>);
115 // end of group
117} // namespace mr
118RMM_NAMESPACE_END
allocation_handle_type
Flags for specifying memory allocation handle types.
Definition cuda_async_memory_resource.hpp:47
friend void get_property(cuda_async_memory_resource const &, cuda::mr::device_accessible) noexcept
Enables the cuda::mr::device_accessible property.
Definition cuda_async_memory_resource.hpp:62
cuda_async_memory_resource(std::optional< std::size_t > initial_pool_size={}, std::optional< std::size_t > release_threshold={}, std::optional< allocation_handle_type > export_handle_type={})
Constructs a cuda_async_memory_resource with the optionally specified initial pool size and release t...
cudaMemPool_t pool_handle() const noexcept
Returns the underlying native handle to the CUDA pool.
Memory Resource classes and adaptors.