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

Memory resource that uses cudaMallocAsync/cudaFreeAsync for allocation/deallocation. More...

#include <cuda_async_view_memory_resource.hpp>

Public Member Functions

 cuda_async_view_memory_resource (cudaMemPool_t pool_handle)
 Constructs a cuda_async_view_memory_resource which uses an existing CUDA memory pool. The provided pool is not owned by cuda_async_view_memory_resource and must remain valid during the lifetime of the memory resource. More...
 
cudaMemPool_t pool_handle () const noexcept
 Returns the underlying native handle to the CUDA pool. More...
 
 cuda_async_view_memory_resource (cuda_async_view_memory_resource const &)=default
 Default copy constructor.
 
 cuda_async_view_memory_resource (cuda_async_view_memory_resource &&)=default
 Default move constructor.
 
cuda_async_view_memory_resourceoperator= (cuda_async_view_memory_resource const &)=default
 Default copy assignment operator. More...
 
cuda_async_view_memory_resourceoperator= (cuda_async_view_memory_resource &&)=default
 Default move assignment operator. More...
 
void * allocate (cuda::stream_ref stream, std::size_t bytes, [[maybe_unused]] std::size_t alignment=rmm::CUDA_ALLOCATION_ALIGNMENT)
 Allocates memory of size at least bytes. More...
 
void deallocate (cuda::stream_ref stream, void *ptr, [[maybe_unused]] std::size_t bytes, [[maybe_unused]] std::size_t alignment=rmm::CUDA_ALLOCATION_ALIGNMENT) noexcept
 Deallocate memory pointed to by ptr. More...
 
void * allocate_sync (std::size_t bytes, std::size_t alignment=rmm::CUDA_ALLOCATION_ALIGNMENT)
 Allocates memory of size at least bytes synchronously. More...
 
void deallocate_sync (void *ptr, std::size_t bytes, std::size_t alignment=rmm::CUDA_ALLOCATION_ALIGNMENT) noexcept
 Deallocate memory pointed to by ptr synchronously. More...
 
bool operator== (cuda_async_view_memory_resource const &other) const noexcept
 Compare this resource to another. More...
 
bool operator!= (cuda_async_view_memory_resource const &other) const noexcept
 Compare this resource to another. More...
 

Friends

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

Detailed Description

Memory resource that uses cudaMallocAsync/cudaFreeAsync for allocation/deallocation.

Constructor & Destructor Documentation

◆ cuda_async_view_memory_resource()

rmm::mr::cuda_async_view_memory_resource::cuda_async_view_memory_resource ( cudaMemPool_t  pool_handle)
inline

Constructs a cuda_async_view_memory_resource which uses an existing CUDA memory pool. The provided pool is not owned by cuda_async_view_memory_resource and must remain valid during the lifetime of the memory resource.

Exceptions
rmm::logic_errorif the CUDA version does not support cudaMallocAsync
Parameters
pool_handleHandle to a CUDA memory pool which will be used to serve allocation requests.

Member Function Documentation

◆ allocate()

void* rmm::mr::cuda_async_view_memory_resource::allocate ( cuda::stream_ref  stream,
std::size_t  bytes,
[[maybe_unused] ] std::size_t  alignment = rmm::CUDA_ALLOCATION_ALIGNMENT 
)
inline

Allocates memory of size at least bytes.

The returned pointer will have at minimum 256 byte alignment.

Parameters
streamStream on which to perform allocation
bytesThe size of the allocation
alignmentThe alignment of the allocation
Returns
void* Pointer to the newly allocated memory

◆ allocate_sync()

void* rmm::mr::cuda_async_view_memory_resource::allocate_sync ( std::size_t  bytes,
std::size_t  alignment = rmm::CUDA_ALLOCATION_ALIGNMENT 
)
inline

Allocates memory of size at least bytes synchronously.

Parameters
bytesThe size of the allocation
alignmentThe alignment of the allocation
Returns
void* Pointer to the newly allocated memory

◆ deallocate()

void rmm::mr::cuda_async_view_memory_resource::deallocate ( cuda::stream_ref  stream,
void *  ptr,
[[maybe_unused] ] std::size_t  bytes,
[[maybe_unused] ] std::size_t  alignment = rmm::CUDA_ALLOCATION_ALIGNMENT 
)
inlinenoexcept

Deallocate memory pointed to by ptr.

Parameters
streamStream on which to perform deallocation
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 ptr.
alignmentThe alignment that was passed to the allocate call that returned ptr

◆ deallocate_sync()

void rmm::mr::cuda_async_view_memory_resource::deallocate_sync ( void *  ptr,
std::size_t  bytes,
std::size_t  alignment = rmm::CUDA_ALLOCATION_ALIGNMENT 
)
inlinenoexcept

Deallocate memory pointed to by ptr synchronously.

Parameters
ptrPointer to be deallocated
bytesThe size in bytes of the allocation
alignmentThe alignment that was passed to the allocate call that returned ptr

◆ operator!=()

bool rmm::mr::cuda_async_view_memory_resource::operator!= ( cuda_async_view_memory_resource const &  other) const
inlinenoexcept

Compare this resource to another.

Parameters
otherThe other resource to compare to
Returns
true If the two resources are equivalent
false If the two resources are not equal

◆ operator=() [1/2]

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

Default move assignment operator.

Returns
cuda_async_view_memory_resource& Reference to the assigned object

◆ operator=() [2/2]

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

Default copy assignment operator.

Returns
cuda_async_view_memory_resource& Reference to the assigned object

◆ operator==()

bool rmm::mr::cuda_async_view_memory_resource::operator== ( cuda_async_view_memory_resource const &  other) const
inlinenoexcept

Compare this resource to another.

Parameters
otherThe other resource to compare to
Returns
true If the two resources are equivalent
false If the two resources are not equal

◆ pool_handle()

cudaMemPool_t rmm::mr::cuda_async_view_memory_resource::pool_handle ( ) const
inlinenoexcept

Returns the underlying native handle to the CUDA pool.

Returns
cudaMemPool_t Handle to the underlying CUDA pool

Friends And Related Function Documentation

◆ get_property

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

Enables the cuda::mr::device_accessible property.

This property declares that a cuda_async_view_memory_resource provides device accessible memory


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