Public Member Functions | Friends | List of all members
rmm::mr::pool_memory_resource Class Reference

A coalescing best-fit suballocator which uses a pool of memory allocated from an upstream memory_resource. More...

#include <pool_memory_resource.hpp>

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

Public Member Functions

 pool_memory_resource (cuda::mr::any_resource< cuda::mr::device_accessible > upstream, std::size_t initial_pool_size, std::optional< std::size_t > maximum_pool_size=std::nullopt)
 Construct a pool_memory_resource and allocate the initial device memory pool using upstream. More...
 
device_async_resource_ref get_upstream_resource () const noexcept
 rmm::device_async_resource_ref to the upstream resource More...
 
std::size_t pool_size () const noexcept
 Computes the size of the current pool. More...
 

Friends

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

Detailed Description

A coalescing best-fit suballocator which uses a pool of memory allocated from an upstream memory_resource.

Allocation and deallocation are thread-safe. Also, this class is compatible with CUDA per-thread default stream.

This class is copyable and shares ownership of its internal state, allowing multiple instances to safely reference the same underlying pool.

Constructor & Destructor Documentation

◆ pool_memory_resource()

rmm::mr::pool_memory_resource::pool_memory_resource ( cuda::mr::any_resource< cuda::mr::device_accessible >  upstream,
std::size_t  initial_pool_size,
std::optional< std::size_t >  maximum_pool_size = std::nullopt 
)
explicit

Construct a pool_memory_resource and allocate the initial device memory pool using upstream.

Exceptions
rmm::logic_errorif initial_pool_size is not aligned to a multiple of 256 bytes.
rmm::logic_errorif maximum_pool_size is neither the default nor aligned to a multiple of 256 bytes.
Parameters
upstreamThe resource from which to allocate blocks for the pool.
initial_pool_sizeMinimum size, in bytes, of the initial pool.
maximum_pool_sizeMaximum size, in bytes, that the pool can grow to. Defaults to all of the available memory from the upstream resource.

Member Function Documentation

◆ get_upstream_resource()

device_async_resource_ref rmm::mr::pool_memory_resource::get_upstream_resource ( ) const
noexcept

rmm::device_async_resource_ref to the upstream resource

Returns
rmm::device_async_resource_ref to the upstream resource

◆ pool_size()

std::size_t rmm::mr::pool_memory_resource::pool_size ( ) const
noexcept

Computes the size of the current pool.

Includes allocated as well as free memory.

Returns
std::size_t The total size of the currently allocated pool.

Friends And Related Function Documentation

◆ get_property

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

Enables the cuda::mr::device_accessible property.

This property declares that a pool_memory_resource provides device accessible memory


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