|
ADS
Algorithms and Data Structures
|
the mailbox of the processes of a communicator for messages of bytes, each with a tag of its own, in batches of records More...
#include <ADS/distributed/MPIMailbox.h>
Public member functions | |
| MPIByteMailbox (MPI_Comm comm=MPI_COMM_WORLD, std::size_t batch=65536) | |
| the mailbox of the processes of comm, which sends an outbox when it holds batch bytes; a collective operation | |
| ~MPIByteMailbox () | |
| the closing, if leftovers() did not do it, its messages dropped; a collective operation | |
| void | send (std::size_t to, std::uint32_t t, std::span< const std::byte > b) |
| the message of the bytes \( b \) and of the tag \( t \) appended to the outbox for to, which is sent when it holds a batch; never waits, and after the stop only appends | |
| void | flush (void) |
| the outboxes sent, unless stopped | |
| template<class F> | |
| std::size_t | poll (F &&f) |
| the calls f( t , b ) on the messages received, of tag \( t \) and bytes \( b \) (valid during the call, at an offset multiple of 8 of a buffer that new allocated), and their number; nothing after the stop | |
| bool | quiescent (void) |
| true if the computation has ended, or its stop; called with no work left, it sends the outboxes (unless stopped) and joins the waves | |
| template<class F> | |
| std::size_t | leftovers (F &&f) |
| the calls f( t , b ) on the messages left to this process, those on their way to it, those to itself and those of its outboxes, and their number: a collective operation after quiescent() has returned true, after which every message sent has been handed to a function once, by a poll() or here | |
the mailbox of the processes of a communicator for messages of bytes, each with a tag of its own, in batches of records
|
inlineexplicit |
the mailbox of the processes of comm, which sends an outbox when it holds batch bytes; a collective operation
|
inline |
the closing, if leftovers() did not do it, its messages dropped; a collective operation
|
inline |
the outboxes sent, unless stopped
|
inline |
the calls f( t , b ) on the messages left to this process, those on their way to it, those to itself and those of its outboxes, and their number: a collective operation after quiescent() has returned true, after which every message sent has been handed to a function once, by a poll() or here
|
inline |
the calls f( t , b ) on the messages received, of tag \( t \) and bytes \( b \) (valid during the call, at an offset multiple of 8 of a buffer that new allocated), and their number; nothing after the stop
In pseudocode (beyond the book), \( r \) the messages received:
\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{function}\ \mathrm{poll}( f ) \cr 2 & \quad \textbf{if}\ \text{stopped}\ \textbf{then return}\ 0 \cr 3 & \quad \text{free the buffers of the sends that } \mathrm{MPI\_Testsome} \text{ finds completed} \cr 4 & \quad n \gets 0;\ \textbf{foreach}\ \text{record } ( t , b ) \text{ to itself}\ \textbf{do}\ f( t , b );\ n \gets n + 1 \cr 5 & \quad \textbf{while}\ \mathrm{MPI\_Iprobe}( \text{any source} ) \text{ finds a batch}\ \textbf{do} \cr 6 & \qquad \textbf{if}\ \text{it is empty}\ \textbf{then} \ \text{stopped};\ \textbf{break}\quad \triangleright \ \text{the note of a stop} \cr 7 & \qquad \mathrm{MPI\_Recv};\ \textbf{foreach}\ \text{record } ( t , b )\ \textbf{do}\ f( t , b );\ n \gets n + 1 \cr 8 & \quad r \gets r + n;\ \textbf{return}\ n \end{array}} \]
|
inline |
true if the computation has ended, or its stop; called with no work left, it sends the outboxes (unless stopped) and joins the waves
|
inline |
the message of the bytes \( b \) and of the tag \( t \) appended to the outbox for to, which is sent when it holds a batch; never waits, and after the stop only appends
In pseudocode (beyond the book), \( O_{\mathit{to}} \) the outbox:
\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{procedure}\ \mathrm{send}( \mathit{to} , t , b ) \cr 2 & \quad \text{append to } O_{\mathit{to}} \text{ the record of } t \text{, of } |b| \text{ and of } b \text{, padded to 8 bytes} \cr 3 & \quad \textbf{if}\ |O_{\mathit{to}}| \ge \mathit{batch} \ \textbf{and not stopped then}\ \mathrm{post}( \mathit{to} ) \end{array}} \]