AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
memory_management.hpp File Reference
#include "axom/config.hpp"
#include "axom/core/Macros.hpp"
#include "axom/core/utilities/Utilities.hpp"
#include <cstring>
#include <cstdlib>
#include <cstddef>
#include <iostream>
#include <string>
#include <type_traits>

Classes

struct  axom::Allocator
 Wrapper type representing an Umpire allocator ID. More...
 

Namespaces

 axom
 
 axom::detail
 

Enumerations

enum class  axom::MemorySpace { axom::Malloc , axom::Dynamic }
 Memory spaces supported by Array-like types. More...
 

Functions

bool axom::isValidAllocatorID (int allocatorId) noexcept
 Returns whether allocatorId is a valid Axom allocator id. More...
 
template<MemorySpace SPACE>
int axom::detail::getAllocatorID ()
 Translates between the MemorySpace enum and Umpire allocator IDs. More...
 
template<>
int axom::detail::getAllocatorID< MemorySpace::Dynamic > ()
 
template<>
int axom::detail::getAllocatorID< MemorySpace::Malloc > ()
 
MemorySpace axom::detail::getAllocatorSpace (int allocatorId)
 Return the Axom MemorySpace for the given Axom allocator id. More...
 
bool axom::isDeviceAllocator (int AXOM_UNUSED_PARAM(allocator_id))
 Determines whether an allocator id is on device. More...
 
Memory Management Routines
void axom::setDefaultAllocator (int allocId)
 Sets the default memory allocator to use. More...
 
int axom::getDefaultAllocatorID ()
 Returns the ID of the current default Umpire allocator or MALLOC_ALLOCATOR_ID if Umpire is not used. More...
 
int axom::getAllocatorIDFromPointer (const void *ptr)
 Get the allocator id from which data has been allocated. More...
 
bool axom::isSharedMemoryAllocator (int allocID)
 Determines whether an allocator id is for shared memory. More...
 
int axom::getSharedMemoryAllocatorID (std::size_t minSegmentSize=0)
 Get the allocator ID for Axom's shared memory allocator. More...
 
template<typename T >
T * axom::allocate (std::size_t n, int allocID=getDefaultAllocatorID()) noexcept
 Allocates a chunk of memory of type T. More...
 
template<typename T >
T * axom::allocate (std::size_t n, const std::string &name, int allocID=getDefaultAllocatorID()) noexcept
 Allocates a chunk of memory of type T with a user-supplied allocation name. More...
 
template<typename T >
void axom::deallocate (T *&p) noexcept
 Frees the chunk of memory pointed to by the supplied pointer, p. More...
 
template<typename T >
T * axom::reallocate (T *p, std::size_t n, int allocID=getDefaultAllocatorID()) noexcept
 Reallocates the chunk of memory pointed to by the supplied pointer. More...
 
void axom::copy (void *dst, const void *src, std::size_t numbytes) noexcept
 Copies memory from the source to the destination. More...
 
template<typename T >
void axom::fill (void *dst, std::size_t n, const T &value) noexcept
 Fills memory with a value. More...
 

Variables

constexpr int axom::INVALID_ALLOCATOR_ID = -1
 Place holder for no/unknown allocator. More...
 
constexpr int axom::MALLOC_ALLOCATOR_ID = -3
 Refers to MemorySpace::Malloc. More...