9#include <rmm/detail/export.hpp>
10#include <rmm/detail/runtime_shutdown.hpp>
14#include <cuda/memory_resource>
78 static std::map<cuda_device_id::value_type, cuda::mr::any_resource<cuda::mr::device_accessible>>
79 device_id_to_resource;
81 rmm::detail::register_process_exit_hook();
82 return device_id_to_resource;
115 auto const found = map.find(device_id.
value());
116 if (found == map.end()) {
152 cuda_device_id device_id, cuda::mr::any_resource<cuda::mr::device_accessible> new_resource)
156 auto const old_itr = map.find(device_id.
value());
157 if (old_itr == map.end()) {
158 map.emplace(device_id.
value(), std::move(new_resource));
161 return std::exchange(old_itr->second, std::move(new_resource));
216 cuda::mr::any_resource<cuda::mr::device_accessible> new_resource)
Memory resource that uses cudaMalloc/Free for allocation/deallocation.
Definition cuda_memory_resource.hpp:25
cuda_device_id get_current_cuda_device()
Returns a cuda_device_id for the current device.
cuda::mr::any_resource< cuda::mr::device_accessible > set_per_device_resource(cuda_device_id device_id, cuda::mr::any_resource< cuda::mr::device_accessible > new_resource)
Set the memory resource for the specified device.
Definition per_device_resource.hpp:151
cuda::mr::any_resource< cuda::mr::device_accessible > set_current_device_resource(cuda::mr::any_resource< cuda::mr::device_accessible > new_resource)
Set the memory resource for the current device.
Definition per_device_resource.hpp:215
cuda::mr::any_resource< cuda::mr::device_accessible > reset_per_device_resource(cuda_device_id device_id)
Reset the memory resource for the specified device to the initial resource.
Definition per_device_resource.hpp:238
device_async_resource_ref get_current_device_resource_ref()
Get the device_async_resource_ref for the current device.
Definition per_device_resource.hpp:187
device_async_resource_ref get_per_device_resource_ref(cuda_device_id device_id)
Get the device_async_resource_ref for the specified device.
Definition per_device_resource.hpp:110
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::any_resource< cuda::mr::device_accessible > reset_current_device_resource()
Reset the memory resource for the current device to the initial resource.
Definition per_device_resource.hpp:258
Memory Resource classes and adaptors.
auto & get_ref_map()
Reference to the map from device id -> any_resource.
Definition per_device_resource.hpp:76
std::mutex & ref_map_lock()
Reference to the lock.
Definition per_device_resource.hpp:66
cuda_memory_resource & initial_resource()
Returns a reference to the initial resource.
Definition per_device_resource.hpp:57
Strong type for a CUDA device identifier.
Definition cuda_device.hpp:27
constexpr value_type value() const noexcept
The wrapped integer value.
Definition cuda_device.hpp:43