|
Nektar++
|
ITransport implementation performing a personalised all-to-all on a (bisected) hypercube (a Fox/gslib-style crystal router). More...
#include <Transport.hpp>
Classes | |
| struct | Record |
| One message in flight, as an index into m_pool. More... | |
Public Member Functions | |
| CrystalRouterTransport (CommSharedPtr comm) | |
Construct a transport bound to comm. | |
| int | Rank () const override |
| int | Size () const override |
| CommSharedPtr | Comm () const override |
| void | Exchange (std::vector< RoutedMessage > &outbound, std::vector< RoutedMessage > &inbound) override |
| Personalised all-to-all via recursive-bisection hypercube routing. | |
Public Member Functions inherited from Nektar::LibUtilities::ITransport | |
| virtual | ~ITransport ()=default |
Private Member Functions | |
| void | Flatten (const std::vector< RoutedMessage > &outbound) |
Copy outbound into the flat (m_recs, m_pool) form routing works on. The only place a caller's per-message buffer is read. | |
| void | Rebuild (std::vector< RoutedMessage > &inbound) |
| Hand the routed records back as RoutedMessage, the one allocation per message the interface obliges us to make. | |
| void | PackSend (const std::vector< Record > &send) |
Write the records selected by send into m_sendBuf, in wire format: a record count, then per record its header and payload. | |
| void | UnpackInto (const std::vector< std::byte > &buf, size_t &liveBytes) |
Append the records in buf (wire format, from PackSend()) to m_recs, their payloads going on the end of m_pool. | |
| void | ExchangeWith (int partner) |
Symmetric size-then-data exchange of m_sendBuf with partner, leaving the reply in m_recvBuf. | |
| void | SendOneWay (int partner) |
One-way forward of m_sendBuf from an unpaired rank in the larger half to partner, which has no direct partner this round. | |
| void | RecvOneWay (int partner) |
| Receive the mirror side of a SendOneWay() into m_recvBuf. | |
| void | Route () |
| Drive the recursive-bisection hypercube routing loop until every record in m_recs has reached its destination rank. | |
| void | Compact () |
| Rebuild the pool from the live records, dropping departed payloads. | |
Private Attributes | |
| std::vector< Record > | m_recs |
| Records in flight, and the contiguous pool their payloads live in. | |
| std::vector< std::byte > | m_pool |
| std::vector< Record > | m_keep |
| Scratch for one round, kept as members so the buffers are grown once and then reused for the life of the transport. | |
| std::vector< Record > | m_send |
| std::vector< std::byte > | m_next |
| std::vector< std::byte > | m_sendBuf |
| std::vector< std::byte > | m_recvBuf |
| CommSharedPtr | m_comm |
| int | m_nproc = 0 |
| int | m_rank = 0 |
Static Private Attributes | |
| static constexpr size_t | kHeaderBytes = 3 * sizeof(int32_t) |
| Bytes of a record's wire header: dest, src, len. | |
| static constexpr size_t | kCompactSlack = 64 * 1024 |
| Slack below which reclaiming departed payloads is not worth a pass. | |
ITransport implementation performing a personalised all-to-all on a (bisected) hypercube (a Fox/gslib-style crystal router).
O(log P) communication rounds; each message is forwarded at most log2(P) hops, with no O(P) arrays. This is the variant to use at very large rank counts.
The recursive-bisection formulation in Route() handles non-power-of-two rank counts directly: at each step the current group [lo, hi] is split into [lo, mid] and [mid+1, hi]. Equal halves pair up directly; an odd split leaves one unpaired rank in the larger half, which forwards its cross-group messages one-way to a designated rank in the other half.
Definition at line 594 of file Transport.hpp.
|
inlineexplicit |
Construct a transport bound to comm.
| comm | Communicator whose ranks participate in each Exchange(). |
Definition at line 599 of file Transport.hpp.
|
inlineoverridevirtual |
Implements Nektar::LibUtilities::ITransport.
Definition at line 613 of file Transport.hpp.
References m_comm.
|
inlineprivate |
Rebuild the pool from the live records, dropping departed payloads.
Definition at line 915 of file Transport.hpp.
References m_next, m_pool, and m_recs.
Referenced by Route().
|
inlineoverridevirtual |
Personalised all-to-all via recursive-bisection hypercube routing.
| [in,out] | outbound | Messages to send, at most one per destination rank; moved from on entry. |
| [out] | inbound | Filled with every message addressed to this rank once routing completes (i.e. once dest == Rank() for all of them). |
Implements Nektar::LibUtilities::ITransport.
Definition at line 626 of file Transport.hpp.
|
inlineprivate |
Symmetric size-then-data exchange of m_sendBuf with partner, leaving the reply in m_recvBuf.
Definition at line 795 of file Transport.hpp.
References m_comm, m_recvBuf, and m_sendBuf.
Referenced by Route().
|
inlineprivate |
Copy outbound into the flat (m_recs, m_pool) form routing works on. The only place a caller's per-message buffer is read.
Definition at line 668 of file Transport.hpp.
References m_pool, and m_recs.
Referenced by Exchange().
|
inlineprivate |
Write the records selected by send into m_sendBuf, in wire format: a record count, then per record its header and payload.
The count is always written, so the buffer is never empty and never reaches Comm's GetPointer(), which asserts on an empty container.
Definition at line 722 of file Transport.hpp.
References kHeaderBytes, m_pool, and m_sendBuf.
Referenced by Route().
|
inlineoverridevirtual |
Implements Nektar::LibUtilities::ITransport.
Definition at line 605 of file Transport.hpp.
References m_rank.
|
inlineprivate |
Hand the routed records back as RoutedMessage, the one allocation per message the interface obliges us to make.
Definition at line 700 of file Transport.hpp.
References Nektar::LibUtilities::RoutedMessage::bytes, Nektar::LibUtilities::RoutedMessage::dest, m_pool, m_recs, and Nektar::LibUtilities::RoutedMessage::src.
Referenced by Exchange().
|
inlineprivate |
Receive the mirror side of a SendOneWay() into m_recvBuf.
Definition at line 818 of file Transport.hpp.
References m_comm, and m_recvBuf.
Referenced by Route().
|
inlineprivate |
Drive the recursive-bisection hypercube routing loop until every record in m_recs has reached its destination rank.
Each iteration narrows the active group [lo, hi] by half (via detail::CrystalPlanStep) and moves any record whose destination is no longer in this rank's half across to a partner (or forwards it one-way if unpaired), so after ceil(log2(nproc)) rounds every record has arrived. Records that stay are compacted into m_next alongside the ones that arrive, so the pool never accumulates the payloads of records that have left.
Definition at line 839 of file Transport.hpp.
References Compact(), Nektar::LibUtilities::detail::CrystalDestInMyHalf(), Nektar::LibUtilities::detail::CrystalPlanStep(), ExchangeWith(), Nektar::LibUtilities::detail::CrystalStep::forwardTo, hi, Nektar::LibUtilities::detail::CrystalStep::inLow, kCompactSlack, lo, m_keep, m_nproc, m_pool, m_rank, m_recs, m_recvBuf, m_send, Nektar::LibUtilities::detail::CrystalStep::mid, PackSend(), Nektar::LibUtilities::detail::CrystalStep::partner, Nektar::LibUtilities::detail::CrystalStep::recvForwardFrom, RecvOneWay(), SendOneWay(), and UnpackInto().
Referenced by Exchange().
|
inlineprivate |
|
inlineoverridevirtual |
Implements Nektar::LibUtilities::ITransport.
Definition at line 609 of file Transport.hpp.
References m_nproc.
|
inlineprivate |
Append the records in buf (wire format, from PackSend()) to m_recs, their payloads going on the end of m_pool.
Definition at line 753 of file Transport.hpp.
References ASSERTL1, kHeaderBytes, m_pool, and m_recs.
Referenced by Route().
|
staticconstexprprivate |
Slack below which reclaiming departed payloads is not worth a pass.
Definition at line 662 of file Transport.hpp.
Referenced by Route().
|
staticconstexprprivate |
Bytes of a record's wire header: dest, src, len.
Definition at line 659 of file Transport.hpp.
Referenced by PackSend(), and UnpackInto().
|
private |
Definition at line 936 of file Transport.hpp.
Referenced by Comm(), ExchangeWith(), RecvOneWay(), and SendOneWay().
|
private |
Scratch for one round, kept as members so the buffers are grown once and then reused for the life of the transport.
Definition at line 933 of file Transport.hpp.
Referenced by Route().
|
private |
Definition at line 934 of file Transport.hpp.
Referenced by Compact().
|
private |
Definition at line 937 of file Transport.hpp.
|
private |
Definition at line 930 of file Transport.hpp.
Referenced by Compact(), Flatten(), PackSend(), Rebuild(), Route(), and UnpackInto().
|
private |
Definition at line 938 of file Transport.hpp.
|
private |
Records in flight, and the contiguous pool their payloads live in.
Definition at line 929 of file Transport.hpp.
Referenced by Compact(), Flatten(), Rebuild(), Route(), and UnpackInto().
|
private |
Definition at line 934 of file Transport.hpp.
Referenced by ExchangeWith(), RecvOneWay(), and Route().
|
private |
Definition at line 933 of file Transport.hpp.
Referenced by Route().
|
private |
Definition at line 934 of file Transport.hpp.
Referenced by ExchangeWith(), PackSend(), and SendOneWay().