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/cuda_memory_resource.hpp>
19 #include <rmm/detail/error.hpp>
20 #include <rmm/detail/export.hpp>
21 
22 namespace RMM_NAMESPACE {
23 
34 using device_resource_ref = cuda::mr::resource_ref<cuda::mr::device_accessible>;
35 
40 using device_async_resource_ref = cuda::mr::async_resource_ref<cuda::mr::device_accessible>;
41 
46 using host_resource_ref = cuda::mr::resource_ref<cuda::mr::host_accessible>;
47 
52 using host_async_resource_ref = cuda::mr::async_resource_ref<cuda::mr::host_accessible>;
53 
59  cuda::mr::resource_ref<cuda::mr::host_accessible, cuda::mr::device_accessible>;
60 
66  cuda::mr::async_resource_ref<cuda::mr::host_accessible, cuda::mr::device_accessible>;
67 
77 template <class Resource>
79 {
80  RMM_EXPECTS(res, "Unexpected null resource pointer.");
81  return device_async_resource_ref{*res};
82 }
83  // end of group
85 } // namespace RMM_NAMESPACE
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:46
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:40
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:52
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:66
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:59
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:34
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:78