19 #include <rmm/detail/error.hpp>
20 #include <rmm/detail/export.hpp>
27 namespace RMM_NAMESPACE {
43 template <
typename Upstream>
46 using lock_t = std::lock_guard<std::mutex>;
103 return get_upstream_resource().allocate_async(bytes, stream);
113 void do_deallocate(
void* ptr, std::size_t bytes,
cuda_stream_view stream)
override
116 get_upstream_resource().deallocate_async(ptr, bytes, stream);
126 bool do_is_equal(device_memory_resource
const& other)
const noexcept
override
128 if (
this == &other) {
return true; }
129 auto cast =
dynamic_cast<thread_safe_resource_adaptor<Upstream> const*
>(&other);
130 if (cast ==
nullptr) {
return false; }
131 return get_upstream_resource() == cast->get_upstream_resource();
134 std::mutex
mutable mtx;
Strongly-typed non-owning wrapper for CUDA streams with default constructor.
Definition: cuda_stream_view.hpp:39
Base class for all librmm device memory allocation.
Definition: device_memory_resource.hpp:93
Resource that adapts Upstream memory resource adaptor to be thread safe.
Definition: thread_safe_resource_adaptor.hpp:44
std::lock_guard< std::mutex > lock_t
Type of lock used to synchronize access.
Definition: thread_safe_resource_adaptor.hpp:46
thread_safe_resource_adaptor(device_async_resource_ref upstream)
Construct a new thread safe resource adaptor using upstream to satisfy allocation requests.
Definition: thread_safe_resource_adaptor.hpp:56
rmm::device_async_resource_ref get_upstream_resource() const noexcept
rmm::device_async_resource_ref to the upstream resource
Definition: thread_safe_resource_adaptor.hpp:83
thread_safe_resource_adaptor(Upstream *upstream)
Construct a new thread safe resource adaptor using upstream to satisfy allocation requests.
Definition: thread_safe_resource_adaptor.hpp:68
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:41
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:79