Resource that uses an upstream resource to allocate memory and limits the total allocations possible. More...
#include <limiting_resource_adaptor.hpp>


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. | |
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.
| 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.
| upstream | The resource used for allocating/deallocating device memory |
| allocation_limit | Maximum memory allowed for this allocator |
| alignment | Alignment in bytes for the start of each allocated buffer |
| 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.
| 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.
|
noexcept |
device_async_resource_ref to the upstream resource