适配流有序分配器以提供标准的 Allocator
接口。 更多...
#include <polymorphic_allocator.hpp>
类 | |
结构体 | rebind |
将分配器重绑定到指定的类型。 更多... | |
公共类型 | |
使用 | value_type = typename std::allocator_traits< Allocator >::value_type |
公共成员函数 | |
stream_allocator_adaptor (Allocator const &allocator, cuda_stream_view stream) | |
使用 a 作为底层分配器构造一个 stream_allocator_adaptor 。 更多... | |
template<typename OtherAllocator > | |
stream_allocator_adaptor (stream_allocator_adaptor< OtherAllocator > const &other) | |
使用 other.underlying_allocator() 和 other.stream() 作为底层分配器和流构造一个 stream_allocator_adaptor 。 更多... | |
value_type * | allocate (std::size_t num) |
使用底层分配器在 stream() 上为 num 个类型为 T 的对象分配存储空间。 更多... | |
void | deallocate (value_type *ptr, std::size_t num) |
使用底层分配器在 stream() 上释放由 ptr 指向的存储空间。 更多... | |
cuda_stream_view | stream () const noexcept |
底层分配器进行调用时使用的流。 更多... | |
Allocator | underlying_allocator () const noexcept |
底层分配器。 更多... | |
适配流有序分配器以提供标准的 Allocator
接口。
流有序分配器(即 allocate/deallocate
使用 cuda_stream_view
)无法在需要标准 C++ Allocator
接口的接口中使用。stream_allocator_adaptor
封装了一个流有序分配器和一个流,以提供标准的 Allocator
接口。此适配器在调用底层分配器的 allocate
和 deallocate
函数时使用封装的流。
示例
Allocator | 要适配的流有序分配器类型 |
using rmm::mr::stream_allocator_adaptor< Allocator >::value_type = typename std::allocator_traits<Allocator>::value_type |
此分配器分配的对象的类型
|
inline |
使用 a
作为底层分配器构造一个 stream_allocator_adaptor
。
stream_allocator_adaptor
销毁之前,stream
不得销毁,否则行为未定义。allocator | 用作底层分配器的流有序分配器 |
stream | 与底层分配器一起使用的流 |
|
inline |
使用 other.underlying_allocator()
和 other.stream()
作为底层分配器和流构造一个 stream_allocator_adaptor
。
OtherAllocator | other 的底层分配器类型 |
other | 要复制其底层分配器和流的另一个 stream_allocator_adaptor |
|
inline |
|
inline |
使用底层分配器在 stream()
上释放由 ptr
指向的存储空间。
ptr
必须是由与 underlying_allocator()
相等的分配器 a
通过调用 a.allocate(n)
分配的。
ptr | 要释放的内存指针 |
num | 原始分配的对象数量 |
|
inlinenoexcept |
底层分配器进行调用时使用的流。
|
inlinenoexcept |
底层分配器。