Implementation class for RmmResourceAdaptor.
More...
#include <rmm_resource_adaptor_impl.hpp>
Implementation class for RmmResourceAdaptor.
Holds all mutable state for memory tracking and fallback allocation. This class satisfies the CCCL cuda::mr::resource concept and is held by RmmResourceAdaptor via cuda::mr::shared_resource for reference-counted ownership.
Definition at line 35 of file rmm_resource_adaptor_impl.hpp.
◆ RmmResourceAdaptorImpl()
| rapidsmpf::detail::RmmResourceAdaptorImpl::RmmResourceAdaptorImpl |
( |
cuda::mr::any_resource< cuda::mr::device_accessible > |
primary_mr, |
|
|
std::optional< cuda::mr::any_resource< cuda::mr::device_accessible >> |
fallback_mr |
|
) |
| |
Construct with primary and optional fallback memory resource.
- Parameters
-
| primary_mr | The primary memory resource. |
| fallback_mr | Optional fallback memory resource. |
◆ allocate()
| void* rapidsmpf::detail::RmmResourceAdaptorImpl::allocate |
( |
cuda::stream_ref |
stream, |
|
|
std::size_t |
bytes, |
|
|
std::size_t |
alignment = rmm::CUDA_ALLOCATION_ALIGNMENT |
|
) |
| |
Allocate memory asynchronously on the given stream.
- Parameters
-
| stream | The CUDA stream for the allocation. |
| bytes | Number of bytes to allocate. |
| alignment | Alignment requirement. |
- Returns
- Pointer to the allocated memory.
◆ allocate_sync()
Allocate memory synchronously.
- Parameters
-
| bytes | Number of bytes to allocate. |
| alignment | Alignment requirement. |
- Returns
- Pointer to the allocated memory.
◆ begin_scoped_memory_record()
| void rapidsmpf::detail::RmmResourceAdaptorImpl::begin_scoped_memory_record |
( |
| ) |
|
◆ current_allocated()
| std::int64_t rapidsmpf::detail::RmmResourceAdaptorImpl::current_allocated |
( |
| ) |
const |
|
noexcept |
Get the total current allocated memory from both primary and fallback.
- Returns
- Total number of currently allocated bytes.
◆ deallocate()
| void rapidsmpf::detail::RmmResourceAdaptorImpl::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.
- Parameters
-
| 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. |
◆ deallocate_sync()
| void rapidsmpf::detail::RmmResourceAdaptorImpl::deallocate_sync |
( |
void * |
ptr, |
|
|
std::size_t |
bytes, |
|
|
std::size_t |
alignment = rmm::CUDA_ALLOCATION_ALIGNMENT |
|
) |
| |
|
noexcept |
Deallocate memory synchronously.
- Parameters
-
| ptr | Pointer to the memory to deallocate. |
| bytes | Number of bytes to deallocate. |
| alignment | Alignment of the original allocation. |
◆ end_scoped_memory_record()
| ScopedMemoryRecord rapidsmpf::detail::RmmResourceAdaptorImpl::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.
- Returns
- The scope that was just ended.
- Exceptions
-
- See also
- begin_scoped_memory_record()
◆ get_fallback_resource()
Get a reference to the fallback upstream resource.
This resource is used if the primary resource throws rmm::out_of_memory.
- Returns
- Optional reference to the fallback RMM memory resource.
◆ get_main_record()
Returns a copy of the main memory record.
The main record tracks memory statistics for the lifetime of the resource.
- Returns
- A copy of the current main memory record.
◆ get_upstream_resource()
Get a reference to the primary upstream resource.
- Returns
- Reference to the RMM memory resource.
◆ operator==()
Equality comparison (identity-based).
- Parameters
-
| other | The other impl to compare. |
- Returns
- True if this and other are the same object.
The documentation for this class was generated from the following file: