Memory statistics for a specific scope. More...
#include <rmm_resource_adaptor.hpp>
Public Types | |
| enum class | AllocType : std::size_t { PRIMARY = 0 , FALLBACK = 1 , ALL = 2 } |
| Allocation source types. More... | |
| using | AllocTypeArray = std::array< std::int64_t, 2 > |
| Array type for storing per-allocator statistics. | |
Public Member Functions | |
| std::int64_t | num_total_allocs (AllocType alloc_type=AllocType::ALL) const noexcept |
| Returns the total number of allocations performed by the specified allocator type. More... | |
| std::int64_t | num_current_allocs (AllocType alloc_type=AllocType::ALL) const noexcept |
| Returns the number of currently active (non-deallocated) allocations for the specified allocator type. More... | |
| std::int64_t | current (AllocType alloc_type=AllocType::ALL) const noexcept |
| Returns the current memory usage in bytes for the specified allocator type. More... | |
| std::int64_t | total (AllocType alloc_type=AllocType::ALL) const noexcept |
| Returns the total number of bytes allocated. More... | |
| std::int64_t | peak (AllocType alloc_type=AllocType::ALL) const noexcept |
| Returns the peak memory usage (in bytes) for the specified allocator type. More... | |
| void | record_allocation (AllocType alloc_type, std::int64_t nbytes) |
| Records a memory allocation event. More... | |
| void | record_deallocation (AllocType alloc_type, std::int64_t nbytes) |
| Records a memory deallocation event. More... | |
| ScopedMemoryRecord & | add_subscope (ScopedMemoryRecord const &subscope) |
| Merge the memory statistics of a subscope into this record. More... | |
| ScopedMemoryRecord & | add_scope (ScopedMemoryRecord const &scope) |
| Merge the memory statistics of another scope into this one. More... | |
Memory statistics for a specific scope.
Definition at line 29 of file rmm_resource_adaptor.hpp.
|
strong |
Allocation source types.
| Enumerator | |
|---|---|
| PRIMARY | The primary allocator (first-choice allocator). |
| FALLBACK | The fallback allocator (used when the primary fails). |
| ALL | Aggregated statistics from both primary and fallback allocators. |
Definition at line 31 of file rmm_resource_adaptor.hpp.
| ScopedMemoryRecord& rapidsmpf::ScopedMemoryRecord::add_scope | ( | ScopedMemoryRecord const & | scope | ) |
Merge the memory statistics of another scope into this one.
Unlike add_subscope(), this method treats the given scope as a peer or sibling, rather than a nested child. It aggregates totals and allocation counts and updates peak usage by taking the maximum peaks independently.
This is useful for combining memory statistics across multiple independent scopes, such as from different threads or non-nested regions.
| scope | The scope to combine with this one. |
| ScopedMemoryRecord& rapidsmpf::ScopedMemoryRecord::add_subscope | ( | ScopedMemoryRecord const & | subscope | ) |
Merge the memory statistics of a subscope into this record.
Combines the memory tracking data from a nested scope (subscope) into this record, updating statistics to include the subscope's allocations, peaks, and totals.
This method treats the given record as a child scope nested within this scope, so peak usage is updated considering the current usage plus the subscope's peak, reflecting hierarchical (inclusive) memory usage accounting.
This design allows memory scopes to be organized hierarchically, so when querying a parent scope, its statistics are inclusive of all nested scopes — similar to hierarchical memory profiling tools. However, it assumes that the parent scope's statistics remain constant during the execution of the subscope.
| subscope | The scoped memory record representing a completed nested region. |
|
noexcept |
Returns the current memory usage in bytes for the specified allocator type.
Current usage is the total bytes currently allocated but not yet deallocated.
| alloc_type | The allocator type to query. Use AllocType::ALL to return the sum across all types. |
|
noexcept |
Returns the number of currently active (non-deallocated) allocations for the specified allocator type.
This reflects the number of allocations that have not yet been deallocated.
| alloc_type | The allocator type to query. Use AllocType::ALL to return the sum across all types. |
|
noexcept |
Returns the total number of allocations performed by the specified allocator type.
| alloc_type | The allocator type to query. Use AllocType::ALL to return the sum across all types. |
|
noexcept |
Returns the peak memory usage (in bytes) for the specified allocator type.
The peak represents the highest value reached by current memory usage over the lifetime of the allocator. It does not decrease after deallocations.
When queried with AllocType::ALL, this returns the highest combined memory usage ever observed across both primary and fallback allocators, not the sum of individual peaks.
| alloc_type | The allocator type to query. Defaults to AllocType::ALL. |
| void rapidsmpf::ScopedMemoryRecord::record_allocation | ( | AllocType | alloc_type, |
| std::int64_t | nbytes | ||
| ) |
Records a memory allocation event.
Updates the allocation counters and memory usage statistics, and adjusts peak usage if the new current usage exceeds the previous peak.
| alloc_type | The allocator that performed the allocation. |
| nbytes | The number of bytes allocated. |
| void rapidsmpf::ScopedMemoryRecord::record_deallocation | ( | AllocType | alloc_type, |
| std::int64_t | nbytes | ||
| ) |
Records a memory deallocation event.
Reduces the current memory usage for the specified allocator.
| alloc_type | The allocator that performed the deallocation. |
| nbytes | The number of bytes deallocated. |
|
noexcept |
Returns the total number of bytes allocated.
This value accumulates over time and is not reduced by deallocations.
| alloc_type | The allocator type to query. Use AllocType::ALL to return the sum across all types. |