Public Types | Public Member Functions | Friends | List of all members
rmm::mr::statistics_resource_adaptor Class Reference

Resource that uses an upstream resource to allocate memory and tracks allocation statistics (current, peak, total bytes and allocation counts). More...

#include <statistics_resource_adaptor.hpp>

Inheritance diagram for rmm::mr::statistics_resource_adaptor:
Inheritance graph
[legend]
Collaboration diagram for rmm::mr::statistics_resource_adaptor:
Collaboration graph
[legend]

Public Types

using counter = detail::statistics_resource_adaptor_impl::counter
 Counter type tracking current, peak, and total bytes or allocations.
 
using read_lock_t = detail::statistics_resource_adaptor_impl::read_lock_t
 Shared-reader lock type used to protect the counter stack.
 
using write_lock_t = detail::statistics_resource_adaptor_impl::write_lock_t
 Exclusive-writer lock type used to protect the counter stack.
 

Public Member Functions

 statistics_resource_adaptor (cuda::mr::any_resource< cuda::mr::device_accessible > upstream)
 Construct a statistics resource adaptor using upstream to satisfy allocation requests. More...
 
device_async_resource_ref get_upstream_resource () const noexcept
 rmm::device_async_resource_ref to the upstream resource More...
 
counter get_bytes_counter () const noexcept
 Returns a counter struct for bytes allocated since construction (or last push). More...
 
counter get_allocations_counter () const noexcept
 Returns a counter struct for number of allocations since construction (or last push). More...
 
std::pair< counter, counterpush_counters ()
 Push a pair of zero counters — new counters start fresh. More...
 
std::pair< counter, counterpop_counters ()
 Pop a pair of counters from the stack. More...
 

Friends

void get_property (statistics_resource_adaptor const &, cuda::mr::device_accessible) noexcept
 Enables the cuda::mr::device_accessible property.
 

Detailed Description

Resource that uses an upstream resource to allocate memory and tracks allocation statistics (current, peak, total bytes and allocation counts).

Supports nested statistics via push_counters()/pop_counters(). Intended as a debug adaptor.

This class is copyable and shares ownership of its internal state via cuda::mr::shared_resource.

Constructor & Destructor Documentation

◆ statistics_resource_adaptor()

rmm::mr::statistics_resource_adaptor::statistics_resource_adaptor ( cuda::mr::any_resource< cuda::mr::device_accessible >  upstream)
explicit

Construct a statistics resource adaptor using upstream to satisfy allocation requests.

Parameters
upstreamThe resource used for allocating/deallocating device memory.

Member Function Documentation

◆ get_allocations_counter()

counter rmm::mr::statistics_resource_adaptor::get_allocations_counter ( ) const
noexcept

Returns a counter struct for number of allocations since construction (or last push).

Returns
counter containing current, peak, and total allocation counts

◆ get_bytes_counter()

counter rmm::mr::statistics_resource_adaptor::get_bytes_counter ( ) const
noexcept

Returns a counter struct for bytes allocated since construction (or last push).

Returns
counter containing current, peak, and total byte counts

◆ get_upstream_resource()

device_async_resource_ref rmm::mr::statistics_resource_adaptor::get_upstream_resource ( ) const
noexcept

rmm::device_async_resource_ref to the upstream resource

Returns
rmm::device_async_resource_ref to the upstream resource

◆ pop_counters()

std::pair<counter, counter> rmm::mr::statistics_resource_adaptor::pop_counters ( )

Pop a pair of counters from the stack.

Returns
pair of counters (bytes, allocations) from the top before the pop
Exceptions
std::out_of_rangeif the counter stack has fewer than two entries

◆ push_counters()

std::pair<counter, counter> rmm::mr::statistics_resource_adaptor::push_counters ( )

Push a pair of zero counters — new counters start fresh.

Returns
pair of counters (bytes, allocations) from the top before the push

The documentation for this class was generated from the following file: