|
| | CArena (std::size_t hunk_size=0, ArenaInfo info=ArenaInfo()) |
| | Construct a coalescing memory manager.
|
| |
| | CArena (const CArena &rhs)=delete |
| |
| | CArena (CArena &&rhs)=delete |
| |
| CArena & | operator= (const CArena &rhs)=delete |
| |
| CArena & | operator= (CArena &&rhs)=delete |
| |
| | ~CArena () override |
| | The destructor.
|
| |
| void * | alloc (std::size_t nbytes) final |
| | Allocate some memory.
|
| |
| std::pair< void *, std::size_t > | alloc_in_place (void *pt, std::size_t szmin, std::size_t szmax) final |
| | Allocate memory in-place if possible.
|
| |
| void * | shrink_in_place (void *pt, std::size_t new_size) final |
| | Shrink allocation size in-place.
|
| |
| void | free (void *vp) final |
| | Free up allocated memory. Merge neighboring free memory chunks into largest possible chunk.
|
| |
| std::size_t | freeUnused () final |
| | Free unused memory back to the system. Return value is the amount of memory freed.
|
| |
| std::size_t | freeableMemory () const |
| | Return the amount of memory that can be released back to the heap.
|
| |
| std::size_t | largestFreeBlock () const final |
| | Return the largest free memory block already held by this CArena.
|
| |
| bool | hasFreeDeviceMemory (std::size_t sz) final |
| | 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.
|
| |
| std::size_t | heap_space_used () const noexcept |
| | The current amount of heap space used by the CArena object.
|
| |
| std::size_t | heap_space_actually_used () const noexcept |
| | Return the total amount of memory given out via alloc.
|
| |
| std::size_t | sizeOf (void *p) const noexcept |
| | Return the size of the allocation referenced by p (0 if unknown).
|
| |
| void | PrintUsage (std::string const &name, bool print_max_usage) const |
| | Print memory usage information of this arena.
|
| |
| void | PrintUsage (std::ostream &os, std::string const &name, std::string const &space) const |
| | Print memory usage information of this arena to a given output stream.
|
| |
| void | ResetMaxUsageCounter () final |
| | Reset the maximum usage counter.
|
| |
| 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 bool | isDeviceAccessible () const |
| |
| virtual bool | isHostAccessible () const |
| |
| virtual bool | isManaged () const |
| | Check whether it is managed GPU memory.
|
| |
| virtual bool | isDevice () const |
| | Check whether it is non-managed GPU device memory.
|
| |
| virtual bool | isPinned () const |
| | Check whether it is pinned host memory.
|
| |
| 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.
|
| |
| virtual bool | isStreamOrderedArena () const |
| | Is this GPU stream ordered memory allocator?
|
| |
| virtual void | streamOrderedFree (void *pt, gpuStream_t stream) |
| |
| const ArenaInfo & | arenaInfo () const |
| | Return the ArenaInfo object for querying.
|
| |
|
| std::vector< std::pair< void *, std::size_t > > | m_alloc |
| | The list of blocks allocated.
|
| |
| NL | m_freelist |
| | The free list of allocated but not currently used blocks. Maintained in lo to hi memory sorted order.
|
| |
| std::unordered_set< Node, Node::hash > | m_busylist |
| | The list of busy blocks. A block is either on the freelist or on the blocklist, but not on both.
|
| |
| std::size_t | m_hunk |
| | The minimal size of hunks to request from system.
|
| |
| std::size_t | m_used {0} |
| | The amount of heap space currently allocated.
|
| |
| std::size_t | m_max_used {0} |
| | The max amount of heap space currently allocated.
|
| |
| std::size_t | m_actually_used {0} |
| | The amount of memory given out via alloc().
|
| |
| std::size_t | m_max_actually_used {0} |
| | The max amount of memory given out via alloc().
|
| |
| std::mutex | carena_mutex |
| |
| ArenaInfo | arena_info |
| |
|
| 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 void | out_of_memory_abort (std::string const &memory_type, std::size_t nbytes, std::string const &error_msg) |
| |
Coalescing first-fit dynamic memory arena.
Allocates large hunks from the heap and sub-allocates from them on demand. Neighboring free blocks are merged on each free() call to reduce fragmentation.
| std::pair< void *, std::size_t > amrex::CArena::alloc_in_place |
( |
void * |
pt, |
|
|
std::size_t |
szmin, |
|
|
std::size_t |
szmax |
|
) |
| |
|
finalvirtual |
Allocate memory in-place if possible.
This function tries to allocate in-place by extending the capacity of an existing pointer. If it's possible to extend the given pointer to the minimum required size without performing a new allocation, this function will return the original pointer back along with the new size (which may be in the range of [szmin,szmax]); otherwise a new allocation is performed to allocate the maximum requested size.
Note that this function does NOT free the existing allocation, even when a new memory allocation is performed. So it's the caller's responsibility to free the original pointer when appropriate. A new allocation can be detected by comparing the returned pointer with the input pointer.
- Parameters
-
| pt | existing pointer |
| szmin | minimum required size in bytes |
| szmax | maximum requested size in bytes |
- Returns
- pair of pointer and allocation size in bytes
Reimplemented from amrex::Arena.