MFEM  v4.5.1
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
Public Member Functions | List of all members
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< double > &base_, int offset_, int size_, bool usedev_)
 
void MakeAliasForSync (Memory< double > &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 double * GetHostPointer () const
 
const double * GetDevicePointer () const
 
- Public Member Functions inherited from mfem::Memory< double >
 Memory ()
 
 Memory (const Memory &orig)=default
 Copy constructor: default. More...
 
 Memory (Memory &&orig)
 
 Memory (int size)
 Allocate host memory for size entries. More...
 
 Memory (int size, MemoryType mt)
 Allocate memory for size entries with the given MemoryType mt. More...
 
 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. More...
 
 Memory (double *ptr, int size, bool own)
 Wrap an externally allocated host pointer, ptr with the current host memory type returned by MemoryManager::GetHostMemoryType(). More...
 
 Memory (double *ptr, int size, MemoryType mt, bool own)
 Wrap an externally allocated pointer, ptr, of the given MemoryType. More...
 
 Memory (const Memory &base, int offset, int size)
 Alias constructor. Create a Memory object that points inside the Memory object base. More...
 
Memoryoperator= (const Memory &orig)=default
 Copy-assignment operator: default. More...
 
Memoryoperator= (Memory &&orig)
 
 ~Memory ()=default
 Destructor: default. More...
 
bool OwnsHostPtr () const
 Return true if the host pointer is owned. Ownership indicates whether the pointer will be deleted by the method Delete(). More...
 
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(). More...
 
bool OwnsDevicePtr () const
 Return true if the device pointer is owned. Ownership indicates whether the pointer will be deleted by the method Delete(). More...
 
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(). More...
 
void ClearOwnerFlags () const
 Clear the ownership flags for the host and device pointers, as well as any internal data allocated by the Memory object. More...
 
bool UseDevice () const
 Read the internal device flag. More...
 
void UseDevice (bool use_dev) const
 Set the internal device flag. More...
 
int Capacity () const
 Return the size of the allocated memory. More...
 
void Reset ()
 Reset the memory to be empty, ensuring that Delete() will be a no-op. More...
 
void Reset (MemoryType host_mt)
 Reset the memory and set the host memory type. More...
 
bool Empty () const
 Return true if the Memory object is empty, see Reset(). More...
 
void New (int size)
 Allocate host memory for size entries with the current host memory type returned by MemoryManager::GetHostMemoryType(). More...
 
void New (int size, MemoryType mt)
 Allocate memory for size entries with the given MemoryType. More...
 
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. More...
 
void Wrap (double *ptr, int size, bool own)
 Wrap an externally allocated host pointer, ptr with the current host memory type returned by MemoryManager::GetHostMemoryType(). More...
 
void Wrap (double *ptr, int size, MemoryType mt, bool own)
 Wrap an externally allocated pointer, ptr, of the given MemoryType. More...
 
void Wrap (double *h_ptr, double *d_ptr, int size, MemoryType h_mt, bool own)
 
void MakeAlias (const Memory &base, int offset, int size)
 Create a memory object that points inside the memory object base. More...
 
void SetDeviceMemoryType (MemoryType d_mt)
 Set the device MemoryType to be used by the Memory object. More...
 
void Delete ()
 Delete the owned pointers and reset the Memory object. More...
 
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. More...
 
double & operator[] (int idx)
 Array subscript operator for host memory. More...
 
const double & operator[] (int idx) const
 Array subscript operator for host memory, const version. More...
 
 operator double * ()
 Direct access to the host memory as T* (implicit conversion). More...
 
 operator const double * () const
 Direct access to the host memory as const T* (implicit conversion). More...
 
 operator U * ()
 Direct access to the host memory via explicit typecast. More...
 
 operator const U * () const
 Direct access to the host memory via explicit typecast, const version. More...
 
double * ReadWrite (MemoryClass mc, int size)
 Get read-write access to the memory with the given MemoryClass. More...
 
const double * Read (MemoryClass mc, int size) const
 Get read-only access to the memory with the given MemoryClass. More...
 
double * Write (MemoryClass mc, int size)
 Get write-only access to the memory with the given MemoryClass. More...
 
void Sync (const Memory &other) const
 Copy the host/device pointer validity flags from other to *this. More...
 
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. More...
 
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. More...
 
MemoryType GetHostMemoryType () const
 Return the host MemoryType of the Memory object. More...
 
MemoryType GetDeviceMemoryType () const
 Return the device MemoryType of the Memory object. If the device MemoryType is not set, return MemoryType::DEFAULT. More...
 
bool HostIsValid () const
 Return true if host pointer is valid. More...
 
bool DeviceIsValid () const
 Return true if device pointer is valid. More...
 
void CopyFrom (const Memory &src, int size)
 Copy size entries from src to *this. More...
 
void CopyFromHost (const double *src, int size)
 Copy size entries from the host pointer src to *this. More...
 
void CopyTo (Memory &dest, int size) const
 Copy size entries from *this to dest. More...
 
void CopyToHost (double *dest, int size) const
 Copy size entries from *this to the host pointer dest. More...
 
void PrintFlags () const
 Print the internal flags. More...
 
int CompareHostAndDevice (int size) const
 If both the host and the device data are valid, compare their contents. More...
 

Additional Inherited Members

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

Detailed Description

Wrapper for syncing PETSc's vector memory.

Definition at line 84 of file petsc.hpp.

Constructor & Destructor Documentation

mfem::PetscMemory::PetscMemory ( )
inline

Definition at line 92 of file petsc.hpp.

Member Function Documentation

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

Definition at line 140 of file petsc.hpp.

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

Definition at line 207 of file petsc.cpp.

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

Definition at line 198 of file petsc.cpp.

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

Definition at line 97 of file petsc.hpp.

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

Definition at line 99 of file petsc.hpp.

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

Definition at line 109 of file petsc.hpp.

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

Definition at line 130 of file petsc.hpp.

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

Definition at line 96 of file petsc.hpp.

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

Definition at line 94 of file petsc.hpp.

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

Definition at line 95 of file petsc.hpp.

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

Definition at line 93 of file petsc.hpp.

void mfem::PetscMemory::SyncBase ( )
inline

Definition at line 119 of file petsc.hpp.

void mfem::PetscMemory::SyncBaseAndReset ( )
inline

Definition at line 124 of file petsc.hpp.

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

Definition at line 135 of file petsc.hpp.


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