MFEM v4.7.0
Finite element discretization library
Loading...
Searching...
No Matches
mfem::MemoryManager Class Reference

#include <mem_manager.hpp>

Public Member Functions

 MemoryManager ()
 
 ~MemoryManager ()
 
void Init ()
 Initialize the memory manager.
 
void Configure (const MemoryType h_mt, const MemoryType d_mt)
 Configure the Memory manager with given default host and device types. This method will be called when configuring a device.
 
void Destroy ()
 Free all the device memories.
 
bool IsKnown (const void *h_ptr)
 Return true if the pointer is known by the memory manager.
 
bool IsAlias (const void *h_ptr)
 Return true if the pointer is known by the memory manager as an alias.
 
void RegisterCheck (void *h_ptr)
 Check if the host pointer has been registered in the memory manager.
 
int PrintPtrs (std::ostream &out=mfem::out)
 
int PrintAliases (std::ostream &out=mfem::out)
 
 __attribute__ ((used)) inline static void *__enzyme_allocation_like1[4]
 
 __attribute__ ((used)) inline static void *__enzyme_allocation_like2[4]
 

Static Public Member Functions

static MemoryType GetDualMemoryType (MemoryType mt)
 Return the dual MemoryType of the given one, mt.
 
static void SetDualMemoryType (MemoryType mt, MemoryType dual_mt)
 Set the dual memory type of mt to be dual_mt.
 
static void SetUmpireHostAllocatorName (const char *h_name)
 Set the host Umpire allocator name used with MemoryType::HOST_UMPIRE.
 
static void SetUmpireDeviceAllocatorName (const char *d_name)
 Set the device Umpire allocator name used with MemoryType::DEVICE_UMPIRE.
 
static void SetUmpireDevice2AllocatorName (const char *d_name)
 Set the device Umpire allocator name used with MemoryType::DEVICE_UMPIRE_2.
 
static const char * GetUmpireHostAllocatorName ()
 Get the host Umpire allocator name used with MemoryType::HOST_UMPIRE.
 
static const char * GetUmpireDeviceAllocatorName ()
 Get the device Umpire allocator name used with MemoryType::DEVICE_UMPIRE.
 
static const char * GetUmpireDevice2AllocatorName ()
 Get the device Umpire allocator name used with MemoryType::DEVICE_UMPIRE_2.
 
static MemoryType GetHostMemoryType ()
 
static MemoryType GetDeviceMemoryType ()
 
static void myfree (void *mem, MemoryType MT, unsigned &flags)
 

Friends

template<typename T >
class Memory
 

Detailed Description

The MFEM memory manager class. Host-side pointers are inserted into this manager which keeps track of the associated device pointer, and where the data currently resides.

Definition at line 604 of file mem_manager.hpp.

Constructor & Destructor Documentation

◆ MemoryManager()

mfem::MemoryManager::MemoryManager ( )

Definition at line 1537 of file mem_manager.cpp.

◆ ~MemoryManager()

mfem::MemoryManager::~MemoryManager ( )

Definition at line 1539 of file mem_manager.cpp.

Member Function Documentation

◆ __attribute__() [1/2]

mfem::MemoryManager::__attribute__ ( (used) )

◆ __attribute__() [2/2]

mfem::MemoryManager::__attribute__ ( (used) )

◆ Configure()

void mfem::MemoryManager::Configure ( const MemoryType h_mt,
const MemoryType d_mt )

Configure the Memory manager with given default host and device types. This method will be called when configuring a device.

The host and device MemoryTypes, h_mt and d_mt, are set to be dual to each other.

Definition at line 1572 of file mem_manager.cpp.

◆ Destroy()

void mfem::MemoryManager::Destroy ( )

Free all the device memories.

Definition at line 1591 of file mem_manager.cpp.

◆ GetDeviceMemoryType()

static MemoryType mfem::MemoryManager::GetDeviceMemoryType ( )
inlinestatic

Definition at line 859 of file mem_manager.hpp.

◆ GetDualMemoryType()

static MemoryType mfem::MemoryManager::GetDualMemoryType ( MemoryType mt)
inlinestatic

Return the dual MemoryType of the given one, mt.

The default dual memory types are:

memory type dual type
HOST DEVICE
HOST_32 DEVICE
HOST_64 DEVICE
HOST_DEBUG DEVICE_DEBUG
HOST_UMPIRE DEVICE_UMPIRE
HOST_PINNED DEVICE
MANAGED MANAGED
DEVICE HOST
DEVICE_DEBUG HOST_DEBUG
DEVICE_UMPIRE HOST_UMPIRE
DEVICE_UMPIRE_2 HOST_UMPIRE

The dual types can be modified before device configuration using the method SetDualMemoryType() or by calling Device::SetMemoryTypes().

Definition at line 802 of file mem_manager.hpp.

◆ GetHostMemoryType()

static MemoryType mfem::MemoryManager::GetHostMemoryType ( )
inlinestatic

Definition at line 858 of file mem_manager.hpp.

◆ GetUmpireDevice2AllocatorName()

static const char * mfem::MemoryManager::GetUmpireDevice2AllocatorName ( )
inlinestatic

Get the device Umpire allocator name used with MemoryType::DEVICE_UMPIRE_2.

Definition at line 835 of file mem_manager.hpp.

◆ GetUmpireDeviceAllocatorName()

static const char * mfem::MemoryManager::GetUmpireDeviceAllocatorName ( )
inlinestatic

Get the device Umpire allocator name used with MemoryType::DEVICE_UMPIRE.

Definition at line 833 of file mem_manager.hpp.

◆ GetUmpireHostAllocatorName()

static const char * mfem::MemoryManager::GetUmpireHostAllocatorName ( )
inlinestatic

Get the host Umpire allocator name used with MemoryType::HOST_UMPIRE.

Definition at line 831 of file mem_manager.hpp.

◆ Init()

void mfem::MemoryManager::Init ( )

Initialize the memory manager.

Definition at line 1528 of file mem_manager.cpp.

◆ IsAlias()

bool mfem::MemoryManager::IsAlias ( const void * h_ptr)
inline

Return true if the pointer is known by the memory manager as an alias.

Definition at line 845 of file mem_manager.hpp.

◆ IsKnown()

bool mfem::MemoryManager::IsKnown ( const void * h_ptr)
inline

Return true if the pointer is known by the memory manager.

Definition at line 842 of file mem_manager.hpp.

◆ myfree()

static void mfem::MemoryManager::myfree ( void * mem,
MemoryType MT,
unsigned & flags )
inlinestatic

Definition at line 862 of file mem_manager.hpp.

◆ PrintAliases()

int mfem::MemoryManager::PrintAliases ( std::ostream & out = mfem::out)

Prints all aliases known by the memory manager returning the number of printed pointers

Definition at line 1652 of file mem_manager.cpp.

◆ PrintPtrs()

int mfem::MemoryManager::PrintPtrs ( std::ostream & out = mfem::out)

Prints all pointers known by the memory manager, returning the number of printed pointers

Definition at line 1637 of file mem_manager.cpp.

◆ RegisterCheck()

void mfem::MemoryManager::RegisterCheck ( void * h_ptr)

Check if the host pointer has been registered in the memory manager.

Definition at line 1626 of file mem_manager.cpp.

◆ SetDualMemoryType()

void mfem::MemoryManager::SetDualMemoryType ( MemoryType mt,
MemoryType dual_mt )
static

Set the dual memory type of mt to be dual_mt.

This method can only be called before configuration, i.e. before calling Configure(), which is typically done during Device construction.

One of the types must be a host MemoryType and the other must be a device MemoryType or both types must be the same host memory type. The latter case is only allowed for convenience in setting up pure host execution, so the actual dual is not updated.

Definition at line 1541 of file mem_manager.cpp.

◆ SetUmpireDevice2AllocatorName()

static void mfem::MemoryManager::SetUmpireDevice2AllocatorName ( const char * d_name)
inlinestatic

Set the device Umpire allocator name used with MemoryType::DEVICE_UMPIRE_2.

Definition at line 828 of file mem_manager.hpp.

◆ SetUmpireDeviceAllocatorName()

static void mfem::MemoryManager::SetUmpireDeviceAllocatorName ( const char * d_name)
inlinestatic

Set the device Umpire allocator name used with MemoryType::DEVICE_UMPIRE.

Definition at line 826 of file mem_manager.hpp.

◆ SetUmpireHostAllocatorName()

static void mfem::MemoryManager::SetUmpireHostAllocatorName ( const char * h_name)
inlinestatic

Set the host Umpire allocator name used with MemoryType::HOST_UMPIRE.

Definition at line 824 of file mem_manager.hpp.

Friends And Related Symbol Documentation

◆ Memory

template<typename T >
friend class Memory
friend

Definition at line 611 of file mem_manager.hpp.


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