19 #include <rmm/detail/error.hpp>
20 #include <rmm/detail/export.hpp>
27 namespace RMM_NAMESPACE {
44 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;
rmm::cuda_stream_view
CUDA 流的强类型非拥有包装器,带有默认构造函数。
rmm::mr::device_memory_resource
所有 librmm 设备内存分配的基类。
定义: device_memory_resource.hpp:92
rmm::mr::thread_safe_resource_adaptor
rmm::cuda_stream_view
适配上游内存资源适配器以实现线程安全的资源。
用于同步访问的锁类型。
定义: thread_safe_resource_adaptor.hpp:46
rmm::mr::thread_safe_resource_adaptor::thread_safe_resource_adaptor
使用 `upstream` 构造一个新的线程安全资源适配器来满足分配请求。
定义: thread_safe_resource_adaptor.hpp:56
rmm::mr::thread_safe_resource_adaptor::get_upstream_resource