Block-Structured AMR Software Framework
amrex::Arena Class Referenceabstract

A virtual base class for objects that manage their own dynamic memory allocation. More...

#include <AMReX_Arena.H>

Inheritance diagram for amrex::Arena:
amrex::BArena amrex::CArena amrex::PArena amrex::detail::SingleChunkArena

Classes

struct  ArenaProfiler
 

Public Member Functions

virtual ~Arena ()=default
 
 Arena () noexcept=default
 
 Arena (const Arena &rhs)=delete
 
 Arena (Arena &&rhs)=delete
 
Arenaoperator= (const Arena &rhs)=delete
 
Arenaoperator= (Arena &&rhs)=delete
 
virtual void * alloc (std::size_t sz)=0
 
virtual std::pair< void *, std::size_t > alloc_in_place (void *, std::size_t, std::size_t szmax)
 
virtual void * shrink_in_place (void *, std::size_t sz)
 
virtual void free (void *pt)=0
 A pure virtual function for deleting the arena pointed to by pt. More...
 
virtual std::size_t freeUnused ()
 Free unused memory back to the system. Return value is the amount memory freed. More...
 
virtual bool isDeviceAccessible () const
 
virtual bool isHostAccessible () const
 
virtual bool isManaged () const
 
virtual bool isDevice () const
 
virtual bool isPinned () const
 
virtual bool hasFreeDeviceMemory (std::size_t sz)
 Does the device have enough free memory for allocating this much memory? For CPU builds, this always return true. This is not a const function because it may attempt to release memory back to the system. More...
 
void registerForProfiling (const std::string &memory_name)
 Add this Arena to the list of Arenas that are profiled by TinyProfiler. More...
 
virtual bool isStreamOrderedArena () const
 Is this GPU stream ordered memory allocator? More...
 
const ArenaInfoarenaInfo () const
 Return the ArenaInfo object for querying. More...
 

Static Public Member Functions

static std::size_t align (std::size_t sz)
 Given a minimum required arena size of sz bytes, this returns the next largest arena size that will align to align_size bytes. More...
 
static void Initialize ()
 
static void PrintUsage ()
 
static void PrintUsageToFiles (std::string const &filename, std::string const &message)
 
static void Finalize ()
 

Static Public Attributes

static const std::size_t align_size = 16
 

Protected Member Functions

virtual std::size_t freeUnused_protected ()
 
void * allocate_system (std::size_t nbytes)
 
void deallocate_system (void *p, std::size_t nbytes)
 

Protected Attributes

ArenaInfo arena_info
 
struct amrex::Arena::ArenaProfiler m_profiler
 

Detailed Description

A virtual base class for objects that manage their own dynamic memory allocation.

Constructor & Destructor Documentation

◆ ~Arena()

virtual amrex::Arena::~Arena ( )
virtualdefault

◆ Arena() [1/3]

amrex::Arena::Arena ( )
defaultnoexcept

◆ Arena() [2/3]

amrex::Arena::Arena ( const Arena rhs)
delete

◆ Arena() [3/3]

amrex::Arena::Arena ( Arena &&  rhs)
delete

Member Function Documentation

◆ align()

std::size_t amrex::Arena::align ( std::size_t  sz)
static

Given a minimum required arena size of sz bytes, this returns the next largest arena size that will align to align_size bytes.

◆ alloc()

virtual void* amrex::Arena::alloc ( std::size_t  sz)
pure virtual

Allocate a dynamic memory arena

Parameters
szsize of the memory request
Returns
a pointer to the allocated memory

Implemented in amrex::detail::SingleChunkArena, amrex::BArena, amrex::PArena, and amrex::CArena.

◆ alloc_in_place()

virtual std::pair<void*,std::size_t> amrex::Arena::alloc_in_place ( void *  ,
std::size_t  ,
std::size_t  szmax 
)
inlinevirtual

Try to allocate in-place by extending the capacity of given pointer.

Reimplemented in amrex::CArena.

◆ allocate_system()

void * amrex::Arena::allocate_system ( std::size_t  nbytes)
protected

◆ arenaInfo()

const ArenaInfo& amrex::Arena::arenaInfo ( ) const
inline

Return the ArenaInfo object for querying.

◆ deallocate_system()

void amrex::Arena::deallocate_system ( void *  p,
std::size_t  nbytes 
)
protected

◆ Finalize()

void amrex::Arena::Finalize ( )
static

◆ free()

virtual void amrex::Arena::free ( void *  pt)
pure virtual

A pure virtual function for deleting the arena pointed to by pt.

Implemented in amrex::CArena, amrex::detail::SingleChunkArena, amrex::BArena, and amrex::PArena.

◆ freeUnused()

virtual std::size_t amrex::Arena::freeUnused ( )
inlinevirtual

Free unused memory back to the system. Return value is the amount memory freed.

Reimplemented in amrex::CArena.

◆ freeUnused_protected()

virtual std::size_t amrex::Arena::freeUnused_protected ( )
inlineprotectedvirtual

Reimplemented in amrex::CArena.

◆ hasFreeDeviceMemory()

bool amrex::Arena::hasFreeDeviceMemory ( std::size_t  sz)
virtual

Does the device have enough free memory for allocating this much memory? For CPU builds, this always return true. This is not a const function because it may attempt to release memory back to the system.

Reimplemented in amrex::CArena.

◆ Initialize()

void amrex::Arena::Initialize ( )
static

◆ isDevice()

bool amrex::Arena::isDevice ( ) const
virtual

◆ isDeviceAccessible()

bool amrex::Arena::isDeviceAccessible ( ) const
virtual

◆ isHostAccessible()

bool amrex::Arena::isHostAccessible ( ) const
virtual

◆ isManaged()

bool amrex::Arena::isManaged ( ) const
virtual

◆ isPinned()

bool amrex::Arena::isPinned ( ) const
virtual

◆ isStreamOrderedArena()

virtual bool amrex::Arena::isStreamOrderedArena ( ) const
inlinevirtual

Is this GPU stream ordered memory allocator?

Reimplemented in amrex::PArena.

◆ operator=() [1/2]

Arena& amrex::Arena::operator= ( Arena &&  rhs)
delete

◆ operator=() [2/2]

Arena& amrex::Arena::operator= ( const Arena rhs)
delete

◆ PrintUsage()

void amrex::Arena::PrintUsage ( )
static

◆ PrintUsageToFiles()

void amrex::Arena::PrintUsageToFiles ( std::string const &  filename,
std::string const &  message 
)
static

◆ registerForProfiling()

void amrex::Arena::registerForProfiling ( const std::string &  memory_name)

Add this Arena to the list of Arenas that are profiled by TinyProfiler.

Parameters
memory_nameThe name of this arena in the TinyProfiler output.

◆ shrink_in_place()

virtual void* amrex::Arena::shrink_in_place ( void *  ,
std::size_t  sz 
)
inlinevirtual

Try to shrink in-place

Reimplemented in amrex::CArena.

Member Data Documentation

◆ align_size

const std::size_t amrex::Arena::align_size = 16
static

◆ arena_info

ArenaInfo amrex::Arena::arena_info
protected

◆ m_profiler

struct amrex::Arena::ArenaProfiler amrex::Arena::m_profiler
protected

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