Loading...
Searching...
No Matches
resource_ref.hpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3 * SPDX-License-Identifier: Apache-2.0
4 */
5#pragma once
6
7#include <rmm/detail/error.hpp>
8#include <rmm/detail/export.hpp>
9
10#include <cuda/memory_resource>
11
12RMM_NAMESPACE_BEGIN
13
19
24using device_resource_ref = cuda::mr::synchronous_resource_ref<cuda::mr::device_accessible>;
25
30using device_async_resource_ref = cuda::mr::resource_ref<cuda::mr::device_accessible>;
31
36using host_resource_ref = cuda::mr::synchronous_resource_ref<cuda::mr::host_accessible>;
37
42using host_async_resource_ref = cuda::mr::resource_ref<cuda::mr::host_accessible>;
43
49 cuda::mr::synchronous_resource_ref<cuda::mr::host_accessible, cuda::mr::device_accessible>;
50
56 cuda::mr::resource_ref<cuda::mr::host_accessible, cuda::mr::device_accessible>;
57
67template <class Resource>
69{
70 RMM_EXPECTS(res, "Unexpected null resource pointer.");
71 return device_async_resource_ref{*res};
72}
73
74// Verify that host_device resource refs can be converted to device-only and host-only resource
75// refs. This is needed because a resource that is both host and device accessible can be used in
76// contexts that only require one or the other.
77static_assert(
78 std::is_constructible_v<device_async_resource_ref, host_device_async_resource_ref>,
79 "device_async_resource_ref must be constructible from host_device_async_resource_ref");
80static_assert(std::is_constructible_v<device_resource_ref, host_device_resource_ref>,
81 "device_resource_ref must be constructible from host_device_resource_ref");
82static_assert(std::is_constructible_v<host_async_resource_ref, host_device_async_resource_ref>,
83 "host_async_resource_ref must be constructible from host_device_async_resource_ref");
84static_assert(std::is_constructible_v<host_resource_ref, host_device_resource_ref>,
85 "host_resource_ref must be constructible from host_device_resource_ref");
86 // end of group
88RMM_NAMESPACE_END
cuda::mr::resource_ref< cuda::mr::host_accessible, cuda::mr::device_accessible > host_device_async_resource_ref
Alias for a cuda::mr::resource_ref with the properties cuda::mr::host_accessible and cuda::mr::device...
Definition resource_ref.hpp:55
cuda::mr::resource_ref< cuda::mr::host_accessible > host_async_resource_ref
Alias for a cuda::mr::resource_ref with the property cuda::mr::host_accessible.
Definition resource_ref.hpp:42
cuda::mr::synchronous_resource_ref< cuda::mr::host_accessible, cuda::mr::device_accessible > host_device_resource_ref
Alias for a cuda::mr::synchronous_resource_ref with the properties cuda::mr::host_accessible and cuda...
Definition resource_ref.hpp:48
cuda::mr::synchronous_resource_ref< cuda::mr::host_accessible > host_resource_ref
Alias for a cuda::mr::synchronous_resource_ref with the property cuda::mr::host_accessible.
Definition resource_ref.hpp:36
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
cuda::mr::synchronous_resource_ref< cuda::mr::device_accessible > device_resource_ref
Alias for a cuda::mr::synchronous_resource_ref with the property cuda::mr::device_accessible.
Definition resource_ref.hpp:24
device_async_resource_ref to_device_async_resource_ref_checked(Resource *res)
Convert pointer to memory resource into device_async_resource_ref, checking for nullptr.
Definition resource_ref.hpp:68