resource_types.hpp
1 
6 #pragma once
7 
8 #include <cuda/memory_resource>
9 
10 namespace rapidsmpf {
11 
13 using any_device_resource = cuda::mr::any_resource<cuda::mr::device_accessible>;
14 
17  cuda::mr::any_resource<cuda::mr::host_accessible, cuda::mr::device_accessible>;
18 
20 using any_host_resource = cuda::mr::any_resource<cuda::mr::host_accessible>;
21 
32 template <typename... Properties>
33 [[nodiscard]] bool is_host_accessible(
34  cuda::mr::resource_ref<Properties...> const& mr
35 ) noexcept {
36  auto const accessibility =
37  get_property(mr, cuda::mr::dynamic_accessibility_property{});
38  return accessibility == cuda::mr::__memory_accessibility::__host
39  || accessibility == cuda::mr::__memory_accessibility::__host_device;
40 }
41 
52 template <typename... Properties>
53 [[nodiscard]] bool is_device_accessible(
54  cuda::mr::resource_ref<Properties...> const& mr
55 ) noexcept {
56  // See `is_host_accessible` for why the call is unqualified (ADL).
57  auto const accessibility =
58  get_property(mr, cuda::mr::dynamic_accessibility_property{});
59  return accessibility == cuda::mr::__memory_accessibility::__device
60  || accessibility == cuda::mr::__memory_accessibility::__host_device;
61 }
62 
63 } // namespace rapidsmpf
RAPIDS Multi-Processor interfaces.
Definition: backend.hpp:14
cuda::mr::any_resource< cuda::mr::host_accessible > any_host_resource
Owning type-erased host memory resource.
bool is_device_accessible(cuda::mr::resource_ref< Properties... > const &mr) noexcept
Check whether a type-erased memory resource is device-accessible.
bool is_host_accessible(cuda::mr::resource_ref< Properties... > const &mr) noexcept
Check whether a type-erased memory resource is host-accessible.
cuda::mr::any_resource< cuda::mr::host_accessible, cuda::mr::device_accessible > any_host_device_resource
Owning type-erased host- and device-accessible memory resource.
cuda::mr::any_resource< cuda::mr::device_accessible > any_device_resource
Owning type-erased device memory resource.