46#ifndef Foam_UPstreamWindow_H
47#define Foam_UPstreamWindow_H
86 if constexpr (std::is_void_v<Type>) {
return 1; }
87 else {
return sizeof(Type); }
98 std::streamsize num_elements,
105 const bool shared =
false
116 std::streamsize num_elements,
123 const bool shared =
false
134 std::streamsize num_elements,
150 std::streamsize num_elements,
167 const int expected_disp_unit
181 const int expected_disp_unit
199 std::streamsize count,
212 std::streamsize count,
227 std::streamsize count,
286 return (value_ ==
rhs.value_);
292 return (value_ !=
rhs.value_);
324 return reinterpret_cast<const void*
>(value_);
348 std::streamsize count,
351 const
bool shared = false
361 std::streamsize count,
364 const
bool shared = false
374 std::streamsize count,
385 std::streamsize count,
395 template<class Type =
void>
404 template<
class Type =
void>
405 bool create(std::nullptr_t,
const int comm)
420 std::streamsize count,
432 std::streamsize count,
477 void lock(
int rank,
bool exclusive=
false)
526 bool is_shared(
const bool failNonShared =
false)
const;
553 std::streamsize count,
566 std::streamsize count,
581 std::streamsize count,
596 return this->
get(&value, 1, fromProcNo, target_disp);
609 return this->
put(&value, 1, toProcNo, target_disp);
623 return this->
put(opCodeId, &
value, 1, toProcNo, target_disp);
729 #include "UPstreamWindow.txx"
A non-owning sub-view of a List (allocated or unallocated storage).
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
const T * cdata() const noexcept
Return pointer to the underlying array serving as data storage.
void size(const label n)
Older name for setAddressableSize.
An opaque wrapper for MPI_Comm with a vendor-independent representation without any <mpi....
An opaque wrapper for MPI_Win with a vendor-independent representation and without any <mpi....
bool create(const Type *buffer, std::streamsize count, UPstream::Communicator communicator)
A window exposing an existing memory region.
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.
bool put_value(const Type &value, int toProcNo, int target_disp=0) const
Put a single value to given rank.
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 a...
UList< Type > view() const
Return view of the currently exposed window content. No restriction on the type of memory associated ...
Window() noexcept
Default construct as MPI_WIN_NULL.
void reset() noexcept
Reset to default constructed value (MPI_WIN_NULL).
void unlock_all()
MPI_Win_unlock_all().
void unlock(int rank)
MPI_Win_unlock() for given target rank.
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(),...
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.
Window(Window &&) noexcept=default
Move construct.
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.
const void * pointer() const noexcept
Return as pointer value.
bool create(SubList< Type > buffer, UPstream::Communicator communicator)
A window exposing the specified buffer contents.
void flush_local_all()
MPI_Win_flush_local_all().
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.
value_type value() const noexcept
Return raw value.
void mpi_win_unlocking(int rank)
Entry point to MPI_Win_unlock(), MPI_Win_unlock_all().
bool good() const noexcept
True if not equal to MPI_WIN_NULL.
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....
void close()
MPI_Win_free(). Closes the window view and frees any associated memory,.
void mpi_win_locking(int rank, bool exclusive=false)
Entry point to MPI_Win_lock(), MPI_Win_lock_all(), optionally as exclusive lock.
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 parall...
bool put(const Type *buffer, std::streamsize count, int toProcNo, int target_disp=0) const
Put buffer contents to given rank.
std::intptr_t value_type
Storage for MPI_Win (as integer or pointer).
void lock_all(bool exclusive=false)
MPI_Win_lock_all(), optionally as exclusive lock.
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().
void flush_all()
MPI_Win_flush_all().
static constexpr auto element_width() noexcept
Sizing helper for disp_unit.
Window(const Window &) noexcept=default
Copy construct.
void lock(int rank, bool exclusive=false)
MPI_Win_lock() for given target rank (no assertions), optionally as exclusive lock.
bool create(const UList< Type > &buffer, UPstream::Communicator comm)
A window exposing the specified buffer contents.
bool create(const Type *buffer, std::streamsize count, const int communicator)
A window exposing an existing memory region.
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.
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 a...
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....
Window(value_type val) noexcept
Construct from MPI_Win (as integer type).
bool operator!=(const Window &rhs) const noexcept
Test for inequality.
bool create(SubList< Type > buffer, int communicator)
A window exposing the specified buffer contents.
bool create(std::nullptr_t, UPstream::Communicator comm)
A window exposing a zero-sized memory region.
bool get_value(Type &value, int fromProcNo, int target_disp=0) const
Get a single value from given rank.
UList< Type > allocate_shared(std::streamsize count, UPstream::Communicator communicator)
Allocate a shared memory region and create window onto it.
bool create(std::nullptr_t, const int comm)
A window exposing a zero-sized memory region.
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).
void sync()
MPI_Win_sync() - ignored if the window is not active.
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....
bool is_shared(const bool failNonShared=false) const
Test if the window is a shared memory window.
UList< Type > view_shared(int target_rank) const
Return view of shared memory window content.
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....
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()...
bool create(const UList< Type > &buffer, int communicator)
A window exposing the specified buffer contents.
UList< Type > allocate(std::streamsize count, UPstream::Communicator communicator, const bool shared=false)
Allocate a local memory region and create window onto it.
void flush_local(int rank)
MPI_Win_flush_local().
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....
int size() const
The number of ranks associated with the window group.
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.
void flush(int rank)
MPI_Win_flush() for given target rank.
Wrapper for internally indexed communicator label. Always invokes UPstream::allocateCommunicatorCompo...
opCodes
Mapping of some MPI op codes.
UPstream(const commsTypes commsType) noexcept
Construct for given communication type.
dataTypes
Mapping of some fundamental and aggregate types to MPI data types.
limits reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL))
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)