Public Member Functions | Friends | List of all members
rmm::mr::pinned_memory_resource Class Referencefinal

A host_memory_resource that uses cudaMallocHost to allocate pinned/page-locked host memory. More...

#include <pinned_memory_resource.hpp>

Inheritance diagram for rmm::mr::pinned_memory_resource:
Inheritance graph
[legend]
Collaboration diagram for rmm::mr::pinned_memory_resource:
Collaboration graph
[legend]

Public Member Functions

 pinned_memory_resource (pinned_memory_resource const &)=default
 Default copy constructor.
 
 pinned_memory_resource (pinned_memory_resource &&)=default
 Default move constructor.
 
pinned_memory_resourceoperator= (pinned_memory_resource const &)=default
 Default copy assignment operator. More...
 
pinned_memory_resourceoperator= (pinned_memory_resource &&)=default
 Default move assignment operator. More...
 
bool supports_streams () const noexcept
 Query whether the pinned_memory_resource supports use of non-null CUDA streams for allocation/deallocation. More...
 
bool supports_get_mem_info () const noexcept
 Query whether the resource supports the get_mem_info API. More...
 
std::pair< std::size_t, std::size_t > get_mem_info (cuda_stream_view stream) const
 Queries the amount of free and total memory for the resource. More...
 
void * allocate_async (std::size_t bytes, std::size_t alignment, cuda_stream_view)
 Pretend to support the allocate_async interface, falling back to stream 0. More...
 
void * allocate_async (std::size_t bytes, cuda_stream_view)
 Pretend to support the allocate_async interface, falling back to stream 0. More...
 
void deallocate_async (void *ptr, std::size_t bytes, std::size_t alignment, cuda_stream_view)
 Pretend to support the deallocate_async interface, falling back to stream 0. More...
 
- Public Member Functions inherited from rmm::mr::host_memory_resource
 host_memory_resource (host_memory_resource const &)=default
 Default copy constructor.
 
 host_memory_resource (host_memory_resource &&) noexcept=default
 Default move constructor.
 
host_memory_resourceoperator= (host_memory_resource const &)=default
 Default copy assignment operator. More...
 
host_memory_resourceoperator= (host_memory_resource &&) noexcept=default
 Default move assignment operator. More...
 
void * allocate (std::size_t bytes, std::size_t alignment=alignof(std::max_align_t))
 Allocates memory on the host of size at least bytes bytes. More...
 
void deallocate (void *ptr, std::size_t bytes, std::size_t alignment=alignof(std::max_align_t))
 Deallocate memory pointed to by ptr. More...
 
bool is_equal (host_memory_resource const &other) const noexcept
 Compare this resource to another. More...
 
bool operator== (host_memory_resource const &other) const noexcept
 Comparison operator with another device_memory_resource. More...
 
bool operator!= (host_memory_resource const &other) const noexcept
 Comparison operator with another device_memory_resource. More...
 

Friends

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

Detailed Description

A host_memory_resource that uses cudaMallocHost to allocate pinned/page-locked host memory.

See https://devblogs.nvidia.com/how-optimize-data-transfers-cuda-cc/

Member Function Documentation

◆ allocate_async() [1/2]

void* rmm::mr::pinned_memory_resource::allocate_async ( std::size_t  bytes,
cuda_stream_view   
)
inline

Pretend to support the allocate_async interface, falling back to stream 0.

Exceptions
rmm::bad_allocWhen the requested bytes cannot be allocated on the specified stream.
Parameters
bytesThe size of the allocation
Returns
void* Pointer to the newly allocated memory

◆ allocate_async() [2/2]

void* rmm::mr::pinned_memory_resource::allocate_async ( std::size_t  bytes,
std::size_t  alignment,
cuda_stream_view   
)
inline

Pretend to support the allocate_async interface, falling back to stream 0.

Exceptions
rmm::bad_allocWhen the requested bytes cannot be allocated on the specified stream.
Parameters
bytesThe size of the allocation
alignmentThe expected alignment of the allocation
Returns
void* Pointer to the newly allocated memory

◆ deallocate_async()

void rmm::mr::pinned_memory_resource::deallocate_async ( void *  ptr,
std::size_t  bytes,
std::size_t  alignment,
cuda_stream_view   
)
inline

Pretend to support the deallocate_async interface, falling back to stream 0.

Parameters
ptrPointer to be deallocated
bytesThe size in bytes of the allocation. This must be equal to the value of bytes that was passed to the allocate call that returned p.
alignmentThe alignment that was passed to the allocate call that returned p

◆ get_mem_info()

std::pair<std::size_t, std::size_t> rmm::mr::pinned_memory_resource::get_mem_info ( cuda_stream_view  stream) const
inline

Queries the amount of free and total memory for the resource.

Parameters
streamthe stream whose memory manager we want to retrieve
Returns
a pair containing the free memory in bytes in .first and total amount of memory in .second

◆ operator=() [1/2]

pinned_memory_resource& rmm::mr::pinned_memory_resource::operator= ( pinned_memory_resource &&  )
default

Default move assignment operator.

Returns
pinned_memory_resource& Reference to the assigned object

◆ operator=() [2/2]

pinned_memory_resource& rmm::mr::pinned_memory_resource::operator= ( pinned_memory_resource const &  )
default

Default copy assignment operator.

Returns
pinned_memory_resource& Reference to the assigned object

◆ supports_get_mem_info()

bool rmm::mr::pinned_memory_resource::supports_get_mem_info ( ) const
inlinenoexcept

Query whether the resource supports the get_mem_info API.

Returns
bool false.

◆ supports_streams()

bool rmm::mr::pinned_memory_resource::supports_streams ( ) const
inlinenoexcept

Query whether the pinned_memory_resource supports use of non-null CUDA streams for allocation/deallocation.

Returns
bool false.

Friends And Related Function Documentation

◆ get_property

void get_property ( pinned_memory_resource const &  ,
cuda::mr::device_accessible   
)
friend

Enables the cuda::mr::device_accessible property.

This property declares that a pinned_memory_resource provides device accessible memory


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