|
Nektar++
|
Personalised all-to-all exchange of opaque byte blobs, and the overview of the shared-id module built on it. More...
#include <algorithm>#include <chrono>#include <cstddef>#include <cstdint>#include <cstring>#include <functional>#include <limits>#include <memory>#include <set>#include <type_traits>#include <unordered_map>#include <utility>#include <vector>#include <LibUtilities/BasicUtils/ErrorUtil.hpp>#include <LibUtilities/Communication/Comm.h>Go to the source code of this file.
Classes | |
| struct | Nektar::LibUtilities::detail::CrystalStep |
| Crystal-router routing decision for one bisection step. More... | |
| struct | Nektar::LibUtilities::RoutedMessage |
| An opaque byte payload plus routing metadata. More... | |
| class | Nektar::LibUtilities::ITransport |
| Abstract interface for a personalised all-to-all exchange of opaque byte blobs. More... | |
| class | Nektar::LibUtilities::AlltoallvTransport |
ITransport implementation built on MPI_Alltoall (of counts) followed by MPI_Alltoallv (of data). More... | |
| class | Nektar::LibUtilities::CrystalRouterTransport |
| ITransport implementation performing a personalised all-to-all on a (bisected) hypercube (a Fox/gslib-style crystal router). More... | |
| struct | Nektar::LibUtilities::CrystalRouterTransport::Record |
| One message in flight, as an index into m_pool. More... | |
Namespaces | |
| namespace | Nektar |
| namespace | Nektar::LibUtilities |
| namespace | Nektar::LibUtilities::detail |
Functions | |
| template<typename T > | |
| void | Nektar::LibUtilities::detail::PackPod (std::vector< std::byte > &buf, const T &v) |
| Append a trivially-copyable POD value to a byte buffer. | |
| template<typename T > | |
| T | Nektar::LibUtilities::detail::UnpackPod (const std::byte *&cur) |
| Read a trivially-copyable POD value from a cursor and advance it. | |
| CrystalStep | Nektar::LibUtilities::detail::CrystalPlanStep (int lo, int hi, int rank) |
| Compute this rank's routing decision for one bisection step of the crystal router. | |
| bool | Nektar::LibUtilities::detail::CrystalDestInMyHalf (const CrystalStep &s, int dest) |
Test whether a message destined for dest belongs in the querying rank's half of the current bisection. | |
| int | Nektar::LibUtilities::detail::RendezvousRank (int64_t id, int nproc) |
| Bit-mixing hash (splitmix64 finaliser) mapping an entity id to its rendezvous rank, so sequential IDs spread across rendezvous ranks and don't create hot spots. | |
| std::vector< RoutedMessage > | Nektar::LibUtilities::detail::DrainBucketsToMessages (std::unordered_map< int, std::vector< std::byte > > &buckets, int selfRank) |
| Move sparse per-destination byte buckets into transport messages, clearing the buckets. | |
| CommSharedPtr | Nektar::LibUtilities::detail::BuildNeighbourComm (const CommSharedPtr &base, int selfRank, const std::unordered_map< int64_t, std::vector< int > > &sharers) |
| Build a persistent distributed-graph communicator over the discovered topological neighbours (self excluded). | |
Personalised all-to-all exchange of opaque byte blobs, and the overview of the shared-id module built on it.
This header is the bottom layer, holding #ITransport, its two implementations and the detail helpers the layers above share. Every other header in the module includes it, so the module overview lives here:
Several places in the code need to answer "for every global entity ID I touch (vertex / edge / face, possibly periodically identified), find every other rank that also touches it and agree on a canonical value (e.g. the highest polynomial order)". The naive implementation AllReduces arrays sized by the global entity count onto every rank: O(N_global) memory per rank and O(N_global * P) total bandwidth. This does not scale to large rank counts.
There are three main classes:
gs_setup / gs_gather / gs_unique, and what SharedPayloadResolver::Setup() builds. Code working on flat arrays (assembly maps) uses it directly, usually through LibUtilities::GatherScatter.There are also some additional utility classes:
MPI_Alltoall of counts + MPI_Alltoallv of data. Simple and robust; keeps O(P) count arrays, so suitable below a few thousand ranks.Memory per rank is O(local entities); nothing is ever sized by P or by the global entity count. Every map that persists past a call – Nektar::LibUtilities::SharedPayloadResolver::m_sharedPayloads and the ConnectivityResolver equivalent – is keyed only by entities this rank actually registered or was a rendezvous host for, so its size is bounded by local entity count plus, in expectation, N_global / P at the rendezvous step. No structure is ever sized by P or by N_global directly. The sharer lists let you build a persistent neighbourhood communicator (BuildNeighbourComm()) so downstream halo-style exchanges become cheap neighbourhood collectives.
This O(local) claim is about the number of entities, not the fan-out of any one of them: ConnectivityResolver's reply phase sends the full k-entry sharer list to each of an entity's k sharers, so wire volume for a single high-fan-out entity is O(k^2). Fine at the k=2-8 typical of facet/edge adjacency; worth watching for entities that can be shared by dozens of ranks (e.g. a partition corner with periodicity) or, at very large rank counts, a genuinely global entity.
Payloads are shipped as raw bytes (no custom MPI datatype), which assumes a homogeneous cluster: all ranks share the same endianness and struct layout for PayloadT. True of essentially every HPC deployment, but not checked or enforced here.
Out of the box a resolver answers its question once: every Resolve() rediscovers the sharers. That is optimal for a one-off agreement but wasteful when the same ids are resolved again and again with new values – the gslib use case. For that, #SharedIdPlan pays discovery once in its constructor, and every Gather() / Reduce() thereafter is a single neighbour exchange carrying only values – no ids, no counts, no rendezvous – over the backend chosen by #ExchangeBackend. SharedPayloadResolver offers the same split behind its id-keyed interface: Register() the ids once, call Setup() once, then update payloads with SetPayload() and Resolve() as often as needed.
Definition in file Transport.hpp.