Implementation class for RmmResourceAdaptor. More...
#include <rmm_resource_adaptor_impl.hpp>
Public Member Functions | |
| RmmResourceAdaptorImpl (PrimaryMR primary_mr) | |
| Construct with a primary memory resource. More... | |
| template<typename... Args> | |
| RmmResourceAdaptorImpl (std::in_place_t, Args &&... args) | |
| Construct the primary resource in-place from forwarded arguments. More... | |
| RmmResourceAdaptorImpl (RmmResourceAdaptorImpl const &)=delete | |
| RmmResourceAdaptorImpl (RmmResourceAdaptorImpl &&)=delete | |
| RmmResourceAdaptorImpl & | operator= (RmmResourceAdaptorImpl const &)=delete |
| RmmResourceAdaptorImpl & | operator= (RmmResourceAdaptorImpl &&)=delete |
| bool | operator== (RmmResourceAdaptorImpl const &other) const noexcept |
| Equality comparison. More... | |
| PrimaryMR const & | get_upstream_resource () const noexcept |
| Returns 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... | |
| void * | allocate (cuda::stream_ref stream, std::size_t bytes, std::size_t alignment=rmm::CUDA_ALLOCATION_ALIGNMENT) |
| Allocate memory asynchronously on the given stream. More... | |
| void | deallocate (cuda::stream_ref stream, void *ptr, std::size_t bytes, std::size_t alignment=rmm::CUDA_ALLOCATION_ALIGNMENT) noexcept |
| Deallocate memory asynchronously on the given stream. More... | |
| void * | allocate_sync (std::size_t bytes, std::size_t alignment=rmm::CUDA_ALLOCATION_ALIGNMENT) |
| Allocate memory synchronously. More... | |
| void | deallocate_sync (void *ptr, std::size_t bytes, std::size_t alignment=rmm::CUDA_ALLOCATION_ALIGNMENT) noexcept |
| Deallocate memory synchronously. More... | |
Friends | |
| void | get_property (RmmResourceAdaptorImpl const &, cuda::mr::device_accessible) noexcept |
| Tag this resource as device-accessible for the CCCL concept. | |
Implementation class for RmmResourceAdaptor.
Holds all mutable state for memory tracking. This class satisfies the CCCL cuda::mr::resource concept and is held by RmmResourceAdaptor via cuda::mr::shared_resource for reference-counted ownership.
| PrimaryMR | The type of the primary memory resource. Use a concrete resource type (e.g. cuda::pinned_memory_pool) to store the resource directly inside the shared control block, avoiding an extra heap allocation. |
Definition at line 43 of file rmm_resource_adaptor_impl.hpp.
|
inlineexplicit |
Construct with a primary memory resource.
| primary_mr | The primary memory resource (moved in). |
Definition at line 54 of file rmm_resource_adaptor_impl.hpp.
|
inlineexplicit |
Construct the primary resource in-place from forwarded arguments.
Use this overload when the primary resource type is non-movable (e.g. cuda::pinned_memory_pool). The resource is constructed directly inside the shared-ownership control block, avoiding an extra heap allocation.
| args | Arguments forwarded to the PrimaryMR constructor. |
Definition at line 71 of file rmm_resource_adaptor_impl.hpp.
|
inline |
Allocate memory asynchronously on the given stream.
| stream | The CUDA stream for the allocation. |
| bytes | Number of bytes to allocate. |
| alignment | Alignment requirement. |
Definition at line 142 of file rmm_resource_adaptor_impl.hpp.
|
inline |
Allocate memory synchronously.
| bytes | Number of bytes to allocate. |
| alignment | Alignment requirement. |
Definition at line 202 of file rmm_resource_adaptor_impl.hpp.
|
inline |
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().
Definition at line 112 of file rmm_resource_adaptor_impl.hpp.
|
inlinenoexcept |
Get the total current allocated memory through this resource.
Definition at line 106 of file rmm_resource_adaptor_impl.hpp.
|
inlinenoexcept |
Deallocate memory asynchronously on the given stream.
| stream | The CUDA stream for the deallocation. |
| ptr | Pointer to the memory to deallocate. |
| bytes | Number of bytes to deallocate. |
| alignment | Alignment of the original allocation. |
Definition at line 172 of file rmm_resource_adaptor_impl.hpp.
|
inlinenoexcept |
Deallocate memory synchronously.
| ptr | Pointer to the memory to deallocate. |
| bytes | Number of bytes to deallocate. |
| alignment | Alignment of the original allocation. |
Definition at line 217 of file rmm_resource_adaptor_impl.hpp.
|
inline |
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(). |
Definition at line 118 of file rmm_resource_adaptor_impl.hpp.
|
inline |
Returns a copy of the main memory record.
The main record tracks memory statistics for the lifetime of the resource.
Definition at line 100 of file rmm_resource_adaptor_impl.hpp.
|
inlinenoexcept |
Returns a reference to the primary upstream resource.
Definition at line 95 of file rmm_resource_adaptor_impl.hpp.
|
inlinenoexcept |
Equality comparison.
| other | The other impl to compare. |
Definition at line 87 of file rmm_resource_adaptor_impl.hpp.