A RMM memory resource adaptor tailored to RapidsMPF. More...
#include <rmm_resource_adaptor.hpp>
Public Member Functions | |
| bool | operator== (RmmResourceAdaptor const &other) const noexcept |
| Equality comparison. More... | |
| rmm::device_async_resource_ref | get_upstream_resource () const noexcept |
| Get a reference to the primary upstream resource. More... | |
| ScopedMemoryRecord | get_main_record () const |
| Returns a copy of the main memory record. More... | |
| std::int64_t | current_allocated () const noexcept |
| Get the total current allocated memory through this resource. More... | |
| void | begin_scoped_memory_record () |
| Begin recording a new scoped memory usage record for the current thread. More... | |
| ScopedMemoryRecord | end_scoped_memory_record () |
| End the current scoped memory record and return it. More... | |
Public Member Functions inherited from rapidsmpf::BackRefMixin< BufferResource > | |
| BackRefMixin () noexcept=default | |
| Construct a mixin with no installed back-reference. | |
| BackRefMixin (BackRefMixin const &other) | |
Acquire shared ownership of other's back-referenced owner. More... | |
| BackRefMixin (BackRefMixin &&) noexcept=default | |
| Move constructor. | |
| BackRefMixin & | operator= (BackRefMixin const &other) |
| Copy assignment with the same semantics as the copy constructor. More... | |
| BackRefMixin & | operator= (BackRefMixin &&) noexcept=default |
| Move assignment operator. More... | |
| bool | operator== (BackRefMixin const &other) const noexcept |
| Owner-based equality. More... | |
| void | set_backref (std::weak_ptr< BufferResource > backref) |
| Install a back-reference on this instance. More... | |
Friends | |
| class | BufferResource |
| void | get_property (RmmResourceAdaptor const &, cuda::mr::device_accessible) noexcept |
| Tag this resource as device-accessible for the CCCL concept. | |
A RMM memory resource adaptor tailored to RapidsMPF.
This adaptor wraps a primary device memory resource and adds memory usage tracking (lifetime stats plus per-thread scoped records).
This class is copyable and shares ownership of its internal state via cuda::mr::shared_resource.
It is not possible to construct an RmmResourceAdaptor directly. Instead, obtain one by creating a BufferResource with the memory resource you wish to use for allocations and then obtain the adaptor with device_mr_adaptor().
Definition at line 35 of file rmm_resource_adaptor.hpp.
| void rapidsmpf::RmmResourceAdaptor::begin_scoped_memory_record | ( | ) |
Begin recording a new scoped memory usage record for the current thread.
This method pushes a new empty ScopedMemoryRecord onto the thread-local record stack, allowing for nested memory tracking scopes.
Must be paired with a matching call to end_scoped_memory_record().
|
noexcept |
Get the total current allocated memory through this resource.
| ScopedMemoryRecord rapidsmpf::RmmResourceAdaptor::end_scoped_memory_record | ( | ) |
End the current scoped memory record and return it.
Pops the top ScopedMemoryRecord from the thread-local stack and returns it. If this scope was nested within another (i.e. if begin_scoped_memory_record() was called multiple times in a row), the returned scope is automatically added as a subscope to the next scope remaining on the stack.
This allows nesting of scoped memory tracking, where each scope can contain one or more subscopes. When analyzing or reporting memory statistics, the memory usage of each scope can be calculated inclusive of its subscopes. This behavior mimics standard hierarchical memory profilers, where the total memory attributed to a scope includes all allocations made within it, plus those made in its nested regions.
| std::out_of_range | if called without a matching begin_scoped_memory_record(). |
| ScopedMemoryRecord rapidsmpf::RmmResourceAdaptor::get_main_record | ( | ) | const |
Returns a copy of the main memory record.
The main record tracks memory statistics for the lifetime of the resource.
|
noexcept |
Get a reference to the primary upstream resource.
|
inlinenoexcept |
Equality comparison.
Two adaptors are equal iff they share the same underlying shared state. Because adaptors are privately constructed by BufferResource and a back-reference cannot be overwritten, sharing the same shared state implies referencing the same owning BufferResource.
| other | The other adaptor to compare. |
Definition at line 62 of file rmm_resource_adaptor.hpp.