Block-Structured AMR Software Framework
Loading...
Searching...
No Matches
amrex::PArena Class Reference

This arena uses CUDA stream-ordered memory allocator if available. If not, use The_Arena(). More...

#include <AMReX_PArena.H>

Inheritance diagram for amrex::PArena:
amrex::Arena

Public Member Functions

 PArena (Long release_threshold)
 PArena (const PArena &rhs)=delete
 PArena (PArena &&rhs)=delete
PArena & operator= (const PArena &rhs)=delete
PArena & operator= (PArena &&rhs)=delete
 ~PArena () override
void * alloc (std::size_t nbytes) final
 Allocate sz bytes from this arena.
void free (void *p) final
 Free a previously allocated block pointed to by pt.
bool isDeviceAccessible () const final
bool isHostAccessible () const final
bool isManaged () const final
 Check whether it is managed GPU memory.
bool isDevice () const final
 Check whether it is non-managed GPU device memory.
bool isPinned () const final
 Check whether it is pinned host memory.
bool isStreamOrderedArena () const final
 Is this CUDA stream ordered memory allocator?
void streamOrderedFree (void *p, gpuStream_t stream) override
Public Member Functions inherited from amrex::Arena
virtual ~Arena ()=default
 Arena () noexcept=default
 Arena (const Arena &rhs)=delete
 Arena (Arena &&rhs)=delete
Arena & operator= (const Arena &rhs)=delete
Arena & operator= (Arena &&rhs)=delete
virtual std::pair< void *, std::size_t > alloc_in_place (void *pt, std::size_t szmin, std::size_t szmax)
 Allocate memory in-place if possible.
virtual void * shrink_in_place (void *pt, std::size_t sz)
 Shrink allocation size in-place.
virtual std::size_t freeUnused ()
 Release unused cached memory back to the system.
virtual std::size_t largestFreeBlock () const
 Return the largest free memory block already held by this Arena.
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.
void registerForProfiling (const std::string &memory_name)
 Add this Arena to the list of Arenas that are profiled by TinyProfiler.
void deregisterFromProfiling ()
 Remove this Arena from the list of Arenas that are profiled by TinyProfiler. This is equivalent to destructing and re-constructing the Arena.
const ArenaInfo & arenaInfo () const
 Return the ArenaInfo object for querying.
virtual void ResetMaxUsageCounter ()

Additional Inherited Members

Static Public Member Functions inherited from amrex::Arena
static std::size_t align (std::size_t sz)
 Return the smallest multiple of Arena::align_size that is >= sz bytes.
static void Initialize (bool minimal)
 Initialize the Arena subsystem (used internally by AMReX).
static void PrintUsage (bool print_max_usage=false)
 Print memory usage information of all arenas.
static void PrintUsageToStream (std::ostream &os, std::string const &space)
 Print memory usage information of all arenas to a given output stream.
static void PrintUsageToFiles (std::string const &filename, std::string const &message)
 Print memory usage information of all arenas to given file.
static void Finalize ()
 Used internally by amrex.
static bool IsInitialized ()
Static Public Attributes inherited from amrex::Arena
static const std::size_t align_size = 256
Protected Member Functions inherited from amrex::Arena
virtual std::size_t freeUnused_protected ()
void * allocate_system (std::size_t nbytes)
void deallocate_system (void *p, std::size_t nbytes)
Static Protected Member Functions inherited from amrex::Arena
static void throw_out_of_memory (std::string const &memory_type, std::size_t nbytes, std::string const &error_msg)
Protected Attributes inherited from amrex::Arena
ArenaInfo arena_info

Detailed Description

This arena uses CUDA stream-ordered memory allocator if available. If not, use The_Arena().

Constructor & Destructor Documentation

◆ PArena() [1/3]

amrex::PArena::PArena ( Long release_threshold)

◆ PArena() [2/3]

amrex::PArena::PArena ( const PArena & rhs)
delete

◆ PArena() [3/3]

amrex::PArena::PArena ( PArena && rhs)
delete

◆ ~PArena()

amrex::PArena::~PArena ( )
override

Member Function Documentation

◆ alloc()

void * amrex::PArena::alloc ( std::size_t sz)
nodiscardfinalvirtual

Allocate sz bytes from this arena.

Parameters
szNumber of bytes to allocate.
Returns
Pointer to the allocated memory.

Implements amrex::Arena.

◆ free()

void amrex::PArena::free ( void * pt)
finalvirtual

Free a previously allocated block pointed to by pt.

Implements amrex::Arena.

◆ isDevice()

bool amrex::PArena::isDevice ( ) const
nodiscardfinalvirtual

Check whether it is non-managed GPU device memory.

Note that isManaged, isDevice and isPinned are mutually exclusive. For memory allocated by cudaMalloc* etc. in GPU builds, one of them returns true. For CPU builds, they are always false.

Reimplemented from amrex::Arena.

◆ isDeviceAccessible()

bool amrex::PArena::isDeviceAccessible ( ) const
nodiscardfinalvirtual

Check whether the memory is accessible on the device. Note that isDeviceAccessible and isHostAccessible can both be true.

Reimplemented from amrex::Arena.

◆ isHostAccessible()

bool amrex::PArena::isHostAccessible ( ) const
nodiscardfinalvirtual

Check whether the memory is accessible on the host. Note that isDeviceAccessible and isHostAccessible can both be true.

Reimplemented from amrex::Arena.

◆ isManaged()

bool amrex::PArena::isManaged ( ) const
nodiscardfinalvirtual

Check whether it is managed GPU memory.

Note that isManaged, isDevice and isPinned are mutually exclusive. For memory allocated by cudaMalloc* etc. in GPU builds, one of them returns true. For CPU builds, they are always false.

Reimplemented from amrex::Arena.

◆ isPinned()

bool amrex::PArena::isPinned ( ) const
nodiscardfinalvirtual

Check whether it is pinned host memory.

Note that isManaged, isDevice and isPinned are mutually exclusive. For memory allocated by cudaMalloc* etc. in GPU builds, one of them returns true. For CPU builds, they are always false.

Reimplemented from amrex::Arena.

◆ isStreamOrderedArena()

bool amrex::PArena::isStreamOrderedArena ( ) const
inlinenodiscardfinalvirtual

Is this CUDA stream ordered memory allocator?

Reimplemented from amrex::Arena.

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ streamOrderedFree()

void amrex::PArena::streamOrderedFree ( void * p,
gpuStream_t stream )
overridevirtual

Reimplemented from amrex::Arena.


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