resource_ref.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2024-2025, NVIDIA CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #pragma once
17 
18 #include <rmm/detail/cccl_adaptors.hpp>
19 #include <rmm/detail/cuda_memory_resource.hpp>
20 #include <rmm/detail/error.hpp>
21 #include <rmm/detail/export.hpp>
22 
23 namespace RMM_NAMESPACE {
24 
31 #if CCCL_MAJOR_VERSION > 3 || (CCCL_MAJOR_VERSION == 3 && CCCL_MINOR_VERSION >= 1)
32 
37 using device_resource_ref =
38  detail::cccl_resource_ref<cuda::mr::synchronous_resource_ref<cuda::mr::device_accessible>>;
39 
45  detail::cccl_async_resource_ref<cuda::mr::resource_ref<cuda::mr::device_accessible>>;
46 
51 using host_resource_ref =
52  detail::cccl_resource_ref<cuda::mr::synchronous_resource_ref<cuda::mr::host_accessible>>;
53 
59  detail::cccl_async_resource_ref<cuda::mr::resource_ref<cuda::mr::host_accessible>>;
60 
65 using host_device_resource_ref = detail::cccl_resource_ref<
66  cuda::mr::synchronous_resource_ref<cuda::mr::host_accessible, cuda::mr::device_accessible>>;
67 
72 using host_device_async_resource_ref = detail::cccl_async_resource_ref<
73  cuda::mr::resource_ref<cuda::mr::host_accessible, cuda::mr::device_accessible>>;
74 
75 #else
76 
82  detail::cccl_resource_ref<cuda::mr::resource_ref<cuda::mr::device_accessible>>;
83 
89  detail::cccl_async_resource_ref<cuda::mr::async_resource_ref<cuda::mr::device_accessible>>;
90 
96  detail::cccl_resource_ref<cuda::mr::resource_ref<cuda::mr::host_accessible>>;
97 
103  detail::cccl_async_resource_ref<cuda::mr::async_resource_ref<cuda::mr::host_accessible>>;
104 
109 using host_device_resource_ref = detail::cccl_resource_ref<
110  cuda::mr::resource_ref<cuda::mr::host_accessible, cuda::mr::device_accessible>>;
111 
116 using host_device_async_resource_ref = detail::cccl_async_resource_ref<
117  cuda::mr::async_resource_ref<cuda::mr::host_accessible, cuda::mr::device_accessible>>;
118 
119 #endif
120 
130 template <class Resource>
132 {
133  RMM_EXPECTS(res, "Unexpected null resource pointer.");
134  return device_async_resource_ref{*res};
135 }
136  // end of group
138 } // namespace RMM_NAMESPACE
detail::cccl_async_resource_ref< cuda::mr::async_resource_ref< cuda::mr::host_accessible > > host_async_resource_ref
Alias for a cuda::mr::async_resource_ref with the property cuda::mr::host_accessible.
Definition: resource_ref.hpp:103
detail::cccl_resource_ref< cuda::mr::resource_ref< cuda::mr::device_accessible > > device_resource_ref
Alias for a cuda::mr::resource_ref with the property cuda::mr::device_accessible.
Definition: resource_ref.hpp:82
detail::cccl_async_resource_ref< cuda::mr::async_resource_ref< cuda::mr::host_accessible, cuda::mr::device_accessible > > host_device_async_resource_ref
Alias for a cuda::mr::async_resource_ref with the properties cuda::mr::host_accessible and cuda::mr::...
Definition: resource_ref.hpp:117
detail::cccl_async_resource_ref< cuda::mr::async_resource_ref< cuda::mr::device_accessible > > device_async_resource_ref
Alias for a cuda::mr::async_resource_ref with the property cuda::mr::device_accessible.
Definition: resource_ref.hpp:89
detail::cccl_resource_ref< cuda::mr::resource_ref< cuda::mr::host_accessible, cuda::mr::device_accessible > > host_device_resource_ref
Alias for a cuda::mr::resource_ref with the properties cuda::mr::host_accessible and cuda::mr::device...
Definition: resource_ref.hpp:110
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:131
detail::cccl_resource_ref< cuda::mr::resource_ref< cuda::mr::host_accessible > > host_resource_ref
Alias for a cuda::mr::resource_ref with the property cuda::mr::host_accessible.
Definition: resource_ref.hpp:96