Helpers for metrics, fragmentation, and buffer management.
Classes | |
class | pw::allocator::WithBuffer< T, kBufferSize, kAlignment > |
struct | pw::allocator::AlignedBuffer< kBufferSize, kAlignment > |
Convenience alias for creating aligned byte buffers. More... | |
struct | pw::allocator::Fragmentation |
struct | pw::allocator::NoMetrics |
struct | pw::allocator::internal::AllMetrics |
class | pw::allocator::internal::Metrics< MetricsType > |
Macros | |
#define | PW_ALLOCATOR_METRICS_FOREACH(fn) |
#define | PW_ALLOCATOR_ABSORB_SEMICOLON() static_assert(true) |
#define | PW_ALLOCATOR_METRICS_DECLARE(metric_name) |
#define | PW_ALLOCATOR_METRICS_INCLUDE(metric_name) |
#define | PW_ALLOCATOR_METRICS_ENABLE(metric_name) |
Functions | |
float | pw::allocator::CalculateFragmentation (const Fragmentation &fragmentation) |
static constexpr bool | pw::allocator::NoMetrics::has_requested_bytes () |
::pw::StatusWithSize | pw::allocator::NoMetrics::get_requested_bytes () const |
static constexpr bool | pw::allocator::NoMetrics::requested_bytes_enabled () |
static constexpr bool | pw::allocator::NoMetrics::has_peak_requested_bytes () |
::pw::StatusWithSize | pw::allocator::NoMetrics::get_peak_requested_bytes () const |
static constexpr bool | pw::allocator::NoMetrics::peak_requested_bytes_enabled () |
static constexpr bool | pw::allocator::NoMetrics::has_cumulative_requested_bytes () |
::pw::StatusWithSize | pw::allocator::NoMetrics::get_cumulative_requested_bytes () const |
static constexpr bool | pw::allocator::NoMetrics::cumulative_requested_bytes_enabled () |
static constexpr bool | pw::allocator::NoMetrics::has_allocated_bytes () |
::pw::StatusWithSize | pw::allocator::NoMetrics::get_allocated_bytes () const |
static constexpr bool | pw::allocator::NoMetrics::allocated_bytes_enabled () |
static constexpr bool | pw::allocator::NoMetrics::has_peak_allocated_bytes () |
::pw::StatusWithSize | pw::allocator::NoMetrics::get_peak_allocated_bytes () const |
static constexpr bool | pw::allocator::NoMetrics::peak_allocated_bytes_enabled () |
static constexpr bool | pw::allocator::NoMetrics::has_cumulative_allocated_bytes () |
::pw::StatusWithSize | pw::allocator::NoMetrics::get_cumulative_allocated_bytes () const |
static constexpr bool | pw::allocator::NoMetrics::cumulative_allocated_bytes_enabled () |
static constexpr bool | pw::allocator::NoMetrics::has_num_allocations () |
::pw::StatusWithSize | pw::allocator::NoMetrics::get_num_allocations () const |
static constexpr bool | pw::allocator::NoMetrics::num_allocations_enabled () |
static constexpr bool | pw::allocator::NoMetrics::has_num_deallocations () |
::pw::StatusWithSize | pw::allocator::NoMetrics::get_num_deallocations () const |
static constexpr bool | pw::allocator::NoMetrics::num_deallocations_enabled () |
static constexpr bool | pw::allocator::NoMetrics::has_num_resizes () |
::pw::StatusWithSize | pw::allocator::NoMetrics::get_num_resizes () const |
static constexpr bool | pw::allocator::NoMetrics::num_resizes_enabled () |
static constexpr bool | pw::allocator::NoMetrics::has_num_reallocations () |
::pw::StatusWithSize | pw::allocator::NoMetrics::get_num_reallocations () const |
static constexpr bool | pw::allocator::NoMetrics::num_reallocations_enabled () |
static constexpr bool | pw::allocator::NoMetrics::has_num_free_blocks () |
::pw::StatusWithSize | pw::allocator::NoMetrics::get_num_free_blocks () const |
static constexpr bool | pw::allocator::NoMetrics::num_free_blocks_enabled () |
static constexpr bool | pw::allocator::NoMetrics::has_smallest_free_block_size () |
::pw::StatusWithSize | pw::allocator::NoMetrics::get_smallest_free_block_size () const |
static constexpr bool | pw::allocator::NoMetrics::smallest_free_block_size_enabled () |
static constexpr bool | pw::allocator::NoMetrics::has_largest_free_block_size () |
::pw::StatusWithSize | pw::allocator::NoMetrics::get_largest_free_block_size () const |
static constexpr bool | pw::allocator::NoMetrics::largest_free_block_size_enabled () |
static constexpr bool | pw::allocator::NoMetrics::has_num_failures () |
::pw::StatusWithSize | pw::allocator::NoMetrics::get_num_failures () const |
static constexpr bool | pw::allocator::NoMetrics::num_failures_enabled () |
static constexpr bool | pw::allocator::NoMetrics::has_unfulfilled_bytes () |
::pw::StatusWithSize | pw::allocator::NoMetrics::get_unfulfilled_bytes () const |
static constexpr bool | pw::allocator::NoMetrics::unfulfilled_bytes_enabled () |
void | pw::allocator::NoMetrics::UpdateDeferred (Allocator &) |
template<typename MetricsType > | |
constexpr bool | pw::allocator::internal::AnyEnabled () |
template<typename MetricsType > | |
void | pw::allocator::internal::CopyMetrics (const MetricsType &src, MetricsType &dst) |
Copies the values enabled for a given MetricsType from src to dst . | |
uint32_t | pw::allocator::internal::ClampU32 (size_t size) |
Helper method for converting size_t s to uint32_t s. | |
#define PW_ALLOCATOR_METRICS_DECLARE | ( | metric_name | ) |
Declares the names of metrics used by pw::allocator::Metrics
.
Only the names of declared metrics may be passed to PW_ALLOCATOR_METRICS_ENABLE
as part of a metrics struct definition.
This macro generates trait types that are used by Metrics
to conditionally include metric-related code.
Note: if enabling `peak_allocated_bytes
or cumulative_allocated_bytes
, allocated_bytes
should also be enabled.
#define PW_ALLOCATOR_METRICS_ENABLE | ( | metric_name | ) |
Enables a metric for in a metrics struct.
The pw::allocator::TrackingAllocator
template takes a struct that enables zero or more of the metrics enumerated by PW_ALLOCATOR_METRICS_DECLARE
`.
This struct may be one of AllMetrics
or NoMetrics
, or may be a custom struct that selects a subset of metrics.
A metric that is enabled is expected to be updated automatically by using a tracking allocator's API.
Example:
#define PW_ALLOCATOR_METRICS_FOREACH | ( | fn | ) |
Applies the given macro to each metric.
This macro helps ensure consistency between definitions that involve every metric.
The recognized pw_allocator metrics are:
#define PW_ALLOCATOR_METRICS_INCLUDE | ( | metric_name | ) |
Includes a metric in a metrics struct.
The pw::allocator::TrackingAllocator
template takes a struct that includes zero or more of the metrics enumerated by PW_ALLOCATOR_METRICS_DECLARE
`.
This struct may be one of AllMetrics
or NoMetrics
, or may be a custom struct that selects a subset of metrics.
A metric that is only included, and not enabled, is expected to only be updated when UpdatedDeferred
is invoked.
|
constexpr |
Returns whether any metric is enabled. If not, metric collection can be skipped.
float pw::allocator::CalculateFragmentation | ( | const Fragmentation & | fragmentation | ) |
Perform the final steps of calculating the fragmentation metric.
This step includes manipulating floating point numbers, and as such it may be desirable to avoid performing this step on device.
|
inline |
Updates metrics by querying an allocator directly.
Metrics are typically updated by an allocator when the pw::Allocator API is invoked. In some cases, there may be metrics that cannot be determined at the interface or are too expensive to do so, e.g. determining the smallest free block. This method provides a way for metrics structs to request these values on-demand.
For this empty base struct, this is simply a no-op.