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

Resource that uses an upstream resource to allocate memory and tracks allocations. More...

#include <tracking_resource_adaptor.hpp>

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

Public Types

using allocation_info = detail::tracking_resource_adaptor_impl::allocation_info
 Allocation info type (pointer, size, optional stack trace).
 
using read_lock_t = detail::tracking_resource_adaptor_impl::read_lock_t
 Shared-reader lock type used to protect the allocations map.
 
using write_lock_t = detail::tracking_resource_adaptor_impl::write_lock_t
 Exclusive-writer lock type used to protect the allocations map.
 

Public Member Functions

 tracking_resource_adaptor (cuda::mr::any_resource< cuda::mr::device_accessible > upstream, bool capture_stacks=false)
 Construct a tracking 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...
 
std::map< void *, allocation_info > const & get_outstanding_allocations () const noexcept
 Get the outstanding allocations map. More...
 
std::size_t get_allocated_bytes () const noexcept
 Query the number of bytes currently allocated. More...
 
std::string get_outstanding_allocations_str () const
 Gets a string describing all outstanding allocations (pointer, size, optional stack). More...
 
void log_outstanding_allocations () const
 Log any outstanding allocations via RMM_LOG_DEBUG.
 

Friends

void get_property (tracking_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 allocations.

Tracks every allocation (size, pointer, and optionally stack trace). Intended as a debug adaptor; should not be used in performance-sensitive code.

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

Constructor & Destructor Documentation

◆ tracking_resource_adaptor()

rmm::mr::tracking_resource_adaptor::tracking_resource_adaptor ( cuda::mr::any_resource< cuda::mr::device_accessible >  upstream,
bool  capture_stacks = false 
)

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

Parameters
upstreamThe resource used for allocating/deallocating device memory.
capture_stacksIf true, capture stacks for each allocation.

Member Function Documentation

◆ get_allocated_bytes()

std::size_t rmm::mr::tracking_resource_adaptor::get_allocated_bytes ( ) const
noexcept

Query the number of bytes currently allocated.

Returns
std::size_t number of bytes currently allocated

◆ get_outstanding_allocations()

std::map<void*, allocation_info> const& rmm::mr::tracking_resource_adaptor::get_outstanding_allocations ( ) const
noexcept

Get the outstanding allocations map.

Returns
map of outstanding allocations (pointer → allocation_info)

◆ get_outstanding_allocations_str()

std::string rmm::mr::tracking_resource_adaptor::get_outstanding_allocations_str ( ) const

Gets a string describing all outstanding allocations (pointer, size, optional stack).

Returns
std::string describing outstanding allocations

◆ get_upstream_resource()

device_async_resource_ref rmm::mr::tracking_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

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