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

Resource that uses an upstream resource to allocate memory and limits the total allocations possible. More...

#include <limiting_resource_adaptor.hpp>

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

Public Member Functions

 limiting_resource_adaptor (cuda::mr::any_resource< cuda::mr::device_accessible > upstream, std::size_t allocation_limit, std::size_t alignment=rmm::CUDA_ALLOCATION_ALIGNMENT)
 Construct a new limiting resource adaptor using upstream to satisfy allocation requests and limiting the total allocation amount possible. More...
 
device_async_resource_ref get_upstream_resource () const noexcept
 device_async_resource_ref to the upstream resource More...
 
std::size_t get_allocated_bytes () const
 Query the number of bytes that have been allocated. Note that this can not be used to know how large of an allocation is possible due to both possible fragmentation and also internal page sizes and alignment that is not tracked by this allocator. More...
 
std::size_t get_allocation_limit () const
 Query the maximum number of bytes that this allocator is allowed to allocate. This is the limit on the allocator and not a representation of the underlying device. The device may not be able to support this limit. More...
 

Friends

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

Detailed Description

Resource that uses an upstream resource to allocate memory and limits the total allocations possible.

An instance of this resource can be constructed with an existing, upstream resource in order to satisfy allocation requests, but any existing allocations will be untracked. Atomics are used to make this thread-safe, but note that the get_allocated_bytes may not include in-flight allocations.

This class is copyable and shares ownership of its internal state via cuda::mr::shared_resource.

Constructor & Destructor Documentation

◆ limiting_resource_adaptor()

rmm::mr::limiting_resource_adaptor::limiting_resource_adaptor ( cuda::mr::any_resource< cuda::mr::device_accessible >  upstream,
std::size_t  allocation_limit,
std::size_t  alignment = rmm::CUDA_ALLOCATION_ALIGNMENT 
)

Construct a new limiting resource adaptor using upstream to satisfy allocation requests and limiting the total allocation amount possible.

Parameters
upstreamThe resource used for allocating/deallocating device memory
allocation_limitMaximum memory allowed for this allocator
alignmentAlignment in bytes for the start of each allocated buffer

Member Function Documentation

◆ get_allocated_bytes()

std::size_t rmm::mr::limiting_resource_adaptor::get_allocated_bytes ( ) const

Query the number of bytes that have been allocated. Note that this can not be used to know how large of an allocation is possible due to both possible fragmentation and also internal page sizes and alignment that is not tracked by this allocator.

Returns
std::size_t number of bytes that have been allocated through this allocator.

◆ get_allocation_limit()

std::size_t rmm::mr::limiting_resource_adaptor::get_allocation_limit ( ) const

Query the maximum number of bytes that this allocator is allowed to allocate. This is the limit on the allocator and not a representation of the underlying device. The device may not be able to support this limit.

Returns
std::size_t max number of bytes allowed for this allocator

◆ get_upstream_resource()

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

device_async_resource_ref to the upstream resource

Returns
device_async_resource_ref to the upstream resource

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