KASKADE 7 development version
Public Member Functions | Protected Member Functions | List of all members
Kaskade::KallocUnlocked Class Reference

A class for local memory management. More...

#include <kalloc.hh>

Detailed Description

A class for local memory management.

Use this only locally, as it is not thread-safe. If unsure, use Kalloc.

Definition at line 186 of file kalloc.hh.

Inheritance diagram for Kaskade::KallocUnlocked:
Kaskade::Kalloc

Public Member Functions

 KallocUnlocked (int node_, int align_=64, size_t blocksize_=2 *1024 *1024, bool checking=true)
 Constructor. More...
 
void * alloc (size_t n)
 Allocates n bytes of memory. More...
 
void free (void *p, size_t n)
 Releases memory range. More...
 
void reserve (size_t n, size_t k)
 Tells the allocator that subsequently several blocks of the same size will be requested. More...
 
size_t alignment () const
 Reports the alignment size. More...
 
std::ostream & print (std::ostream &out) const
 Prints memory management statistics to the given stream. More...
 

Protected Member Functions

void * allocUnlocked (size_t n)
 Allocates n bytes of memory. More...
 
void freeUnlocked (void *p, size_t n)
 Releases memory range. More...
 

Constructor & Destructor Documentation

◆ KallocUnlocked()

Kaskade::KallocUnlocked::KallocUnlocked ( int  node_,
int  align_ = 64,
size_t  blocksize_ = 2*1024*1024,
bool  checking = true 
)
inline

Constructor.

Parameters
nodeThe NUMA node on which to allocate memory.
alignThe alignment of the memory to return. Has to be a power of 2, and significantly below blocksize. Defaults to common cache line size of 64 bytes.
blocksizeThe size of memory blocks to be requested from libnuma. Has to be a multiple of \( 4096 \). Defaults to 2^21, which is two MB.
checkingIf true, performs additional usage sanity checks for detecting memory management bugs.

Definition at line 196 of file kalloc.hh.

Member Function Documentation

◆ alignment()

size_t Kaskade::Kalloc::alignment ( ) const
inlineinherited

Reports the alignment size.

Definition at line 119 of file kalloc.hh.

◆ alloc()

void * Kaskade::KallocUnlocked::alloc ( size_t  n)
inline

Allocates n bytes of memory.

If n exceeds the alignment size, the returned memory range is guaranteed to be aligned as to the value specified on construction.

The method is NOT thread-safe.

Parameters
nrequested memory size in bytes.

Definition at line 208 of file kalloc.hh.

◆ allocUnlocked()

void * Kaskade::Kalloc::allocUnlocked ( size_t  n)
protectedinherited

Allocates n bytes of memory.

This method is NOT thread-safe. Use this only if you know exactly there's only one thread accessing the allocator.

Referenced by alloc().

◆ free()

void Kaskade::KallocUnlocked::free ( void *  p,
size_t  n 
)
inline

Releases memory range.

The method is NOT thread-safe.

Parameters
ppointer returned previously by alloc
nmemory size as requrested in the corresponding call to alloc

Definition at line 218 of file kalloc.hh.

◆ freeUnlocked()

void Kaskade::Kalloc::freeUnlocked ( void *  p,
size_t  n 
)
protectedinherited

Releases memory range.

This method is NOT thread-safe. Use this only if you know exactly there's only one thread accessing the allocator.

Referenced by free().

◆ print()

std::ostream & Kaskade::Kalloc::print ( std::ostream &  out) const
inherited

Prints memory management statistics to the given stream.

◆ reserve()

void Kaskade::Kalloc::reserve ( size_t  n,
size_t  k 
)
inherited

Tells the allocator that subsequently several blocks of the same size will be requested.

This is a hint to the allocator that can improve its performance.

Parameters
nthe size of the memory blocks to be requested
kthe number of the memory blocks to be requested

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