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

Allocates memory from upstream resources associated with bin sizes. More...

#include <binning_memory_resource.hpp>

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

Public Member Functions

 binning_memory_resource (cuda::mr::any_resource< cuda::mr::device_accessible > upstream)
 Construct a new binning memory resource object. More...
 
 binning_memory_resource (cuda::mr::any_resource< cuda::mr::device_accessible > upstream, int8_t min_size_exponent, int8_t max_size_exponent)
 Construct a new binning memory resource object with a range of initial bins. More...
 
device_async_resource_ref get_upstream_resource () const noexcept
 device_async_resource_ref to the upstream resource More...
 
void add_bin (std::size_t allocation_size, std::optional< device_async_resource_ref > bin_resource=std::nullopt)
 Add a bin allocator to this resource. More...
 

Friends

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

Detailed Description

Allocates memory from upstream resources associated with bin sizes.

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

Constructor & Destructor Documentation

◆ binning_memory_resource() [1/2]

rmm::mr::binning_memory_resource::binning_memory_resource ( cuda::mr::any_resource< cuda::mr::device_accessible >  upstream)
explicit

Construct a new binning memory resource object.

Initially has no bins, so simply uses the upstream resource until bin resources are added with add_bin.

Parameters
upstreamThe resource used to allocate bin pools.

◆ binning_memory_resource() [2/2]

rmm::mr::binning_memory_resource::binning_memory_resource ( cuda::mr::any_resource< cuda::mr::device_accessible >  upstream,
int8_t  min_size_exponent,
int8_t  max_size_exponent 
)

Construct a new binning memory resource object with a range of initial bins.

Constructs a new binning memory resource and adds bins backed by fixed_size_memory_resource in the range [2^min_size_exponent, 2^max_size_exponent]. For example if min_size_exponent==18 and max_size_exponent==22, creates bins of sizes 256KiB, 512KiB, 1024KiB, 2048KiB and 4096KiB.

Parameters
upstreamThe resource used to allocate bin pools.
min_size_exponentThe minimum base-2 exponent bin size.
max_size_exponentThe maximum base-2 exponent bin size.

Member Function Documentation

◆ add_bin()

void rmm::mr::binning_memory_resource::add_bin ( std::size_t  allocation_size,
std::optional< device_async_resource_ref bin_resource = std::nullopt 
)

Add a bin allocator to this resource.

Adds bin_resource if provided; otherwise constructs and adds a fixed_size_memory_resource.

This bin will be used for any allocation smaller than allocation_size that is larger than the next smaller bin's allocation size.

If there is already a bin of the specified size nothing is changed.

This function is not thread safe.

Parameters
allocation_sizeThe maximum size that this bin allocates
bin_resourceThe memory resource for the bin

◆ get_upstream_resource()

device_async_resource_ref rmm::mr::binning_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 ( binning_memory_resource const &  ,
cuda::mr::device_accessible   
)
friend

Enables the cuda::mr::device_accessible property.

This property declares that a binning_memory_resource provides device accessible memory


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