Public Member Functions | Friends | List of all members
rapidsmpf::HostMemoryResource Class Reference

Host memory resource using standard CPU allocation. More...

#include <host_memory_resource.hpp>

Public Member Functions

 HostMemoryResource (HostMemoryResource const &)=default
 Copyable.
 
 HostMemoryResource (HostMemoryResource &&)=default
 Movable.
 
HostMemoryResourceoperator= (HostMemoryResource const &)=default
 Copy assignment. More...
 
HostMemoryResourceoperator= (HostMemoryResource &&)=default
 Move assignment. More...
 
void * allocate_sync (std::size_t, std::size_t)
 Synchronously allocates host memory is disabled. More...
 
void deallocate_sync (void *, std::size_t, std::size_t)
 Synchronously deallocates host memory is disabled. More...
 
void * allocate (rmm::cuda_stream_view stream, std::size_t size, std::size_t alignment=rmm::CUDA_ALLOCATION_ALIGNMENT)
 Allocates host memory associated with a CUDA stream. More...
 
void deallocate (rmm::cuda_stream_view stream, void *ptr, std::size_t size, std::size_t alignment=rmm::CUDA_ALLOCATION_ALIGNMENT) noexcept
 Deallocates host memory associated with a CUDA stream. More...
 
bool operator== ([[maybe_unused]] HostMemoryResource const &other) const noexcept
 Compares this resource to another resource. More...
 
bool operator!= ([[maybe_unused]] HostMemoryResource const &other) const noexcept
 Compares this resource to another resource. More...
 

Friends

void get_property (HostMemoryResource const &, cuda::mr::host_accessible) noexcept
 Enables the cuda::mr::host_accessible property. More...
 

Detailed Description

Host memory resource using standard CPU allocation.

This resource allocates pageable host memory using the new and delete operators. It is intended for use with cuda::mr::resource and related facilities, and advertises the cuda::mr::host_accessible property.

For sufficiently large allocations (>4 MiB), this resource also issues a best-effort request to enable Transparent Huge Pages (THP) on the allocated region. THP can improve device-host memory transfer performance for large buffers. The hint is applied via madvise(MADV_HUGEPAGE) and may be ignored by the kernel depending on system configuration or resource availability.

Definition at line 32 of file host_memory_resource.hpp.

Member Function Documentation

◆ allocate()

void* rapidsmpf::HostMemoryResource::allocate ( rmm::cuda_stream_view  stream,
std::size_t  size,
std::size_t  alignment = rmm::CUDA_ALLOCATION_ALIGNMENT 
)

Allocates 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.

◆ allocate_sync()

void* rapidsmpf::HostMemoryResource::allocate_sync ( std::size_t  ,
std::size_t   
)
inline

Synchronously allocates host memory is disabled.

Always use stream-ordered allocators in RapidsMPF.

Returns
N/A.
Exceptions
std::invalid_argumentAlways.

Definition at line 57 of file host_memory_resource.hpp.

◆ deallocate()

void rapidsmpf::HostMemoryResource::deallocate ( rmm::cuda_stream_view  stream,
void *  ptr,
std::size_t  size,
std::size_t  alignment = rmm::CUDA_ALLOCATION_ALIGNMENT 
)
noexcept

Deallocates host memory associated with a CUDA stream.

Synchronizes stream before deallocating the memory with the delete operator.

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.

◆ deallocate_sync()

void rapidsmpf::HostMemoryResource::deallocate_sync ( void *  ,
std::size_t  ,
std::size_t   
)
inline

Synchronously deallocates host memory is disabled.

Exceptions
std::invalid_argumentAlways.

Definition at line 69 of file host_memory_resource.hpp.

◆ operator!=()

bool rapidsmpf::HostMemoryResource::operator!= ( [[maybe_unused] ] HostMemoryResource const &  other) const
inlinenoexcept

Compares this resource to another resource.

All instances are stateless and interchangeable, so this always returns true.

Parameters
otherThe resource to compare with.
Returns
true

Definition at line 127 of file host_memory_resource.hpp.

◆ operator=() [1/2]

HostMemoryResource& rapidsmpf::HostMemoryResource::operator= ( HostMemoryResource &&  )
default

Move assignment.

Returns
Reference to this object after assignment.

◆ operator=() [2/2]

HostMemoryResource& rapidsmpf::HostMemoryResource::operator= ( HostMemoryResource const &  )
default

Copy assignment.

Returns
Reference to this object after assignment.

◆ operator==()

bool rapidsmpf::HostMemoryResource::operator== ( [[maybe_unused] ] HostMemoryResource const &  other) const
inlinenoexcept

Compares this resource to another resource.

All instances are stateless and interchangeable, so this always returns true.

Parameters
otherThe resource to compare with.
Returns
true

Definition at line 120 of file host_memory_resource.hpp.

Friends And Related Function Documentation

◆ get_property

void get_property ( HostMemoryResource const &  ,
cuda::mr::host_accessible   
)
friend

Enables the cuda::mr::host_accessible property.

This property declares that a HostMemoryResource provides host accessible memory

Definition at line 138 of file host_memory_resource.hpp.


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