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

Atomic lock allowing only one process to acquire it. Implemented using MPI3 RMA. More...

#include <util.h>

Detailed Description

Atomic lock allowing only one process to acquire it. Implemented using MPI3 RMA.

Classes

struct  Proxy
 Proxy that locks on creation and unlocks on destruction. Useful for locking a scope. More...
 

Public Member Functions

 LockMPI3 (MPI_Comm comm)
 Create the lock without acquiring it. This is collective and must be called by all processes in the communicator. More...
 
 ~LockMPI3 ()
 Release the lock and destroy it. This is collective and must be called by all processes in the communicator. More...
 
 LockMPI3 ()=delete
 
 LockMPI3 (const LockMPI3 &)=delete
 
LockMPI3operator= (const LockMPI3 &)=delete
 
void lock ()
 Acquire exclusive lock. More...
 
void unlock ()
 Release the lock. More...
 
std::shared_ptr< Proxyscope ()
 

Protected Attributes

MPI_Comm m_comm = MPI_COMM_NULL
 MPI communicator. More...
 
MPI_Win m_win = MPI_WIN_NULL
 empty window handle More...
 
bool m_locked = false
 whether lock is active More...
 
std::weak_ptr< Proxym_proxy
 Keep track of proxy object so that if lock is deleted, the proxy does not try to unlock. More...
 

Constructor & Destructor Documentation

◆ LockMPI3() [1/3]

molpro::linalg::array::util::LockMPI3::LockMPI3 ( MPI_Comm  comm)

Create the lock without acquiring it. This is collective and must be called by all processes in the communicator.

◆ ~LockMPI3()

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

Release the lock and destroy it. This is collective and must be called by all processes in the communicator.

◆ LockMPI3() [2/3]

molpro::linalg::array::util::LockMPI3::LockMPI3 ( )
delete

◆ LockMPI3() [3/3]

molpro::linalg::array::util::LockMPI3::LockMPI3 ( const LockMPI3 )
delete

Member Function Documentation

◆ lock()

void molpro::linalg::array::util::LockMPI3::lock ( )

Acquire exclusive lock.

◆ operator=()

LockMPI3 & molpro::linalg::array::util::LockMPI3::operator= ( const LockMPI3 )
delete

◆ scope()

std::shared_ptr< LockMPI3::Proxy > molpro::linalg::array::util::LockMPI3::scope ( )

Return a proxy object that acquires the lock on creation and releases it on destruction. Useful for locking a scope.

◆ unlock()

void molpro::linalg::array::util::LockMPI3::unlock ( )

Release the lock.

Member Data Documentation

◆ m_comm

MPI_Comm molpro::linalg::array::util::LockMPI3::m_comm = MPI_COMM_NULL
protected

MPI communicator.

◆ m_locked

bool molpro::linalg::array::util::LockMPI3::m_locked = false
protected

whether lock is active

◆ m_proxy

std::weak_ptr<Proxy> molpro::linalg::array::util::LockMPI3::m_proxy
protected

Keep track of proxy object so that if lock is deleted, the proxy does not try to unlock.

◆ m_win

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

empty window handle