| 公共类型 | 公共成员函数 | 所有成员列表
rmm::mr::stream_allocator_adaptor< Allocator > 类模板参考

适配流有序分配器以提供标准的 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_typeallocate (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
 底层分配器。 更多...
 

详细描述

template<typename Allocator>
class rmm::mr::stream_allocator_adaptor< Allocator >

适配流有序分配器以提供标准的 Allocator 接口。

流有序分配器(即 allocate/deallocate 使用 cuda_stream_view)无法在需要标准 C++ Allocator 接口的接口中使用。stream_allocator_adaptor 封装了一个流有序分配器和一个流,以提供标准的 Allocator 接口。此适配器在调用底层分配器的 allocatedeallocate 函数时使用封装的流。

示例

my_stream_ordered_allocator<int> a{...};
cuda_stream_view s = // create stream;
auto adapted = stream_allocator_adaptor(a, s);
// 在流 `s` 上为 `n` 个 int 分配存储空间
int * p = std::allocator_traits<decltype(adapted)>::allocate(adapted, n);
value_type * allocate(std::size_t num)
使用底层分配器在 stream() 上为 num 个类型 T 的对象分配存储空间。
定义: polymorphic_allocator.hpp:233
模板参数
Allocator要适配的流有序分配器类型

成员类型定义文档

◆ value_type

template<typename Allocator >
using rmm::mr::stream_allocator_adaptor< Allocator >::value_type = typename std::allocator_traits<Allocator>::value_type

此分配器分配的对象的类型

构造函数与析构函数文档

◆ stream_allocator_adaptor() [1/2]

template<typename Allocator >
rmm::mr::stream_allocator_adaptor< Allocator >::stream_allocator_adaptor ( Allocator const &  allocator,
cuda_stream_view  stream 
)
inline

使用 a 作为底层分配器构造一个 stream_allocator_adaptor

注意
:在 stream_allocator_adaptor 销毁之前,stream 不得销毁,否则行为未定义。
参数
allocator用作底层分配器的流有序分配器
stream与底层分配器一起使用的流

◆ stream_allocator_adaptor() [2/2]

template<typename Allocator >
template<typename OtherAllocator >
rmm::mr::stream_allocator_adaptor< Allocator >::stream_allocator_adaptor ( stream_allocator_adaptor< OtherAllocator > const &  other)
inline

使用 other.underlying_allocator()other.stream() 作为底层分配器和流构造一个 stream_allocator_adaptor

模板参数
OtherAllocatorother 的底层分配器类型
参数
other要复制其底层分配器和流的另一个 stream_allocator_adaptor

成员函数文档

◆ allocate()

template<typename Allocator >
value_type* rmm::mr::stream_allocator_adaptor< Allocator >::allocate ( std::size_t  num)
inline

使用底层分配器在 stream() 上为 num 个类型为 T 的对象分配存储空间。

参数
num要为其分配存储空间的对象的数量
返回值
指向已分配存储空间的指针

◆ deallocate()

template<typename Allocator >
void rmm::mr::stream_allocator_adaptor< Allocator >::deallocate ( value_type ptr,
std::size_t  num 
)
inline

使用底层分配器在 stream() 上释放由 ptr 指向的存储空间。

ptr 必须是由与 underlying_allocator() 相等的分配器 a 通过调用 a.allocate(n) 分配的。

参数
ptr要释放的内存指针
num原始分配的对象数量

◆ stream()

template<typename Allocator >
cuda_stream_view rmm::mr::stream_allocator_adaptor< Allocator >::stream ( ) const
inlinenoexcept

底层分配器进行调用时使用的流。

返回值
底层分配器进行调用时使用的流

◆ underlying_allocator()

template<typename Allocator >
Allocator rmm::mr::stream_allocator_adaptor< Allocator >::underlying_allocator ( ) const
inlinenoexcept

底层分配器。

返回值
底层分配器

此类的文档生成自以下文件