一个流序分配器 (stream ordered Allocator),使用一个 rmm::mr::device_memory_resource
来满足分配 (allocations) 和释放 (deallocations)。更多...
#include <polymorphic_allocator.hpp>
公共类型 | |
using | value_type = T |
T,此分配器分配的对象的值类型。 | |
公共成员函数 | |
polymorphic_allocator ()=default | |
构造一个 polymorphic_allocator ,使用 rmm::mr::get_current_device_resource_ref() 的返回值作为底层内存资源。 | |
polymorphic_allocator (device_async_resource_ref mr) | |
使用提供的内存资源构造一个 polymorphic_allocator 。更多... | |
template<typename U > | |
polymorphic_allocator (polymorphic_allocator< U > const &other) noexcept | |
使用 other 的底层内存资源构造一个 polymorphic_allocator 。更多... | |
value_type * | allocate (std::size_t num, cuda_stream_view stream) |
使用底层内存资源为 num 个类型为 T 的对象分配存储空间。更多... | |
void | deallocate (value_type *ptr, std::size_t num, cuda_stream_view stream) |
释放由 ptr 指向的存储空间。更多... | |
rmm::device_async_resource_ref | get_upstream_resource () const noexcept |
指向所用上游资源的 rmm::device_async_resource_ref。更多... | |
一个流序分配器 (stream ordered Allocator),使用一个 rmm::mr::device_memory_resource
来满足分配 (allocations) 和释放 (deallocations)。
类似于 std::pmr::polymorphic_allocator
,它利用 device_memory_resource
的运行时多态性 (runtime polymorphism),使得使用 polymorphic_allocator
作为其静态分配器类型 (static allocator type) 的容器能够互操作 (interoperable),但根据所使用的资源表现出不同的行为。
与 STL 分配器不同,polymorphic_allocator
的 allocate
和 deallocate
函数是流序的 (stream ordered)。使用 stream_allocator_adaptor
来实现与需要标准、非流序 (non stream-ordered) Allocator
接口的接口的互操作性。
T | 分配器的值类型。 |
|
inline |
使用提供的内存资源构造一个 polymorphic_allocator
。
此构造函数提供了从 device_async_resource_ref
的隐式转换 (implicit conversion)。
mr | 用于分配的上游内存资源 (upstream memory resource)。 |
|
inlinenoexcept |
使用 other
的底层内存资源 (underlying memory resource) 构造一个 polymorphic_allocator
。
other | 将其内存资源用作新的 polymorphic_allocator 的底层资源 (underlying resource) 的 polymorphic_allocator 。 |
|
inline |
使用底层内存资源为 num
个类型为 T
的对象分配存储空间。
num | 要为其分配存储空间的对象数量 |
stream | 执行分配操作的流 (stream) |
|
inline |
释放由 ptr
指向的存储空间。
ptr
必须是从一个内存资源 r
分配而来,且该资源与使用 r.allocate(n * sizeof(T))
的 get_upstream_resource()
比较相等 (compares equal to)。
ptr | 指向要释放内存的指针 |
num | 最初分配的对象数量 |
stream | 执行释放操作的流 (Stream) |
|
inlinenoexcept |
指向所用上游资源的 rmm::device_async_resource_ref