An opaque wrapper for MPI_Win with a vendor-independent representation and without any <mpi.h> header dependency.
More...
#include <UPstreamWindow.H>
Public Types | |
| typedef std::intptr_t | value_type |
| Storage for MPI_Win (as integer or pointer). | |
Public Member Functions | |
| Window (const Window &) noexcept=default | |
| Copy construct. | |
| Window (Window &&) noexcept=default | |
| Move construct. | |
| Window & | operator= (const Window &) noexcept=default |
| Copy assignment. | |
| Window & | operator= (Window &&) noexcept=default |
| Move assignment. | |
| bool | operator== (const Window &rhs) const noexcept |
| Test for equality. | |
| bool | operator!= (const Window &rhs) const noexcept |
| Test for inequality. | |
| Window () noexcept | |
| Default construct as MPI_WIN_NULL. | |
| Window (const void *p) noexcept | |
| Construct from MPI_Win (as pointer type). | |
| Window (value_type val) noexcept | |
| Construct from MPI_Win (as integer type). | |
| value_type | value () const noexcept |
| Return raw value. | |
| const void * | pointer () const noexcept |
| Return as pointer value. | |
| bool | good () const noexcept |
| True if not equal to MPI_WIN_NULL. | |
| void | reset () noexcept |
| Reset to default constructed value (MPI_WIN_NULL). | |
| int | size () const |
| The number of ranks associated with the window group. | |
| template<class Type> | |
| UList< Type > | allocate (std::streamsize count, UPstream::Communicator communicator, const bool shared=false) |
| Allocate a local memory region and create window onto it. | |
| template<class Type> | |
| UList< Type > | allocate (std::streamsize count, const int communicator, const bool shared=false) |
| Allocate a local memory region and create window onto it. | |
| template<class Type> | |
| UList< Type > | allocate_shared (std::streamsize count, UPstream::Communicator communicator) |
| Allocate a shared memory region and create window onto it. | |
| template<class Type> | |
| UList< Type > | allocate_shared (std::streamsize count, const int communicator) |
| Create a window by allocating a new shared memory region. | |
| template<class Type = void> | |
| bool | create (std::nullptr_t, UPstream::Communicator comm) |
| A window exposing a zero-sized memory region. | |
| template<class Type = void> | |
| bool | create (std::nullptr_t, const int comm) |
| A window exposing a zero-sized memory region. | |
| template<class Type> | |
| bool | create (const Type *buffer, std::streamsize count, UPstream::Communicator communicator) |
| A window exposing an existing memory region. | |
| template<class Type> | |
| bool | create (const Type *buffer, std::streamsize count, const int communicator) |
| A window exposing an existing memory region. | |
| template<class Type> | |
| bool | create (const UList< Type > &buffer, UPstream::Communicator comm) |
| A window exposing the specified buffer contents. | |
| template<class Type> | |
| bool | create (const UList< Type > &buffer, int communicator) |
| A window exposing the specified buffer contents. | |
| template<class Type> | |
| bool | create (SubList< Type > buffer, UPstream::Communicator communicator) |
| A window exposing the specified buffer contents. | |
| template<class Type> | |
| bool | create (SubList< Type > buffer, int communicator) |
| A window exposing the specified buffer contents. | |
| void | lock (int rank, bool exclusive=false) |
| MPI_Win_lock() for given target rank (no assertions), optionally as exclusive lock. | |
| void | unlock (int rank) |
| MPI_Win_unlock() for given target rank. | |
| void | lock_all (bool exclusive=false) |
| MPI_Win_lock_all(), optionally as exclusive lock. | |
| void | unlock_all () |
| MPI_Win_unlock_all(). | |
| void | flush (int rank) |
| MPI_Win_flush() for given target rank. | |
| void | flush_all () |
| MPI_Win_flush_all(). | |
| void | flush_local (int rank) |
| MPI_Win_flush_local(). | |
| void | flush_local_all () |
| MPI_Win_flush_local_all(). | |
| void | sync () |
| MPI_Win_sync() - ignored if the window is not active. | |
| void | close () |
| MPI_Win_free(). Closes the window view and frees any associated memory,. | |
| bool | is_shared (const bool failNonShared=false) const |
| Test if the window is a shared memory window. | |
| template<class Type> | |
| UList< Type > | view () const |
| Return view of the currently exposed window content. No restriction on the type of memory associated with the window. | |
| template<class Type> | |
| UList< Type > | view_shared (int target_rank) const |
| Return view of shared memory window content. | |
| template<class Type> | |
| bool | get (Type *buffer, std::streamsize count, int fromProcNo, int target_disp=0) const |
| Get buffer contents from given rank. A no-op for an empty or null buffer, or if not running in parallel. | |
| template<class Type> | |
| bool | put (const Type *buffer, std::streamsize count, int toProcNo, int target_disp=0) const |
| Put buffer contents to given rank. | |
| template<class Type> | |
| bool | put (const UPstream::opCodes opCodeId, const Type *buffer, std::streamsize count, int toProcNo, int target_disp=0) const |
| Put accumulate buffer contents to given rank. | |
| template<class Type> | |
| bool | get_value (Type &value, int fromProcNo, int target_disp=0) const |
| Get a single value from given rank. | |
| template<class Type> | |
| bool | put_value (const Type &value, int toProcNo, int target_disp=0) const |
| Put a single value to given rank. | |
| template<class Type> | |
| bool | put_value (const UPstream::opCodes opCodeId, const Type &value, int toProcNo, int target_disp=0) const |
| Put and accumulate a single value to given rank. | |
| template<class Type> | |
| bool | get (UList< Type > &buffer, int fromProcNo, int target_disp=0) const |
| Get into List storage (contiguous data only) from window location on given processor. A no-op for an empty or null buffer, or if not running in parallel. | |
| template<class Type> | |
| bool | put (const UList< Type > &buffer, int toProcNo, int target_disp=0) const |
| Put from List storage (contiguous data only) to window location on given processor. | |
| template<class Type> | |
| bool | put (const UPstream::opCodes opCodeId, const UList< Type > &buffer, int toProcNo, int target_disp=0) const |
| Put and accumulate from List storage (contiguous data only) to window location on given processor. A no-op for an empty or null buffer, or if not running in parallel. | |
| template<class Type> | |
| bool | get (SubList< Type > buffer, int fromProcNo, int target_disp=0) const |
| Get into SubList storage (contiguous data only) from window location on given processor. A no-op for an empty or null buffer, or if not running in parallel. | |
| template<class Type> | |
| bool | fetch_and_op (const UPstream::opCodes opCodeId, const Type &origin, Type &result, int target_rank, int target_disp=0) const |
| Combine the value of origin into the target and return the resulting value (MPI_Fetch_and_op). | |
| template<class Type> | |
| bool | put (const SubList< Type > buffer, int toProcNo, int target_disp=0) const |
| Put from SubList storage (contiguous data only) to window location on given processor. A no-op for an empty or null buffer, or if not running in parallel. | |
| template<class Type> | |
| bool | put (const UPstream::opCodes opCodeId, const SubList< Type > buffer, int toProcNo, int target_disp=0) const |
| Put and accumulate from SubList storage (contiguous data only) to window location on given processor. A no-op for an empty or null buffer, or if not running in parallel. | |
Protected Member Functions | |
| std::pair< void *, int64_t > | mpi_win_allocate (std::streamsize num_elements, int disp_unit, UPstream::Communicator communicator, const bool shared=false) |
| Allocate a local or shared memory window. Uses MPI_Win_allocate() or MPI_Win_allocate_shared(), respectively. | |
| std::pair< void *, int64_t > | mpi_win_allocate (std::streamsize num_elements, int disp_unit, int communicator, const bool shared=false) |
| Allocate a local or shared memory window. Uses MPI_Win_allocate() or MPI_Win_allocate_shared(), respectively. | |
| bool | mpi_win_create (void *baseptr, std::streamsize num_elements, int disp_unit, UPstream::Communicator communicator) |
| Create window onto existing memory with MPI_Win_create(). | |
| bool | mpi_win_create (void *baseptr, std::streamsize num_elements, int disp_unit, int communicator) |
| Create window onto existing memory with MPI_Win_create(). | |
| bool | get_data (void *origin, std::streamsize count, const UPstream::dataTypes dataTypeId, int target_rank, int target_disp=0) const |
| Get buffer contents from given rank. | |
| bool | put_data (const void *origin, std::streamsize count, const UPstream::dataTypes dataTypeId, int target_rank, int target_disp=0) const |
| Put buffer contents to given rank. | |
| bool | put_data (const UPstream::opCodes opCodeId, const void *origin, std::streamsize count, const UPstream::dataTypes dataTypeId, int target_rank, int target_disp=0) const |
| Put accumulate buffer contents to given rank. | |
| bool | mpi_fetch_and_op (const UPstream::opCodes opCodeId, const void *origin, void *result, const UPstream::dataTypes dataTypeId, int target_rank, int target_disp=0) const |
| Retrieve the remote content (a single value) and then combine in new content. | |
| void | mpi_win_flushing (int rank, bool local=false) |
| Entry point to MPI_Win_flush(), MPI_Win_flush_all(), MPI_Win_flush_local(), MPI_Win_flush_local_all(). | |
| void | mpi_win_locking (int rank, bool exclusive=false) |
| Entry point to MPI_Win_lock(), MPI_Win_lock_all(), optionally as exclusive lock. | |
| void | mpi_win_unlocking (int rank) |
| Entry point to MPI_Win_unlock(), MPI_Win_unlock_all(). | |
Static Protected Member Functions | |
| template<class Type> | |
| static constexpr auto | element_width () noexcept |
| Sizing helper for disp_unit. | |
| static std::pair< void *, int64_t > | mpi_win_query (UPstream::Window window, const int expected_disp_unit) |
| Retrieve window sizing information as address/count tuple. The expected sizeof(Type) is supplied as an assertion parameter. | |
| static std::pair< void *, int64_t > | mpi_win_query_shared (UPstream::Window window, int target_rank, const int expected_disp_unit) |
| Retrieve shared window information as address/count tuple. The expected sizeof(Type) is supplied as an assertion parameter. | |
An opaque wrapper for MPI_Win with a vendor-independent representation and without any <mpi.h> header dependency.
The handling for window declaration is very generous - it does not distinguish between readonly and read/write windows. This may become more restrictive in the future.
Definition at line 55 of file UPstreamWindow.H.
| typedef std::intptr_t value_type |
Storage for MPI_Win (as integer or pointer).
Definition at line 64 of file UPstreamWindow.H.
|
defaultnoexcept |
Copy construct.
References Window().
Referenced by operator!=(), operator=(), operator=(), operator==(), Window(), Window(), Window(), and Window().


|
defaultnoexcept |
|
noexcept |
Default construct as MPI_WIN_NULL.
Definition at line 25 of file UPstreamWindow.C.
References Foam::noexcept, UPstream::UPstream(), and Window().

|
inlineexplicitnoexcept |
Construct from MPI_Win (as pointer type).
Definition at line 358 of file UPstreamWindow.H.
References Foam::noexcept, p, and Window().

|
inlineexplicitnoexcept |
Construct from MPI_Win (as integer type).
Definition at line 366 of file UPstreamWindow.H.
References Foam::noexcept.
|
inlinestaticconstexprprotectednoexcept |
Sizing helper for disp_unit.
Definition at line 85 of file UPstreamWindow.H.
References Foam::noexcept.
Referenced by create(), and create().

|
protected |
Allocate a local or shared memory window. Uses MPI_Win_allocate() or MPI_Win_allocate_shared(), respectively.
A no-op if not running in parallel. This is a collective call.
| num_elements | Number of elements in the window (non-negative integer) |
| disp_unit | Local unit size for displacements (positive integer) == sizeof(Type) |
| communicator | Communicator (wrapped) |
| shared | Create shared memory |
Definition at line 52 of file UPstreamWindow.C.
References NotImplemented.
|
protected |
Allocate a local or shared memory window. Uses MPI_Win_allocate() or MPI_Win_allocate_shared(), respectively.
A no-op if not running in parallel. This is a collective call.
| num_elements | Number of elements in the window (non-negative integer) |
| disp_unit | Local unit size for displacements (positive integer) == sizeof(Type) |
| communicator | Communicator (internally indexed) |
| shared | Create shared memory |
Definition at line 66 of file UPstreamWindow.C.
References NotImplemented.
|
protected |
Create window onto existing memory with MPI_Win_create().
A no-op if not running in parallel. This is a collective call.
| baseptr | Address of window |
| num_elements | Number of elements in the window (non-negative integer) |
| disp_unit | Local unit size for displacements (positive integer) == sizeof(Type) |
| communicator | Communicator (wrapped) |
Definition at line 79 of file UPstreamWindow.C.
References NotImplemented.
Referenced by create(), and create().

|
protected |
Create window onto existing memory with MPI_Win_create().
A no-op if not running in parallel. This is a collective call.
| baseptr | Address of window |
| num_elements | Number of elements in the window (non-negative integer) |
| disp_unit | Local unit size for displacements (positive integer) == sizeof(Type) |
| communicator | Communicator (internally indexed) |
Definition at line 92 of file UPstreamWindow.C.
References NotImplemented.
|
staticprotected |
Retrieve window sizing information as address/count tuple. The expected sizeof(Type) is supplied as an assertion parameter.
| expected_disp_unit | Expected element size (fatal for mismatch with queried value) |
Definition at line 198 of file UPstreamWindow.C.
References NotImplemented.
|
staticprotected |
Retrieve shared window information as address/count tuple. The expected sizeof(Type) is supplied as an assertion parameter.
| target_rank | The rank to query |
| expected_disp_unit | Expected element size (fatal for mismatch with queried value) |
Definition at line 211 of file UPstreamWindow.C.
References NotImplemented.
|
protected |
Get buffer contents from given rank.
A no-op if not running in parallel and for empty or null buffer.
void pointer and the required data type (as per MPI). This means it should almost never be called directly but always via a compile-time checked caller. | origin | Destination buffer |
| count | The data count - number of elements. Identical on both sides. |
| target_disp | Window displacement on target |
Definition at line 131 of file UPstreamWindow.C.
References NotImplemented.
|
protected |
Put buffer contents to given rank.
A no-op if not running in parallel and for empty or null buffer.
| origin | Source buffer |
| count | The data count - number of elements. Identical on both sides. |
| target_disp | Window displacement on target |
Definition at line 145 of file UPstreamWindow.C.
References NotImplemented.
|
protected |
Put accumulate buffer contents to given rank.
A no-op if not running in parallel and for empty or null buffer.
| opCodeId | The op-code for accumulate |
| origin | Source buffer |
| count | The data count - number of elements. Identical on both sides. |
| target_disp | Window displacement on target |
Definition at line 159 of file UPstreamWindow.C.
References NotImplemented.
|
protected |
Retrieve the remote content (a single value) and then combine in new content.
A no-op if not running in parallel and for empty or null buffer.
| opCodeId | The op-code for accumulate | |
| [in] | origin | the content to combine with target |
| [out] | result | target content before the operation |
| target_disp | Window displacement on target |
Definition at line 174 of file UPstreamWindow.C.
References NotImplemented.
|
protected |
Entry point to MPI_Win_flush(), MPI_Win_flush_all(), MPI_Win_flush_local(), MPI_Win_flush_local_all().
Uses rank == -1 to signal 'all'
Definition at line 113 of file UPstreamWindow.C.
References local.
Referenced by flush(), flush_all(), flush_local(), and flush_local_all().

|
protected |
Entry point to MPI_Win_lock(), MPI_Win_lock_all(), optionally as exclusive lock.
Uses rank == -1 to signal 'all'
Definition at line 121 of file UPstreamWindow.C.
Referenced by lock(), and lock_all().

|
protected |
Entry point to MPI_Win_unlock(), MPI_Win_unlock_all().
Uses rank == -1 to signal 'all'
Definition at line 125 of file UPstreamWindow.C.
Referenced by unlock(), and unlock_all().

|
inlinenoexcept |
Test for equality.
Definition at line 334 of file UPstreamWindow.H.
References Foam::noexcept, Foam::rhs(), and Window().

|
inlinenoexcept |
Test for inequality.
Definition at line 342 of file UPstreamWindow.H.
References Foam::rhs(), and Window().

|
inlinenoexcept |
Return raw value.
Definition at line 379 of file UPstreamWindow.H.
References Foam::noexcept.
Referenced by get_value(), put_value(), and put_value().

|
inlinenoexcept |
Return as pointer value.
Definition at line 384 of file UPstreamWindow.H.
References Foam::noexcept.
|
noexcept |
True if not equal to MPI_WIN_NULL.
Definition at line 33 of file UPstreamWindow.C.
References Foam::noexcept.
|
noexcept |
Reset to default constructed value (MPI_WIN_NULL).
Definition at line 39 of file UPstreamWindow.C.
References Foam::noexcept.
| int size | ( | ) | const |
The number of ranks associated with the window group.
The same as querying the original communicator, assuming the communicator is available within the current code scope.
Definition at line 43 of file UPstreamWindow.C.
|
inline |
Allocate a local memory region and create window onto it.
A no-op if not running in parallel. This is a collective call.
| count | Number of elements to allocate |
| shared | Create shared memory region |
References allocate(), and UPstream::UPstream().
Referenced by allocate(), and allocate().


|
inline |
Allocate a local memory region and create window onto it.
A no-op if not running in parallel. This is a collective call.
| count | Number of elements to allocate |
| shared | Create shared memory region |
References allocate().

|
inline |
Allocate a shared memory region and create window onto it.
A no-op if not running in parallel. This is a collective call.
| count | Number of elements to allocate |
References allocate_shared(), and UPstream::UPstream().
Referenced by allocate_shared(), and allocate_shared().


|
inline |
Create a window by allocating a new shared memory region.
A no-op if not running in parallel. This is a collective call.
| count | Number of elements to allocate |
References allocate_shared().

|
inline |
A window exposing a zero-sized memory region.
A no-op if not running in parallel. This is a collective call.
Definition at line 480 of file UPstreamWindow.H.
References create(), element_width(), mpi_win_create(), and UPstream::UPstream().
Referenced by create(), create(), create(), create(), and create().


|
inline |
A window exposing a zero-sized memory region.
A no-op if not running in parallel. This is a collective call.
Definition at line 492 of file UPstreamWindow.H.
References element_width(), and mpi_win_create().

|
inline |
A window exposing an existing memory region.
A no-op if not running in parallel. This is a collective call.
| count | Number of elements in the window |
|
inline |
A window exposing an existing memory region.
A no-op if not running in parallel. This is a collective call.
| count | Number of elements in the window |
|
inline |
A window exposing the specified buffer contents.
A no-op if not running in parallel. This is a collective call.
Definition at line 536 of file UPstreamWindow.H.
References UList< T >::cdata(), create(), and UList< T >::size().

|
inline |
A window exposing the specified buffer contents.
A no-op if not running in parallel. This is a collective call.
Definition at line 548 of file UPstreamWindow.H.
References UList< T >::cdata(), create(), and UList< T >::size().

|
inline |
A window exposing the specified buffer contents.
A no-op if not running in parallel. This is a collective call.
Definition at line 560 of file UPstreamWindow.H.
References UList< T >::cdata(), create(), and UList< T >::size().

|
inline |
A window exposing the specified buffer contents.
A no-op if not running in parallel. This is a collective call.
Definition at line 572 of file UPstreamWindow.H.
References UList< T >::cdata(), create(), and UList< T >::size().

|
inline |
MPI_Win_lock() for given target rank (no assertions), optionally as exclusive lock.
Definition at line 584 of file UPstreamWindow.H.
References mpi_win_locking().

|
inline |
MPI_Win_unlock() for given target rank.
Definition at line 592 of file UPstreamWindow.H.
References mpi_win_unlocking().

|
inline |
MPI_Win_lock_all(), optionally as exclusive lock.
Definition at line 597 of file UPstreamWindow.H.
References mpi_win_locking().

|
inline |
MPI_Win_unlock_all().
Definition at line 602 of file UPstreamWindow.H.
References mpi_win_unlocking().

|
inline |
MPI_Win_flush() for given target rank.
Complete all outstanding RMA operations initiated by the calling process to the target rank.
Definition at line 610 of file UPstreamWindow.H.
References mpi_win_flushing().

|
inline |
MPI_Win_flush_all().
Complete all outstanding RMA operations at both the origin and the target
Definition at line 618 of file UPstreamWindow.H.
References mpi_win_flushing().

|
inline |
MPI_Win_flush_local().
Locally complete at the origin all outstanding RMA operations initiated by the calling process to the target process specified by rank.
Definition at line 627 of file UPstreamWindow.H.
References mpi_win_flushing().

|
inline |
MPI_Win_flush_local_all().
Locally complete at the origin all outstanding RMA operations to all targets.
Definition at line 635 of file UPstreamWindow.H.
References mpi_win_flushing().

| void sync | ( | ) |
MPI_Win_sync() - ignored if the window is not active.
Definition at line 117 of file UPstreamWindow.C.
| void close | ( | ) |
MPI_Win_free(). Closes the window view and frees any associated memory,.
eg, from allocate() or allocate_shared(). Ignored if the window is not active. This is a collective call.
Definition at line 107 of file UPstreamWindow.C.
| bool is_shared | ( | const bool | failNonShared = false | ) | const |
Test if the window is a shared memory window.
Definition at line 191 of file UPstreamWindow.C.
|
inline |
Return view of the currently exposed window content. No restriction on the type of memory associated with the window.
A no-op (empty list) if not running in parallel or the window is not active.
|
inline |
Return view of shared memory window content.
A no-op (empty list) if not running in parallel. Undefined behaviour (likely Fatal) if a shared memory window has not been allocated.
|
inline |
Get buffer contents from given rank. A no-op for an empty or null buffer, or if not running in parallel.
| buffer | Destination buffer |
| count | The data count - number of elements. Identical on both sides. |
| target_disp | Window displacement on target |
Referenced by get_value().

|
inline |
Put buffer contents to given rank.
A no-op for an empty/null buffer, or if not running in parallel.
| buffer | Source buffer |
| count | The data count - number of elements. Identical on both sides. |
| target_disp | Window displacement on target |
Referenced by put_value(), and put_value().

|
inline |
Put accumulate buffer contents to given rank.
A no-op for an empty/null buffer, or if not running in parallel.
| buffer | Source buffer |
| count | The data count - number of elements. Identical on both sides. |
| target_disp | Window displacement on target |
|
inline |
Get a single value from given rank.
| target_disp | Window displacement on target |
Definition at line 738 of file UPstreamWindow.H.
References get(), and value().

|
inline |
Put a single value to given rank.
| target_disp | Window displacement on target |
Definition at line 754 of file UPstreamWindow.H.
References put(), and value().

|
inline |
Put and accumulate a single value to given rank.
| target_disp | Window displacement on target |
Definition at line 770 of file UPstreamWindow.H.
References put(), and value().

|
inline |
Get into List storage (contiguous data only) from window location on given processor. A no-op for an empty or null buffer, or if not running in parallel.
| fromProcNo | Offset number of elements on the toProcNo rank |
| target_disp | Window displacement on target |
|
inline |
|
inline |
|
inline |
|
inline |
Combine the value of origin into the target and return the resulting value (MPI_Fetch_and_op).
| origin | the content to combine with target | |
| [out] | result | the old target value before the operation |
| target_rank | The target rank | |
| target_disp | Window displacement on target |
|
inline |
|
inline |