A functor for querying the remaining available memory within a defined limit from an RMM statistics resource. More...
#include <resource.hpp>
Public Member Functions | |
| constexpr | LimitAvailableMemory (RmmResourceAdaptor const *mr, std::int64_t limit) |
Constructs a LimitAvailableMemory instance. More... | |
| std::int64_t | operator() () const |
| Returns the remaining available memory within the defined limit. More... | |
Public Attributes | |
| std::int64_t const | limit |
| The memory limit. | |
A functor for querying the remaining available memory within a defined limit from an RMM statistics resource.
This class is designed to be used as a callback to provide available memory information in the context of memory management, such as when working with BufferResource. The available memory is determined as the difference between a user-defined limit and the memory currently used, as reported by an RMM statistics resource adaptor.
By enforcing a limit, this functor can be used to simulate constrained memory environments or to prevent memory allocation beyond a specific threshold.
Definition at line 452 of file resource.hpp.
|
inlineconstexpr |
Constructs a LimitAvailableMemory instance.
| mr | A pointer to an RMM resource adaptor. The underlying resource adaptor must outlive this instance. |
| limit | The maximum memory available (in bytes). Used to calculate the remaining memory. |
Definition at line 462 of file resource.hpp.
|
inline |
Returns the remaining available memory within the defined limit.
This operator queries the RmmResourceAdaptor to determine the memory currently used and calculates the remaining memory as: limit - used_memory.
Definition at line 474 of file resource.hpp.