TRIQS/mpi 1.3.0
C++ interface to MPI
Loading...
Searching...
No Matches
mpi::shared_window< BaseType >

#include <mpi/window.hpp>

Detailed Description

template<class BaseType>
class mpi::shared_window< BaseType >

A C++ wrapper around MPI_Win representing a shared memory window.

This class provides an interface for creating and managing an MPI shared memory window.

Template Parameters
BaseTypeThe type of elements stored in the shared memory window.

Definition at line 366 of file window.hpp.

Inheritance diagram for mpi::shared_window< BaseType >:
mpi::window< BaseType >

Public Member Functions

 shared_window ()=default
 Construct a shared memory window with MPI_WIN_NULL.
 shared_window (shared_communicator const &c, MPI_Aint sz, MPI_Info info=MPI_INFO_NULL)
 Construct a shared memory window by dynamically allocating memory.
BaseType * base (int rank=MPI_PROC_NULL) const
 Get a pointer to the beginning of the shared memory region of a specific rank.
int disp_unit (int rank=MPI_PROC_NULL) const
 Get the displacement unit of the shared memory region of a specific rank.
shared_communicator get_communicator () const
 Get the mpi::shared_communicator associated with the window.
std::tuple< MPI_Aint, int, void * > query (int rank=MPI_PROC_NULL) const
 Query attributes of a shared memory window.
MPI_Aint size (int rank=MPI_PROC_NULL) const
 Get the size of the shared memory region of a specific rank.
Public Member Functions inherited from mpi::window< BaseType >
 window ()=default
 Construct a window with MPI_WIN_NULL.
 window (communicator const &c, BaseType *base_ptr, MPI_Aint sz, MPI_Info info=MPI_INFO_NULL)
 Construct an MPI window over an existing local memory buffer.
 window (communicator const &c, MPI_Aint sz, MPI_Info info=MPI_INFO_NULL)
 Construct an MPI window with dynamically allocated memory.
 window (window &&other) noexcept
 Move constructor takes ownership of the moved-from MPI window and leaves it with MPI_WIN_NULL.
 window (window const &)=delete
 Deleted copy constructor.
virtual ~window ()
 Destructor calls free() to release the window.
BaseType * base () const
 Get a pointer to the beginning of the window memory.
void complete () const
 Completes an RMA access epoch by calling MPI_Win_complete (see also start()).
int disp_unit () const
 Get the displacement unit in bytes.
void fence (int assert=0) const
 Synchronize all RMA operations within an access epoch by calling MPI_Win_fence.
void flush (int rank=-1) const
 Ensure completion of all outstanding RMA operations.
void free () noexcept
 Release allocated resources owned by the window.
template<typename TargetType = BaseType, typename OriginType>
requires (has_mpi_type<OriginType> && has_mpi_type<TargetType>)
void get (OriginType *origin_addr, int origin_count, int target_rank, MPI_Aint target_disp=0, int target_count=-1) const
 Read data from a remote memory window.
communicator get_communicator () const
 Get the mpi::communicator associated with the window.
void lock (int rank=-1, int lock_type=MPI_LOCK_SHARED, int assert=0) const
 Start an RMA access epoch.
 operator MPI_Win () const
 Convert the window to the wrapped MPI_Win object.
 operator MPI_Win * ()
 Convert a pointer to the window to a pointer to the wrapped MPI_Win object.
windowoperator= (window &&rhs) noexcept
 Move assignment operator takes ownership of the moved-from MPI window and leaves it with MPI_WIN_NULL.
windowoperator= (window const &)=delete
 Deleted copy assignment operator.
void post (group const &grp, int assert=0) const
 Start an RMA exposure epoch by calling MPI_Win_post (see also wait()).
template<typename TargetType = BaseType, typename OriginType>
requires (has_mpi_type<OriginType> && has_mpi_type<TargetType>)
void put (OriginType *origin_addr, int origin_count, int target_rank, MPI_Aint target_disp=0, int target_count=-1) const
 Write data to a remote memory window.
MPI_Aint size () const
 Get the size of the window in number of elements.
void start (group const &grp, int assert=0) const
 Start an RMA access epoch by calling MPI_Win_start (see also complete()).
void sync () const
 Synchronize the public and private copies of the window.
void unlock (int rank=-1) const
 Complete an RMA access epoch started by lock().
void wait () const
 Completes an RMA exposure epoch by calling MPI_Win_wait (see also post()).

Additional Inherited Members

Public Types inherited from mpi::window< BaseType >
using base_type = BaseType
 Type of the base pointer.

Constructor & Destructor Documentation

◆ shared_window()

template<class BaseType>
mpi::shared_window< BaseType >::shared_window ( shared_communicator const & c,
MPI_Aint sz,
MPI_Info info = MPI_INFO_NULL )
inlineexplicit

Construct a shared memory window by dynamically allocating memory.

This constructor allocates a shared memory window within the given communicator by calling MPI_Win_allocate_shared. The allocated memory is automatically freed when the window is destroyed.

Parameters
cmpi::shared_communicator object.
szNumber of elements to allocate for the calling process.
infoAdditional MPI information.

Definition at line 381 of file window.hpp.

Member Function Documentation

◆ base()

template<class BaseType>
BaseType * mpi::shared_window< BaseType >::base ( int rank = MPI_PROC_NULL) const
inlinenodiscard

Get a pointer to the beginning of the shared memory region of a specific rank.

Parameters
rankRank within the shared communicator.
Returns
Pointer to the shared window of the given rank.

Definition at line 423 of file window.hpp.

◆ disp_unit()

template<class BaseType>
int mpi::shared_window< BaseType >::disp_unit ( int rank = MPI_PROC_NULL) const
inlinenodiscard

Get the displacement unit of the shared memory region of a specific rank.

Parameters
rankRank within the shared communicator.
Returns
Displacement unit in bytes.

Definition at line 439 of file window.hpp.

◆ query()

template<class BaseType>
std::tuple< MPI_Aint, int, void * > mpi::shared_window< BaseType >::query ( int rank = MPI_PROC_NULL) const
inlinenodiscard

Query attributes of a shared memory window.

Retrieves the byte-size, displacement unit, and a pointer to the beginning of the shared memory region for a specific rank.

When MPI_PROC_NULL is passed for the rank, MPI returns information about the memory segment with the lowest rank that has a non-zero size.

Parameters
rankRank within the shared communicator.
Returns
A tuple containing the byte-size, the displacement unit in bytes and the base pointer.

Definition at line 405 of file window.hpp.

◆ size()

template<class BaseType>
MPI_Aint mpi::shared_window< BaseType >::size ( int rank = MPI_PROC_NULL) const
inlinenodiscard

Get the size of the shared memory region of a specific rank.

Parameters
rankRank within the shared communicator.
Returns
Number of elements in the shared window of the given rank.

Definition at line 431 of file window.hpp.


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