Resource that uses Upstream to allocate memory and tracks statistics on memory allocations.
More...
#include <statistics_resource_adaptor.hpp>


Classes | |
| struct | counter |
| Utility struct for counting the current, peak, and total value of a number. More... | |
Public Types | |
| using | read_lock_t = std::shared_lock< std::shared_mutex > |
| Type of lock used to synchronize read access. | |
| using | write_lock_t = std::unique_lock< std::shared_mutex > |
| Type of lock used to synchronize write access. | |
Public Member Functions | |
| statistics_resource_adaptor (device_async_resource_ref upstream) | |
Construct a new statistics resource adaptor using upstream to satisfy allocation requests. More... | |
| statistics_resource_adaptor (Upstream *upstream) | |
Construct a new statistics resource adaptor using upstream to satisfy allocation requests. More... | |
| statistics_resource_adaptor (statistics_resource_adaptor const &)=delete | |
| statistics_resource_adaptor & | operator= (statistics_resource_adaptor const &)=delete |
| statistics_resource_adaptor (statistics_resource_adaptor &&) noexcept=default | |
| Default move constructor. | |
| statistics_resource_adaptor & | operator= (statistics_resource_adaptor &&) noexcept=default |
| Default move assignment operator. More... | |
| rmm::device_async_resource_ref | get_upstream_resource () const noexcept |
| rmm::device_async_resource_ref to the upstream resource More... | |
| counter | get_bytes_counter () const noexcept |
Returns a counter struct for this adaptor containing the current, peak, and total number of allocated bytes for this adaptor since it was created. More... | |
| counter | get_allocations_counter () const noexcept |
Returns a counter struct for this adaptor containing the current, peak, and total number of allocation counts for this adaptor since it was created. More... | |
| std::pair< counter, counter > | push_counters () |
Push a pair of zero counters on the stack, which becomes the new counters returned by get_bytes_counter() and get_allocations_counter() More... | |
| std::pair< counter, counter > | pop_counters () |
| Pop a pair of counters from the stack. More... | |
Public Member Functions inherited from rmm::mr::device_memory_resource | |
| device_memory_resource (device_memory_resource const &)=default | |
| Default copy constructor. | |
| device_memory_resource (device_memory_resource &&) noexcept=default | |
| Default move constructor. | |
| device_memory_resource & | operator= (device_memory_resource const &)=default |
| Default copy assignment operator. More... | |
| device_memory_resource & | operator= (device_memory_resource &&) noexcept=default |
| Default move assignment operator. More... | |
| void * | allocate_sync (std::size_t bytes, std::size_t alignment=rmm::CUDA_ALLOCATION_ALIGNMENT) |
Allocates memory of size at least bytes. More... | |
| void | deallocate_sync (void *ptr, std::size_t bytes, [[maybe_unused]] std::size_t alignment=rmm::CUDA_ALLOCATION_ALIGNMENT) noexcept |
Deallocate memory pointed to by p. More... | |
| void * | allocate (cuda_stream_view stream, std::size_t bytes, std::size_t alignment=rmm::CUDA_ALLOCATION_ALIGNMENT) |
Allocates memory of size at least bytes on the specified stream. More... | |
| void | deallocate (cuda_stream_view stream, void *ptr, std::size_t bytes, [[maybe_unused]] std::size_t alignment=rmm::CUDA_ALLOCATION_ALIGNMENT) noexcept |
Deallocate memory pointed to by ptr on the specified stream. More... | |
| bool | is_equal (device_memory_resource const &other) const noexcept |
| Compare this resource to another. More... | |
| bool | operator== (device_memory_resource const &other) const noexcept |
| Comparison operator with another device_memory_resource. More... | |
| bool | operator!= (device_memory_resource const &other) const noexcept |
| Comparison operator with another device_memory_resource. More... | |
Resource that uses Upstream to allocate memory and tracks statistics on memory allocations.
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. Tracking statistics stores the current, peak and total memory allocations for both the number of bytes and number of calls to the memory resource.
This resource supports nested statistics, which makes it possible to track statistics of a code block. Use .push_counters() to start tracking statistics on a code block and use .pop_counters() to stop the tracking. The nested statistics are cascading such that the statistics tracked by a code block include the statistics tracked in all its tracked sub code blocks.
statistics_resource_adaptor is intended as a debug adaptor and shouldn't be used in performance-sensitive code.
| Upstream | Type of the upstream resource used for allocation/deallocation. |
|
inline |
Construct a new statistics resource adaptor using upstream to satisfy allocation requests.
| upstream | The resource_ref used for allocating/deallocating device memory. |
|
inline |
Construct a new statistics resource adaptor using upstream to satisfy allocation requests.
| rmm::logic_error | if upstream == nullptr |
| upstream | The resource used for allocating/deallocating device memory. |
|
inlinenoexcept |
Returns a counter struct for this adaptor containing the current, peak, and total number of allocation counts for this adaptor since it was created.
|
inlinenoexcept |
Returns a counter struct for this adaptor containing the current, peak, and total number of allocated bytes for this adaptor since it was created.
|
inlinenoexcept |
rmm::device_async_resource_ref to the upstream resource
|
defaultnoexcept |
Default move assignment operator.
|
inline |
Pop a pair of counters from the stack.
| std::out_of_range | if the counter stack has fewer than two entries. |
|
inline |
Push a pair of zero counters on the stack, which becomes the new counters returned by get_bytes_counter() and get_allocations_counter()