Public Member Functions | Static Public Attributes | Friends | List of all members
rmm::mr::fixed_size_memory_resource Class Reference

A memory resource which allocates memory blocks of a single fixed size. More...

#include <fixed_size_memory_resource.hpp>

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

Public Member Functions

 fixed_size_memory_resource (cuda::mr::any_resource< cuda::mr::device_accessible > upstream, std::size_t block_size=default_block_size, std::size_t blocks_to_preallocate=default_blocks_to_preallocate)
 Construct a new fixed_size_memory_resource that allocates memory from upstream. More...
 
device_async_resource_ref get_upstream_resource () const noexcept
 device_async_resource_ref to the upstream resource More...
 
std::size_t get_block_size () const noexcept
 Get the size of blocks allocated by this memory resource. More...
 

Static Public Attributes

static constexpr std::size_t default_block_size = 1 << 20
 Default allocation block size.
 
static constexpr std::size_t default_blocks_to_preallocate = 128
 

Friends

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

Detailed Description

A memory resource which allocates memory blocks of a single fixed size.

Supports only allocations of size smaller than the configured block_size.

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

Constructor & Destructor Documentation

◆ fixed_size_memory_resource()

rmm::mr::fixed_size_memory_resource::fixed_size_memory_resource ( cuda::mr::any_resource< cuda::mr::device_accessible >  upstream,
std::size_t  block_size = default_block_size,
std::size_t  blocks_to_preallocate = default_blocks_to_preallocate 
)
explicit

Construct a new fixed_size_memory_resource that allocates memory from upstream.

When the pool of blocks is all allocated, grows the pool by allocating blocks_to_preallocate more blocks from upstream.

Parameters
upstreamThe resource from which to allocate blocks for the pool.
block_sizeThe size of blocks to allocate.
blocks_to_preallocateThe number of blocks to allocate to initialize the pool.

Member Function Documentation

◆ get_block_size()

std::size_t rmm::mr::fixed_size_memory_resource::get_block_size ( ) const
noexcept

Get the size of blocks allocated by this memory resource.

Returns
std::size_t size in bytes of allocated blocks.

◆ get_upstream_resource()

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

device_async_resource_ref to the upstream resource

Returns
device_async_resource_ref to the upstream resource

Friends And Related Function Documentation

◆ get_property

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

Enables the cuda::mr::device_accessible property.

This property declares that a fixed_size_memory_resource provides device accessible memory

Member Data Documentation

◆ default_blocks_to_preallocate

constexpr std::size_t rmm::mr::fixed_size_memory_resource::default_blocks_to_preallocate = 128
staticconstexpr

The number of blocks that the pool starts out with, and also the number of blocks by which the pool grows when all of its current blocks are allocated


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