| 公有类型 | 公有成员函数 | 所有成员列表
rmm::mr::statistics_resource_adaptor< Upstream > 类模板参考final

使用 Upstream 分配内存并跟踪内存分配统计信息的资源。 更多...

#include <statistics_resource_adaptor.hpp>

rmm::mr::statistics_resource_adaptor< Upstream > 的继承图
Inheritance graph
[图例]
rmm::mr::statistics_resource_adaptor< Upstream > 的协作图
Collaboration graph
[图例]

struct  counter
 用于计数当前值、峰值和总值的实用结构体。 更多...
 

公有类型

using read_lock_t = std::shared_lock< std::shared_mutex >
 用于同步读访问的锁类型。
 
using write_lock_t = std::unique_lock< std::shared_mutex >
 用于同步写访问的锁类型。
 

公有成员函数

 statistics_resource_adaptor (device_async_resource_ref upstream)
 构造一个新的统计信息资源适配器,使用 upstream 满足分配请求。 更多...
 
 statistics_resource_adaptor (Upstream *upstream)
 构造一个新的统计信息资源适配器,使用 upstream 满足分配请求。 更多...
 
 statistics_resource_adaptor (statistics_resource_adaptor const &)=delete
 
statistics_resource_adaptoroperator= (statistics_resource_adaptor const &)=delete
 
 statistics_resource_adaptor (statistics_resource_adaptor &&) noexcept=default
 默认移动构造函数。
 
statistics_resource_adaptoroperator= (statistics_resource_adaptor &&) noexcept=default
 默认移动赋值运算符。 更多...
 
rmm::device_async_resource_ref get_upstream_resource () const noexcept
 指向 upstream 资源的 rmm::device_async_resource_ref。 更多...
 
counter get_bytes_counter () const noexcept
 返回此适配器的 counter 结构体,包含自创建以来为此适配器分配的字节数的当前值、峰值和总值。 更多...
 
counter get_allocations_counter () const noexcept
 返回此适配器的 counter 结构体,包含自创建以来为此适配器分配的次数的当前值、峰值和总值。 更多...
 
std::pair< counter, counterpush_counters ()
 将一对零计数器压入栈中,它们将成为由 get_bytes_counter()get_allocations_counter() 返回的新计数器。 更多...
 
std::pair< counter, counterpop_counters ()
 从栈中弹出一对计数器。 更多...
 
- 从 rmm::mr::device_memory_resource 继承的公有成员函数
 device_memory_resource (device_memory_resource const &)=default
 默认复制构造函数。
 
 device_memory_resource (device_memory_resource &&) noexcept=default
 默认移动构造函数。
 
device_memory_resourceoperator= (device_memory_resource const &)=default
 默认复制赋值运算符。 更多...
 
device_memory_resourceoperator= (device_memory_resource &&) noexcept=default
 默认移动赋值运算符。 更多...
 
void * allocate (std::size_t bytes, cuda_stream_view stream=cuda_stream_view{})
 分配至少 `bytes` 大小的内存。 更多...
 
void deallocate (void *ptr, std::size_t bytes, cuda_stream_view stream=cuda_stream_view{})
 释放由 `p` 指向的内存。 更多...
 
bool is_equal (device_memory_resource const &other) const noexcept
 将此资源与另一个资源进行比较。 更多...
 
void * allocate (std::size_t bytes, std::size_t alignment)
 分配至少 `bytes` 大小的内存。 更多...
 
void deallocate (void *ptr, std::size_t bytes, std::size_t alignment)
 释放由 `p` 指向的内存。 更多...
 
void * allocate_async (std::size_t bytes, std::size_t alignment, cuda_stream_view stream)
 分配至少 `bytes` 大小的内存。 更多...
 
void * allocate_async (std::size_t bytes, cuda_stream_view stream)
 分配至少 `bytes` 大小的内存。 更多...
 
void deallocate_async (void *ptr, std::size_t bytes, std::size_t alignment, cuda_stream_view stream)
 释放由 `p` 指向的内存。 更多...
 
void deallocate_async (void *ptr, std::size_t bytes, cuda_stream_view stream)
 释放由 `p` 指向的内存。 更多...
 
bool operator== (device_memory_resource const &other) const noexcept
 与另一个 device_memory_resource 的比较运算符。 更多...
 
bool operator!= (device_memory_resource const &other) const noexcept
 与另一个 device_memory_resource 的比较运算符。 更多...
 

详细描述

template<typename Upstream>
class rmm::mr::statistics_resource_adaptor< Upstream >

使用 Upstream 分配内存并跟踪内存分配统计信息的资源。

可以构造此资源的一个实例,并使用现有的 upstream 资源来满足分配请求,但任何现有分配将不被跟踪。统计信息跟踪会存储内存分配的当前值、峰值和总值,包括字节数和对内存资源的调用次数。

此资源支持嵌套统计信息,这使得跟踪代码块的统计信息成为可能。使用 `.`push_counters()` 开始跟踪代码块的统计信息,并使用 `.`pop_counters()` 停止跟踪。嵌套统计信息是层叠的,因此由某个代码块跟踪的统计信息包括其所有跟踪的子代码块中跟踪的统计信息。

`statistics_resource_adaptor` 旨在作为调试适配器使用,不应在对性能敏感的代码中使用。

模板参数
Upstream用于分配/释放内存的 upstream 资源的类型。

构造函数与析构函数文档

◆ statistics_resource_adaptor() [1/2]

template<typename Upstream >
rmm::mr::statistics_resource_adaptor< Upstream >::statistics_resource_adaptor ( device_async_resource_ref  upstream)
inline

构造一个新的统计信息资源适配器,使用 upstream 满足分配请求。

参数
upstream用于分配/释放设备内存的 resource_ref。

◆ statistics_resource_adaptor() [2/2]

template<typename Upstream >
rmm::mr::statistics_resource_adaptor< Upstream >::statistics_resource_adaptor ( Upstream *  upstream)
inline

构造一个新的统计信息资源适配器,使用 upstream 满足分配请求。

异常
rmm::logic_error如果 upstream == nullptr
参数
upstream用于分配/释放设备内存的资源。

成员函数文档

◆ get_allocations_counter()

template<typename Upstream >
counter rmm::mr::statistics_resource_adaptor< Upstream >::get_allocations_counter ( ) const
inlinenoexcept

返回此适配器的 counter 结构体,包含自创建以来为此适配器分配的次数的当前值、峰值和总值。

返回值
包含分配次数的 counter 结构体

◆ get_bytes_counter()

template<typename Upstream >
counter rmm::mr::statistics_resource_adaptor< Upstream >::get_bytes_counter ( ) const
inlinenoexcept

返回此适配器的 counter 结构体,包含自创建以来为此适配器分配的字节数的当前值、峰值和总值。

返回值
包含字节数的 counter 结构体

◆ get_upstream_resource()

template<typename Upstream >
rmm::device_async_resource_ref rmm::mr::statistics_resource_adaptor< Upstream >::get_upstream_resource ( ) const
inlinenoexcept

指向 upstream 资源的 rmm::device_async_resource_ref

返回值
指向 upstream 资源的 rmm::device_async_resource_ref

◆ operator=()

template<typename Upstream >
statistics_resource_adaptor& rmm::mr::statistics_resource_adaptor< Upstream >::operator= ( statistics_resource_adaptor< Upstream > &&  )
defaultnoexcept

默认移动赋值运算符。

返回值
statistics_resource_adaptor& 引用赋值后的对象

◆ pop_counters()

template<typename Upstream >
std::pair<counter, counter> rmm::mr::statistics_resource__adaptor< Upstream >::pop_counters ( )
inline

从栈中弹出一对计数器。

返回值
弹出栈顶的一对计数器 <bytes, allocations>
异常
std::out_of_range如果计数器栈中的条目少于两个。

◆ push_counters()

template<typename Upstream >
std::pair<counter, counter> rmm::mr::statistics_resource__adaptor< Upstream >::push_counters ( )
inline

将一对零计数器压入栈中,它们将成为由 get_bytes_counter()get_allocations_counter() 返回的新计数器。

返回值
压入栈顶的一对计数器 <bytes, allocations>

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