iterative-solver 0.0
molpro::linalg::array::util::DistrFlags Class Reference

Distributed array of integer flags with one flag per process and a locking mechanism to ensure atomic access. More...

#include <DistrFlags.h>

Detailed Description

Distributed array of integer flags with one flag per process and a locking mechanism to ensure atomic access.

Note
Copying creates a proxy to access flag values on their processor.
Warning
Access to the data of a given rank is done via a Proxy which locks the window buffer on that rank. Care must be taken to ensure a combination of proxies does not lead to a deadlock, especially when mixed with copying.

Classes

class  Proxy
 Proxy for accessing the stored flags. The flag on a given rank is locked on construction and unlocked on destruction. More...
 

Public Member Functions

 DistrFlags ()=default
 
 DistrFlags (const DistrFlags &source)
 
 DistrFlags (DistrFlags &&source) noexcept
 
DistrFlagsoperator= (const DistrFlags &source)
 
DistrFlagsoperator= (DistrFlags &&source) noexcept
 
 ~DistrFlags ()
 
 DistrFlags (MPI_Comm comm, int value=0)
 Construct the distributed array with initial value of flag. More...
 
bool empty () const
 Whether distributed array was allocated. More...
 
Proxy access () const
 
Proxy access (int rank) const
 
MPI_Comm communicator () const
 

Protected Attributes

MPI_Comm m_comm = {}
 mpi communicator More...
 
MPI_Win m_win = MPI_WIN_NULL
 
std::shared_ptr< int > m_counter
 empty window handle More...
 

Friends

void swap (DistrFlags &x, DistrFlags &y)
 

Constructor & Destructor Documentation

◆ DistrFlags() [1/4]

molpro::linalg::array::util::DistrFlags::DistrFlags ( )
default

◆ DistrFlags() [2/4]

molpro::linalg::array::util::DistrFlags::DistrFlags ( const DistrFlags source)

◆ DistrFlags() [3/4]

molpro::linalg::array::util::DistrFlags::DistrFlags ( DistrFlags &&  source)
noexcept

◆ ~DistrFlags()

molpro::linalg::array::util::DistrFlags::~DistrFlags ( )

◆ DistrFlags() [4/4]

molpro::linalg::array::util::DistrFlags::DistrFlags ( MPI_Comm  comm,
int  value = 0 
)

Construct the distributed array with initial value of flag.

Member Function Documentation

◆ access() [1/2]

DistrFlags::Proxy molpro::linalg::array::util::DistrFlags::access ( ) const

Access flag on current process through a proxy, locking access for all other processes until the proxy is destroyed. Cannot be called on an empty object.

◆ access() [2/2]

DistrFlags::Proxy molpro::linalg::array::util::DistrFlags::access ( int  rank) const

Access flag on current process rank a proxy, locking access for all other processes until the proxy is destroyed. Cannot be called on an empty object.

◆ communicator()

MPI_Comm molpro::linalg::array::util::DistrFlags::communicator ( ) const
inline

◆ empty()

bool molpro::linalg::array::util::DistrFlags::empty ( ) const

Whether distributed array was allocated.

◆ operator=() [1/2]

DistrFlags & molpro::linalg::array::util::DistrFlags::operator= ( const DistrFlags source)

◆ operator=() [2/2]

DistrFlags & molpro::linalg::array::util::DistrFlags::operator= ( DistrFlags &&  source)
noexcept

Friends And Related Function Documentation

◆ swap

void swap ( DistrFlags x,
DistrFlags y 
)
friend

Member Data Documentation

◆ m_comm

MPI_Comm molpro::linalg::array::util::DistrFlags::m_comm = {}
protected

mpi communicator

◆ m_counter

std::shared_ptr<int> molpro::linalg::array::util::DistrFlags::m_counter
protected
Initial value:
=
nullptr

empty window handle

counter of Proxy objects created. They must all be destroyed before this can be destroyed

◆ m_win

MPI_Win molpro::linalg::array::util::DistrFlags::m_win = MPI_WIN_NULL
protected