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

Wrapper for syncing PETSc's vector memory. More...

#include <petsc.hpp>

Inheritance diagram for mfem::PetscMemory:
[legend]
Collaboration diagram for mfem::PetscMemory:
[legend]

Public Member Functions

 PetscMemory ()
 
void SetHostValid () const
 
void SetDeviceValid () const
 
void SetHostInvalid () const
 
void SetDeviceInvalid () const
 
bool IsAliasForSync () const
 
void MakeAliasForSync (const Memory< real_t > &base_, int offset_, int size_, bool usedev_)
 
void MakeAliasForSync (Memory< real_t > &base_, int offset_, int size_, bool read_, bool write_, bool usedev_)
 
void SyncBase ()
 
void SyncBaseAndReset ()
 
bool ReadRequested () const
 
bool WriteRequested () const
 
bool DeviceRequested () const
 
const real_tGetHostPointer () const
 
const real_tGetDevicePointer () const
 
- Public Member Functions inherited from mfem::Memory< real_t >
 Memory ()
 
 Memory (const Memory &orig)=default
 Copy constructor: default.
 
 Memory (Memory &&orig)
 
 Memory (int size)
 Allocate host memory for size entries.
 
 Memory (int size, MemoryType mt)
 Allocate memory for size entries with the given MemoryType mt.
 
 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.
 
 Memory (real_t *ptr, int size, bool own)
 Wrap an externally allocated host pointer, ptr with the current host memory type returned by MemoryManager::GetHostMemoryType().
 
 Memory (real_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.
 
Memoryoperator= (const Memory &orig)=default
 Copy-assignment operator: default.
 
Memoryoperator= (Memory &&orig)
 
 ~Memory ()=default
 Destructor: default.
 
bool OwnsHostPtr () const
 Return true if the host pointer is owned. Ownership indicates whether the pointer will be deleted by the method Delete().
 
void SetHostPtrOwner (bool own) const
 Set/clear the ownership flag for the host pointer. Ownership indicates whether the pointer will be deleted by the method Delete().
 
bool OwnsDevicePtr () const
 Return true if the device pointer is owned. Ownership indicates whether the pointer will be deleted by the method Delete().
 
void SetDevicePtrOwner (bool own) const
 Set/clear the ownership flag for the device pointer. Ownership indicates whether the pointer will be deleted by the method Delete().
 
void ClearOwnerFlags () const
 Clear the ownership flags for the host and device pointers, as well as any internal data allocated by the Memory object.
 
bool UseDevice () const
 Read the internal device flag.
 
void UseDevice (bool use_dev) const
 Set the internal device flag.
 
int Capacity () const
 Return the size of the allocated memory.
 
void Reset ()
 Reset the memory to be empty, ensuring that Delete() will be a no-op.
 
void Reset (MemoryType host_mt)
 Reset the memory and set the host memory type.
 
bool Empty () const
 Return true if the Memory object is empty, see Reset().
 
void New (int size)
 Allocate host memory for size entries with the current host memory type returned by MemoryManager::GetHostMemoryType().
 
void New (int size, MemoryType mt)
 Allocate memory for size entries with the given MemoryType.
 
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.
 
void Wrap (real_t *ptr, int size, bool own)
 Wrap an externally allocated host pointer, ptr with the current host memory type returned by MemoryManager::GetHostMemoryType().
 
void Wrap (real_t *ptr, int size, MemoryType mt, bool own)
 Wrap an externally allocated pointer, ptr, of the given MemoryType.
 
void Wrap (real_t *h_ptr, real_t *d_ptr, int size, MemoryType h_mt, bool own, bool valid_host=false, bool valid_device=true)
 
void MakeAlias (const Memory &base, int offset, int size)
 Create a memory object that points inside the memory object base.
 
void SetDeviceMemoryType (MemoryType d_mt)
 Set the device MemoryType to be used by the Memory object.
 
void Delete ()
 Delete the owned pointers and reset the Memory object.
 
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, move it to host before deleting. Invalidates the device memory.
 
real_toperator[] (int idx)
 Array subscript operator for host memory.
 
const real_toperator[] (int idx) const
 Array subscript operator for host memory, const version.
 
 operator real_t * ()
 Direct access to the host memory as T* (implicit conversion).
 
 operator const real_t * () const
 Direct access to the host memory as const T* (implicit conversion).
 
 operator U* ()
 Direct access to the host memory via explicit typecast.
 
 operator const U * () const
 Direct access to the host memory via explicit typecast, const version.
 
real_tReadWrite (MemoryClass mc, int size)
 Get read-write access to the memory with the given MemoryClass.
 
const real_tRead (MemoryClass mc, int size) const
 Get read-only access to the memory with the given MemoryClass.
 
real_tWrite (MemoryClass mc, int size)
 Get write-only access to the memory with the given MemoryClass.
 
void Sync (const Memory &other) const
 Copy the host/device pointer validity flags from other to *this.
 
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, base.
 
MemoryType GetMemoryType () const
 Return a MemoryType that is currently valid. If both the host and the device pointers are currently valid, then the device memory type is returned.
 
MemoryType GetHostMemoryType () const
 Return the host MemoryType of the Memory object.
 
MemoryType GetDeviceMemoryType () const
 Return the device MemoryType of the Memory object. If the device MemoryType is not set, return MemoryType::DEFAULT.
 
bool HostIsValid () const
 Return true if host pointer is valid.
 
bool DeviceIsValid () const
 Return true if device pointer is valid.
 
void CopyFrom (const Memory &src, int size)
 Copy size entries from src to *this.
 
void CopyFromHost (const real_t *src, int size)
 Copy size entries from the host pointer src to *this.
 
void CopyTo (Memory &dest, int size) const
 Copy size entries from *this to dest.
 
void CopyToHost (real_t *dest, int size) const
 Copy size entries from *this to the host pointer dest.
 
void PrintFlags () const
 Print the internal flags.
 
int CompareHostAndDevice (int size) const
 If both the host and the device data are valid, compare their contents.
 

Additional Inherited Members

- Protected Types inherited from mfem::Memory< real_t >
enum  FlagMask
 
- Protected Attributes inherited from mfem::Memory< real_t >
real_th_ptr
 Pointer to host memory. Not owned.
 
int capacity
 Size of the allocated memory.
 
MemoryType h_mt
 Host memory type.
 
unsigned flags
 Bit flags defined from the FlagMask enum.
 

Detailed Description

Wrapper for syncing PETSc's vector memory.

Definition at line 87 of file petsc.hpp.

Constructor & Destructor Documentation

◆ PetscMemory()

mfem::PetscMemory::PetscMemory ( )
inline

Definition at line 95 of file petsc.hpp.

Member Function Documentation

◆ DeviceRequested()

bool mfem::PetscMemory::DeviceRequested ( ) const
inline

Definition at line 143 of file petsc.hpp.

◆ GetDevicePointer()

const mfem::real_t * mfem::PetscMemory::GetDevicePointer ( ) const

Definition at line 256 of file petsc.cpp.

◆ GetHostPointer()

const mfem::real_t * mfem::PetscMemory::GetHostPointer ( ) const

Definition at line 247 of file petsc.cpp.

◆ IsAliasForSync()

bool mfem::PetscMemory::IsAliasForSync ( ) const
inline

Definition at line 100 of file petsc.hpp.

◆ MakeAliasForSync() [1/2]

void mfem::PetscMemory::MakeAliasForSync ( const Memory< real_t > & base_,
int offset_,
int size_,
bool usedev_ )
inline

Definition at line 102 of file petsc.hpp.

◆ MakeAliasForSync() [2/2]

void mfem::PetscMemory::MakeAliasForSync ( Memory< real_t > & base_,
int offset_,
int size_,
bool read_,
bool write_,
bool usedev_ )
inline

Definition at line 112 of file petsc.hpp.

◆ ReadRequested()

bool mfem::PetscMemory::ReadRequested ( ) const
inline

Definition at line 133 of file petsc.hpp.

◆ SetDeviceInvalid()

void mfem::PetscMemory::SetDeviceInvalid ( ) const
inline

Definition at line 99 of file petsc.hpp.

◆ SetDeviceValid()

void mfem::PetscMemory::SetDeviceValid ( ) const
inline

Definition at line 97 of file petsc.hpp.

◆ SetHostInvalid()

void mfem::PetscMemory::SetHostInvalid ( ) const
inline

Definition at line 98 of file petsc.hpp.

◆ SetHostValid()

void mfem::PetscMemory::SetHostValid ( ) const
inline

Definition at line 96 of file petsc.hpp.

◆ SyncBase()

void mfem::PetscMemory::SyncBase ( )
inline

Definition at line 122 of file petsc.hpp.

◆ SyncBaseAndReset()

void mfem::PetscMemory::SyncBaseAndReset ( )
inline

Definition at line 127 of file petsc.hpp.

◆ WriteRequested()

bool mfem::PetscMemory::WriteRequested ( ) const
inline

Definition at line 138 of file petsc.hpp.


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