TRIQS/nda 1.3.0
Multi-dimensional array library for C++
Loading...
Searching...
No Matches
nda::mem::stats< A >

#include <nda/mem/allocators.hpp>

Detailed Description

template<Allocator A>
class nda::mem::stats< A >

Wrap an allocator to gather statistics about memory allocation.

It gathers a histogram of the different allocation sizes. The histogram is a std::vector of size 65, where element \( i \in \{0,...,63\} \) contains the number of allocations with a size in the range \( [2^{64-i-1}, 2^{64-i}) \) and the last element contains the number of allocations of size zero.

Template Parameters
Anda::mem::Allocator type to wrap.

Definition at line 571 of file allocators.hpp.

Inherits nda::mem::A.

Public Member Functions

 stats ()=default
 Default constructor.
 
 stats (stats &&)=default
 Default move constructor.
 
 stats (stats const &)=delete
 Deleted copy constructor.
 
 ~stats ()
 Destructor that outputs the statistics about the memory allocation in debug mode.
 
blk_t allocate (uint64_t s)
 Allocate memory and update the histogram.
 
blk_t allocate_zero (uint64_t s)
 Allocate memory, set it to zero and update the histogram.
 
void deallocate (blk_t b) noexcept
 Deallocate memory.
 
auto const & histogram () const noexcept
 Get the histogram of the allocation sizes.
 
statsoperator= (stats &&)=default
 Default move assignment operator.
 
statsoperator= (stats const &)=delete
 Deleted copy assignment operator.
 
bool owns (blk_t b) const noexcept
 Check if a given nda::mem::blk_t memory block is owned by the base allocator.
 
void print_histogram (std::ostream &os) const
 Print the histogram to a std::ostream.
 

Static Public Attributes

static constexpr auto address_space = A::address_space
 nda::mem::AddressSpace in which the memory is allocated.
 

Member Function Documentation

◆ allocate()

template<Allocator A>
blk_t nda::mem::stats< A >::allocate ( uint64_t s)
inline

Allocate memory and update the histogram.

Parameters
sSize in bytes of the memory to allocate.
Returns
nda::mem::blk_t memory block.

Definition at line 607 of file allocators.hpp.

◆ allocate_zero()

template<Allocator A>
blk_t nda::mem::stats< A >::allocate_zero ( uint64_t s)
inline

Allocate memory, set it to zero and update the histogram.

Parameters
sSize in bytes of the memory to allocate.
Returns
nda::mem::blk_t memory block.

Definition at line 619 of file allocators.hpp.

◆ deallocate()

template<Allocator A>
void nda::mem::stats< A >::deallocate ( blk_t b)
inlinenoexcept

Deallocate memory.

Parameters
bnda::mem::blk_t memory block to deallocate.

Definition at line 629 of file allocators.hpp.

◆ histogram()

template<Allocator A>
auto const & nda::mem::stats< A >::histogram ( ) const
inlinenodiscardnoexcept

Get the histogram of the allocation sizes.

Returns
std::vector of size 65 with the number of allocations in each size range.

Definition at line 643 of file allocators.hpp.

◆ owns()

template<Allocator A>
bool nda::mem::stats< A >::owns ( blk_t b) const
inlinenodiscardnoexcept

Check if a given nda::mem::blk_t memory block is owned by the base allocator.

Parameters
bnda::mem::blk_t memory block.
Returns
True if the base allocator owns the memory block.

Definition at line 637 of file allocators.hpp.

◆ print_histogram()

template<Allocator A>
void nda::mem::stats< A >::print_histogram ( std::ostream & os) const
inline

Print the histogram to a std::ostream.

Parameters
osstd::ostream object to print to.

Definition at line 649 of file allocators.hpp.


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