12#ifndef MFEM_MEM_MANAGER_HPP
13#define MFEM_MEM_MANAGER_HPP
25#include <HYPRE_utilities.h>
26#if (21400 <= MFEM_HYPRE_VERSION) && (MFEM_HYPRE_VERSION < 21900)
27#include <_hypre_utilities.h>
230 if (
this == &other) {
return *
this; }
260 explicit Memory(T *ptr,
int size,
bool own) {
Wrap(ptr, size, own); }
271 {
Wrap(ptr, size, mt, own); }
342 inline void New(
int size);
372 inline void Wrap(T *ptr,
int size,
bool own);
409 bool valid_host =
false,
bool valid_device =
true);
454 inline operator T*();
461 inline operator const T*()
const;
476 template <
typename U>
477 inline explicit operator U*();
487 template <
typename U>
488 inline explicit operator const U*()
const;
574 static constexpr std::size_t def_align_bytes_()
577 return alignof(max_align_t);
579 static constexpr std::size_t def_align_bytes = def_align_bytes_();
580 static constexpr std::size_t new_align_bytes =
581 alignof(T) > def_align_bytes ?
alignof(T) : def_align_bytes;
583 template <std::
size_t align_
bytes,
bool dummy = true>
struct Alloc
585#if __cplusplus < 201703L
586 static inline T *New(std::size_t)
589 MFEM_ASSERT(
false,
"overaligned type cannot use MemoryType::HOST");
593 static inline T *New(std::size_t size) {
return new T[size]; }
597#if __cplusplus < 201703L
598 template<
bool dummy>
struct Alloc<def_align_bytes,dummy>
600 static inline T *New(std::size_t size) {
return new T[size]; }
605 static inline T *NewHOST(std::size_t size)
607 return Alloc<new_align_bytes>::New(size);
631 template <
typename T>
friend class Memory;
634 MFEM_ENZYME_INACTIVE
static MemoryType host_mem_type;
637 MFEM_ENZYME_INACTIVE
static MemoryType device_mem_type;
640 MFEM_ENZYME_INACTIVE
static bool exists;
643 static bool Exists() {
return exists; }
654 MFEM_ENZYME_INACTIVE
static bool configured;
657#ifdef MFEM_USE_UMPIRE
658 static const char * h_umpire_name;
659 static const char * d_umpire_name;
660 static const char * d_umpire_2_name;
668 static void *New_(
void *h_tmp,
size_t bytes,
MemoryType mt,
unsigned &flags);
670 static void *New_(
void *h_tmp,
size_t bytes,
MemoryType h_mt,
671 MemoryType d_mt,
unsigned valid_flags,
unsigned &flags);
675 MFEM_ENZYME_INACTIVE
static void *Register_(
void *ptr,
void *h_ptr,
677 bool own,
bool alias,
unsigned &flags);
680 static void Register2_(
void *h_ptr,
void *d_ptr,
size_t bytes,
682 bool own,
bool alias,
unsigned &flags,
683 unsigned valid_flags);
686 static void Alias_(
void *base_h_ptr,
size_t offset,
size_t bytes,
687 unsigned base_flags,
unsigned &flags);
689 static void SetDeviceMemoryType_(
void *h_ptr,
unsigned flags,
693 MFEM_ENZYME_FN_LIKE_FREE
static void Delete_(
void *h_ptr,
MemoryType mt,
697 static void DeleteDevice_(
void *h_ptr,
unsigned & flags);
700 static bool MemoryClassCheck_(
MemoryClass mc,
void *h_ptr,
701 MemoryType h_mt,
size_t bytes,
unsigned flags);
705 MFEM_ENZYME_FN_LIKE_DYNCAST
static void *ReadWrite_(
void *h_ptr,
707 size_t bytes,
unsigned &flags);
709 MFEM_ENZYME_FN_LIKE_DYNCAST
static const void *Read_(
void *h_ptr,
711 size_t bytes,
unsigned &flags);
713 MFEM_ENZYME_FN_LIKE_DYNCAST
static void *Write_(
void *h_ptr,
MemoryType h_mt,
715 size_t bytes,
unsigned &flags);
717 static void SyncAlias_(
const void *base_h_ptr,
void *alias_h_ptr,
718 size_t alias_bytes,
unsigned base_flags,
719 unsigned &alias_flags);
723 MFEM_ENZYME_INACTIVE
static MemoryType GetDeviceMemoryType_(
void *h_ptr,
727 MFEM_ENZYME_INACTIVE
static MemoryType GetHostMemoryType_(
void *h_ptr);
730 static void CheckHostMemoryType_(
MemoryType h_mt,
void *h_ptr,
bool alias);
734 static void Copy_(
void *dest_h_ptr,
const void *src_h_ptr,
size_t bytes,
735 unsigned src_flags,
unsigned &dest_flags);
739 static void CopyToHost_(
void *dest_h_ptr,
const void *src_h_ptr,
740 size_t bytes,
unsigned src_flags);
744 static void CopyFromHost_(
void *dest_h_ptr,
const void *src_h_ptr,
745 size_t bytes,
unsigned &dest_flags);
748 static bool IsKnown_(
const void *h_ptr);
752 static bool IsAlias_(
const void *h_ptr);
755 static int CompareHostAndDevice_(
void *h_ptr,
size_t size,
unsigned flags);
764 void InsertDevice(
void *d_ptr,
void *h_ptr,
size_t bytes,
768 void InsertAlias(
const void *base_ptr,
void *alias_ptr,
769 const size_t bytes,
const bool base_is_alias);
772 void Erase(
void *h_ptr,
bool free_dev_ptr =
true);
775 void EraseDevice(
void *h_ptr);
778 void EraseAlias(
void *alias_ptr);
782 void *GetDevicePtr(
const void *h_ptr,
size_t bytes,
bool copy_data);
786 void *GetAliasDevicePtr(
const void *alias_ptr,
size_t bytes,
bool copy_data);
790 void *GetHostPtr(
const void *d_ptr,
size_t bytes,
bool copy_data);
794 void *GetAliasHostPtr(
const void *alias_ptr,
size_t bytes,
bool copy_data);
823 {
return dual_map[(int)mt]; }
842#ifdef MFEM_USE_UMPIRE
862 bool IsKnown(
const void *h_ptr) {
return IsKnown_(h_ptr); }
865 bool IsAlias(
const void *h_ptr) {
return IsAlias_(h_ptr); }
868 void RegisterCheck(
void *h_ptr);
872 int PrintPtrs(std::ostream &out =
mfem::out);
876 int PrintAliases(std::ostream &out =
mfem::out);
881#ifdef MFEM_USE_ENZYME
884 MemoryManager::Delete_(mem, MT, flags);
887 inline static void* __enzyme_allocation_like1[4] = {(
void*)
static_cast<void*(*)(
void*,
size_t,
MemoryType,
unsigned&)
>(MemoryManager::New_),
888 (
void*)1, (
void*)
"-1,2,3", (
void*)myfree
891 inline static void* __enzyme_allocation_like2[4] = {(
void*)
static_cast<void*(*)(
void*,
size_t,
MemoryType,
MemoryType,
unsigned,
unsigned&)
>(MemoryManager::New_),
892 (
void*)1, (
void*)
"-1,2,4", (
void*)MemoryManager::Delete_
900#if MFEM_HYPRE_VERSION < 21400
901#define HYPRE_MEMORY_DEVICE (0)
902#define HYPRE_MEMORY_HOST (1)
904#if MFEM_HYPRE_VERSION < 21900
911#if !defined(HYPRE_USING_GPU)
912 return HYPRE_MEMORY_HOST;
913#elif MFEM_HYPRE_VERSION < 23100
914 return HYPRE_MEMORY_DEVICE;
916 if (!HYPRE_Initialized()) {
return HYPRE_MEMORY_HOST; }
918 HYPRE_GetMemoryLocation(&loc);
926#if !defined(HYPRE_USING_GPU)
928#elif MFEM_HYPRE_VERSION < 23100
962 flags = OWNS_HOST | VALID_HOST;
965 (T*)MemoryManager::New_(
nullptr, size*
sizeof(T), h_mt, flags);
972 const size_t bytes = size*
sizeof(T);
974 if (mt_host) { flags = OWNS_HOST | VALID_HOST; }
977 h_ptr = (mt_host) ? h_tmp : (T*)MemoryManager::New_(h_tmp, bytes, mt, flags);
984 const size_t bytes = size*
sizeof(T);
985 this->h_mt = host_mt;
987 h_ptr = (T*)MemoryManager::New_(h_tmp, bytes, host_mt, device_mt,
996 flags = (own ? OWNS_HOST : 0) | VALID_HOST;
999 if (own && MemoryManager::Exists())
1001 MemoryType h_ptr_mt = MemoryManager::GetHostMemoryType_(h_ptr);
1002 MFEM_VERIFY(h_mt == h_ptr_mt,
1003 "h_mt = " << (
int)h_mt <<
", h_ptr_mt = " << (
int)h_ptr_mt);
1008 const size_t bytes = size*
sizeof(T);
1009 MemoryManager::Register_(ptr, ptr, bytes, h_mt, own,
false, flags);
1013template <
typename T>
1024 flags = (own ? OWNS_HOST : 0) | VALID_HOST;
1034 h_ptr = (T*)MemoryManager::Register_(ptr, h_ptr, size*
sizeof(T), mt,
1038template <
typename T>
1040 bool own,
bool valid_host,
bool valid_device)
1047 MFEM_ASSERT(valid_host || valid_device,
"");
1048 const size_t bytes = size*
sizeof(T);
1050 MemoryManager::Register2_(h_ptr, d_ptr, bytes, h_mt, d_mt,
1052 valid_host*VALID_HOST|valid_device*VALID_DEVICE);
1055template <
typename T>
1058 MFEM_ASSERT(0 <= offset,
"invalid offset = " << offset);
1059 MFEM_ASSERT(0 <= size,
"invalid size = " << size);
1060 MFEM_ASSERT(offset + size <= base.
capacity,
1061 "invalid offset + size = " << offset + size
1062 <<
" > base capacity = " << base.
capacity);
1065 h_ptr = base.
h_ptr + offset;
1066 if (!(base.
flags & Registered))
1069#
if !defined(HYPRE_USING_GPU)
1073#elif MFEM_HYPRE_VERSION < 23100
1076 MemoryManager::Exists()
1084 MemoryManager::Register_(base.
h_ptr,
nullptr, base.
capacity*
sizeof(T),
1092 flags = (base.
flags | ALIAS) & ~(OWNS_HOST | OWNS_DEVICE);
1096 const size_t s_bytes = size*
sizeof(T);
1097 const size_t o_bytes = offset*
sizeof(T);
1098 MemoryManager::Alias_(base.
h_ptr, o_bytes, s_bytes, base.
flags, flags);
1101template <
typename T>
1105 if (!(flags & Registered))
1107 MemoryManager::Register_(h_ptr,
nullptr, capacity*
sizeof(T), h_mt,
1108 flags & OWNS_HOST, flags & ALIAS, flags);
1110 MemoryManager::SetDeviceMemoryType_(h_ptr, flags, d_mt);
1113template <
typename T>
1116 const bool registered = flags & Registered;
1118 const bool std_delete = !registered && mt_host;
1122 MemoryManager::Delete_((
void*)h_ptr, h_mt, flags);
1127 if (flags & OWNS_HOST) {
delete [] h_ptr; }
1132template <
typename T>
1135 if (flags & Registered)
1138 MemoryManager::DeleteDevice_((
void*)h_ptr, flags);
1142template <
typename T>
1145 MFEM_ASSERT((flags & VALID_HOST) && !(flags & VALID_DEVICE),
1146 "invalid host pointer access");
1150template <
typename T>
1153 MFEM_ASSERT((flags & VALID_HOST),
"invalid host pointer access");
1157template <
typename T>
1160 MFEM_ASSERT(Empty() ||
1161 ((flags & VALID_HOST) &&
1162 (std::is_const<T>::value || !(flags & VALID_DEVICE))),
1163 "invalid host pointer access");
1167template <
typename T>
1170 MFEM_ASSERT(Empty() || (flags & VALID_HOST),
"invalid host pointer access");
1174template <
typename T>
template <
typename U>
1177 MFEM_ASSERT(Empty() ||
1178 ((flags & VALID_HOST) &&
1179 (std::is_const<U>::value || !(flags & VALID_DEVICE))),
1180 "invalid host pointer access");
1181 return reinterpret_cast<U*
>(h_ptr);
1184template <
typename T>
template <
typename U>
1187 MFEM_ASSERT(Empty() || (flags & VALID_HOST),
"invalid host pointer access");
1188 return reinterpret_cast<U*
>(h_ptr);
1191template <
typename T>
1194 const size_t bytes = size *
sizeof(T);
1195 if (!(flags & Registered))
1198 MemoryManager::Register_(h_ptr,
nullptr, capacity*
sizeof(T), h_mt,
1199 flags & OWNS_HOST, flags & ALIAS, flags);
1201 return (T*)MemoryManager::ReadWrite_(h_ptr, h_mt, mc, bytes, flags);
1204template <
typename T>
1207 const size_t bytes = size *
sizeof(T);
1208 if (!(flags & Registered))
1211 MemoryManager::Register_(h_ptr,
nullptr, capacity*
sizeof(T), h_mt,
1212 flags & OWNS_HOST, flags & ALIAS, flags);
1214 return (
const T*)MemoryManager::Read_(h_ptr, h_mt, mc, bytes, flags);
1217template <
typename T>
1220 const size_t bytes = size *
sizeof(T);
1221 if (!(flags & Registered))
1224 MemoryManager::Register_(h_ptr,
nullptr, capacity*
sizeof(T), h_mt,
1225 flags & OWNS_HOST, flags & ALIAS, flags);
1227 return (T*)MemoryManager::Write_(h_ptr, h_mt, mc, bytes, flags);
1230template <
typename T>
1233 if (!(flags & Registered) && (other.
flags & Registered))
1235 MFEM_ASSERT(h_ptr == other.
h_ptr &&
1236 (flags & ALIAS) == (other.
flags & ALIAS),
1238 flags = (flags | Registered) & ~(OWNS_DEVICE | OWNS_INTERNAL);
1240 flags = (flags & ~(VALID_HOST | VALID_DEVICE)) |
1241 (other.
flags & (VALID_HOST | VALID_DEVICE));
1244template <
typename T>
1248 MFEM_ASSERT(!(flags & Registered) || (base.
flags & Registered),
1249 "invalid base state");
1250 if (!(base.
flags & Registered)) {
return; }
1251 MemoryManager::SyncAlias_(base.
h_ptr, h_ptr, alias_size*
sizeof(T),
1255template <
typename T>
1258 if (h_ptr ==
nullptr || !(flags & VALID_DEVICE)) {
return h_mt; }
1259 return MemoryManager::GetDeviceMemoryType_(h_ptr, flags & ALIAS);
1262template <
typename T>
1266 return MemoryManager::GetDeviceMemoryType_(h_ptr, flags & ALIAS);
1269template <
typename T>
1272 return flags & VALID_HOST ? true :
false;
1275template <
typename T>
1278 return flags & VALID_DEVICE ? true :
false;
1281template <
typename T>
1284 MFEM_VERIFY(src.
capacity>=size && capacity>=size,
"Incorrect size");
1285 if (size <= 0) {
return; }
1286 if (!(flags & Registered) && !(src.
flags & Registered))
1288 if (h_ptr != src.
h_ptr)
1290 MFEM_ASSERT(h_ptr + size <= src.
h_ptr || src.
h_ptr + size <= h_ptr,
1292 std::memcpy(h_ptr, src, size*
sizeof(T));
1298 MemoryManager::Copy_(h_ptr, src.
h_ptr, size*
sizeof(T), src.
flags, flags);
1302template <
typename T>
1305 MFEM_VERIFY(capacity>=size,
"Incorrect size");
1306 if (size <= 0) {
return; }
1307 if (!(flags & Registered))
1311 MFEM_ASSERT(h_ptr + size <= src || src + size <= h_ptr,
1313 std::memcpy(h_ptr, src, size*
sizeof(T));
1319 MemoryManager::CopyFromHost_(h_ptr, src, size*
sizeof(T), flags);
1323template <
typename T>
1329template <
typename T>
1332 MFEM_VERIFY(capacity>=size,
"Incorrect size");
1333 if (size <= 0) {
return; }
1334 if (!(flags & Registered))
1338 MFEM_ASSERT(h_ptr + size <= dest || dest + size <= h_ptr,
1340 std::memcpy(dest, h_ptr, size*
sizeof(T));
1345 MemoryManager::CopyToHost_(dest, h_ptr, size*
sizeof(T), flags);
1355template <
typename T>
1361template <
typename T>
1364 if (!(flags & VALID_HOST) || !(flags & VALID_DEVICE)) {
return 0; }
1365 return MemoryManager::CompareHostAndDevice_(h_ptr, size*
sizeof(T), flags);
A class to initialize the size of a Tensor.
bool IsKnown(const void *h_ptr)
Return true if the pointer is known by the memory manager.
static void SetUmpireDeviceAllocatorName(const char *d_name)
Set the device Umpire allocator name used with MemoryType::DEVICE_UMPIRE.
static void myfree(void *mem, MemoryType MT, unsigned &flags)
static const char * GetUmpireHostAllocatorName()
Get the host Umpire allocator name used with MemoryType::HOST_UMPIRE.
static void SetUmpireHostAllocatorName(const char *h_name)
Set the host Umpire allocator name used with MemoryType::HOST_UMPIRE.
static MemoryType GetHostMemoryType()
bool IsAlias(const void *h_ptr)
Return true if the pointer is known by the memory manager as an alias.
static const char * GetUmpireDevice2AllocatorName()
Get the device Umpire allocator name used with MemoryType::DEVICE_UMPIRE_2.
static void SetUmpireDevice2AllocatorName(const char *d_name)
Set the device Umpire allocator name used with MemoryType::DEVICE_UMPIRE_2.
static MemoryType GetDeviceMemoryType()
static MemoryType GetDualMemoryType(MemoryType mt)
Return the dual MemoryType of the given one, mt.
__attribute__((used)) inline static void *__enzyme_allocation_like2[4]
static const char * GetUmpireDeviceAllocatorName()
Get the device Umpire allocator name used with MemoryType::DEVICE_UMPIRE.
__attribute__((used)) inline static void *__enzyme_allocation_like1[4]
Class used by MFEM to store pointers to host and/or device memory.
void SetHostPtrOwner(bool own) const
Set/clear the ownership flag for the host pointer. Ownership indicates whether the pointer will be de...
void New(int size, MemoryType mt)
Allocate memory for size entries with the given MemoryType.
bool OwnsDevicePtr() const
Return true if the device pointer is owned. Ownership indicates whether the pointer will be deleted b...
T * Write(MemoryClass mc, int size)
Get write-only access to the memory with the given MemoryClass.
Memory(int size, MemoryType mt)
Allocate memory for size entries with the given MemoryType mt.
void Wrap(T *ptr, int size, MemoryType mt, bool own)
Wrap an externally allocated pointer, ptr, of the given MemoryType.
Memory(const Memory &base, int offset, int size)
Alias constructor. Create a Memory object that points inside the Memory object base.
MemoryType GetHostMemoryType() const
Return the host MemoryType of the Memory object.
bool DeviceIsValid() const
Return true if device pointer is valid.
Memory(int size, MemoryType h_mt, MemoryType d_mt)
Allocate memory for size entries with the given host MemoryType h_mt and device MemoryType d_mt.
void SetDeviceMemoryType(MemoryType d_mt)
Set the device MemoryType to be used by the Memory object.
void SetDevicePtrOwner(bool own) const
Set/clear the ownership flag for the device pointer. Ownership indicates whether the pointer will be ...
Memory(const Memory &)=default
Copy constructor: default.
int Capacity() const
Return the size of the allocated memory.
void CopyFromHost(const T *src, int size)
Copy size entries from the host pointer src to *this.
T & operator[](int idx)
Array subscript operator for host memory.
void Swap(Memory &other)
Swap without using move assignment, avoiding Reset() calls.
void New(int size, MemoryType h_mt, MemoryType d_mt)
Allocate memory for size entries with the given host MemoryType h_mt and device MemoryType d_mt.
@ OWNS_INTERNAL
Ownership flag for internal Memory data.
@ VALID_HOST
Host pointer is valid.
@ OWNS_HOST
The host pointer will be deleted by Delete()
@ VALID_DEVICE
Device pointer is valid
@ ALIAS
Pointer is an alias.
MemoryType GetDeviceMemoryType() const
Return the device MemoryType of the Memory object. If the device MemoryType is not set,...
T * ReadWrite(MemoryClass mc, int size)
Get read-write access to the memory with the given MemoryClass.
MemoryType h_mt
Host memory type.
void Reset(MemoryType host_mt)
Reset the memory and set the host memory type.
void MakeAlias(const Memory &base, int offset, int size)
Create a memory object that points inside the memory object base.
bool HostIsValid() const
Return true if host pointer is valid.
~Memory()=default
Destructor: default.
Memory & operator=(Memory &&other)
bool UseDevice() const
Read the internal device flag.
void CopyToHost(T *dest, int size) const
Copy size entries from *this to the host pointer dest.
void SyncAlias(const Memory &base, int alias_size) const
Update the alias Memory *this to match the memory location (all valid locations) of its base Memory,...
bool OwnsHostPtr() const
Return true if the host pointer is owned. Ownership indicates whether the pointer will be deleted by ...
friend void MemoryPrintFlags(unsigned flags)
Print the state of a Memory object based on its internal flags. Useful in a debugger....
MemoryType GetMemoryType() const
Return a MemoryType that is currently valid. If both the host and the device pointers are currently v...
bool Empty() const
Return true if the Memory object is empty, see Reset().
T * h_ptr
Pointer to host memory. Not owned.
void Sync(const Memory &other) const
Copy the host/device pointer validity flags from other to *this.
void PrintFlags() const
Print the internal flags.
void DeleteDevice(bool copy_to_host=true)
Delete the device pointer, if owned. If copy_to_host is true and the data is valid only on device,...
unsigned flags
Bit flags defined from the FlagMask enum.
const T * Read(MemoryClass mc, int size) const
Get read-only access to the memory with the given MemoryClass.
void UseDevice(bool use_dev) const
Set the internal device flag.
int CompareHostAndDevice(int size) const
If both the host and the device data are valid, compare their contents.
void CopyFrom(const Memory &src, int size)
Copy size entries from src to *this.
void Reset()
Reset the memory to be empty, ensuring that Delete() will be a no-op.
Memory(int size)
Allocate host memory for size entries.
void Wrap(T *ptr, int size, bool own)
Wrap an externally allocated host pointer, ptr with the current host memory type returned by MemoryMa...
void Delete()
Delete the owned pointers and reset the Memory object.
Memory(T *ptr, int size, MemoryType mt, bool own)
Wrap an externally allocated pointer, ptr, of the given MemoryType.
void CopyTo(Memory &dest, int size) const
Copy size entries from *this to dest.
void ClearOwnerFlags() const
Clear the ownership flags for the host and device pointers, as well as any internal data allocated by...
const T & operator[](int idx) const
Array subscript operator for host memory, const version.
Memory(MemoryType mt)
Creates a new empty Memory object with host MemoryType mt.
void Wrap(T *h_ptr, T *d_ptr, int size, MemoryType h_mt, bool own, bool valid_host=false, bool valid_device=true)
int capacity
Size of the allocated memory.
void New(int size)
Allocate host memory for size entries with the current host memory type returned by MemoryManager::Ge...
Memory & operator=(const Memory &)=default
Copy-assignment operator: default.
Memory(T *ptr, int size, bool own)
Wrap an externally allocated host pointer, ptr with the current host memory type returned by MemoryMa...
bool IsDeviceMemory(MemoryType mt)
Return true if the given memory type is in MemoryClass::DEVICE.
const T * Read(const Memory< T > &mem, int size, bool on_dev=true)
Get a pointer for read access to mem with the mfem::Device's DeviceMemoryClass, if on_dev = true,...
constexpr int DeviceMemoryType
void swap(Array< T > &a, Array< T > &b)
Swap of Array<T> objects for use with standard library algorithms. Also, used by mfem::Swap().
MemoryClass operator*(MemoryClass mc1, MemoryClass mc2)
Return a suitable MemoryClass from a pair of MemoryClasses.
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
MemoryClass
Memory classes identify sets of memory types.
constexpr int MemoryTypeSize
Static casts to 'int' and sizes of some useful memory types.
MemoryManager mm
The (single) global memory manager object.
MemoryType GetMemoryType(MemoryClass mc)
Return a suitable MemoryType for a given MemoryClass.
constexpr int HostMemoryTypeSize
bool IsHostMemory(MemoryType mt)
Return true if the given memory type is in MemoryClass::HOST.
const char * MemoryTypeName[MemoryTypeSize]
Memory type names, used during Device:: configuration.
constexpr int HostMemoryType
bool HypreUsingGPU()
Return true if HYPRE is configured to use GPU.
constexpr int DeviceMemoryTypeSize
MemoryType
Memory types supported by MFEM.
@ HOST_32
Host memory; aligned at 32 bytes.
@ SIZE
Number of host and device memory types.
@ HOST_64
Host memory; aligned at 64 bytes.
@ HOST
Host memory; using new[] and delete[].
@ HOST_PINNED
Host memory: pinned (page-locked)
@ HOST_DEBUG
Host memory; allocated from a "host-debug" pool.
@ DEVICE
Device memory; using CUDA or HIP *Malloc and *Free.
HYPRE_MemoryLocation GetHypreMemoryLocation()
Return the configured HYPRE_MemoryLocation.
void MemoryPrintFlags(unsigned flags)
Print the state of a Memory object based on its internal flags. Useful in a debugger....
bool MemoryClassContainsType(MemoryClass mc, MemoryType mt)
Return true iff the MemoryType mt is contained in the MemoryClass mc.