Public Member Functions | Friends | List of all members
rapidsmpf::PinnedMemoryResource Class Referencefinal

Memory resource that provides pinned (page-locked) host memory using a pool. More...

#include <pinned_memory_resource.hpp>

Inheritance diagram for rapidsmpf::PinnedMemoryResource:
rapidsmpf::BackRefMixin< BufferResource >

Public Member Functions

void * allocate (cuda::stream_ref stream, std::size_t size, std::size_t alignment=rmm::CUDA_ALLOCATION_ALIGNMENT)
 Allocates pinned host memory associated with a CUDA stream. More...
 
void deallocate (cuda::stream_ref stream, void *ptr, std::size_t size, std::size_t alignment=rmm::CUDA_ALLOCATION_ALIGNMENT) noexcept
 Deallocates pinned host memory associated with a CUDA stream. More...
 
bool operator== (PinnedMemoryResource const &other) const noexcept
 Equality comparison. More...
 
std::int64_t current_allocated () const noexcept
 Returns the total number of currently allocated bytes. More...
 
ScopedMemoryRecord get_main_memory_record () const
 Returns the main memory record for the pinned pool. More...
 
constexpr PinnedPoolProperties const & properties () const noexcept
 Returns the properties used to configure the pool. 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.
 
BackRefMixinoperator= (BackRefMixin const &other)
 Copy assignment with the same semantics as the copy constructor. More...
 
BackRefMixinoperator= (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 (PinnedMemoryResource const &, cuda::mr::host_accessible) noexcept
 Enables the cuda::mr::host_accessible property.
 

Detailed Description

Memory resource that provides pinned (page-locked) host memory using a pool.

Inherits from cuda::mr::shared_resource<RmmResourceAdaptorImpl<cuda::pinned_memory_pool>>, which holds the pool directly inside the shared control block — no extra heap allocation for the pool itself. Copies share the same underlying pool and memory statistics.

This resource allocates and deallocates pinned host memory asynchronously through CUDA streams. It offers higher bandwidth and lower latency for device transfers compared to regular pageable host memory.

Definition at line 128 of file pinned_memory_resource.hpp.

Member Function Documentation

◆ allocate()

void* rapidsmpf::PinnedMemoryResource::allocate ( cuda::stream_ref  stream,
std::size_t  size,
std::size_t  alignment = rmm::CUDA_ALLOCATION_ALIGNMENT 
)
inline

Allocates pinned host memory associated with a CUDA stream.

Parameters
streamCUDA stream associated with the allocation.
sizeNumber of bytes to at least allocate.
alignmentRequired alignment.
Returns
Pointer to the allocated memory.
Exceptions
std::bad_allocIf the allocation fails.
std::invalid_argumentIf alignment is not a valid alignment.

Definition at line 148 of file pinned_memory_resource.hpp.

◆ current_allocated()

std::int64_t rapidsmpf::PinnedMemoryResource::current_allocated ( ) const
inlinenoexcept

Returns the total number of currently allocated bytes.

Returns
The total number of currently allocated bytes.

Definition at line 188 of file pinned_memory_resource.hpp.

◆ deallocate()

void rapidsmpf::PinnedMemoryResource::deallocate ( cuda::stream_ref  stream,
void *  ptr,
std::size_t  size,
std::size_t  alignment = rmm::CUDA_ALLOCATION_ALIGNMENT 
)
inlinenoexcept

Deallocates pinned host memory associated with a CUDA stream.

Parameters
streamCUDA stream associated with operations that used ptr.
ptrPointer to the memory to deallocate. May be nullptr.
sizeNumber of bytes previously allocated at ptr.
alignmentAlignment originally used for the allocation.

Definition at line 164 of file pinned_memory_resource.hpp.

◆ get_main_memory_record()

ScopedMemoryRecord rapidsmpf::PinnedMemoryResource::get_main_memory_record ( ) const
inline

Returns the main memory record for the pinned pool.

Returns
The main memory record for the pinned pool.

Definition at line 197 of file pinned_memory_resource.hpp.

◆ operator==()

bool rapidsmpf::PinnedMemoryResource::operator== ( PinnedMemoryResource const &  other) const
inlinenoexcept

Equality comparison.

Parameters
otherThe other resource to compare.
Returns
True if the two resources share the same underlying shared state.

Definition at line 179 of file pinned_memory_resource.hpp.

◆ properties()

constexpr PinnedPoolProperties const& rapidsmpf::PinnedMemoryResource::properties ( ) const
inlineconstexprnoexcept

Returns the properties used to configure the pool.

Returns
The properties used to configure the pool.

Definition at line 206 of file pinned_memory_resource.hpp.


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