core 1.5.0
Shared MPI block decomposition, asynchronous ghost-layer exchange, SDF geometry, load balancing (header-only C++20)
Loading...
Searching...
No Matches
peclet::core::decomp::RedistributeTopology< Dim, T > Class Template Reference

The planned, repeatable movement of a multigrid level's fields onto a stage target and back (the file comment has the per-kind collectives and the layout contract). More...

#include <redistribute_topology.hpp>

Public Member Functions

 RedistributeTopology ()=default
 
template<class SrcIndex , class DstIndex >
void build (const BlockDecomposer< Dim > &src, const StageTarget< Dim > &dst, const StageComm &c, SrcIndex &&srcIndex, DstIndex &&dstIndex, int id=0)
 Establish the movement from src (the level's current decomposition; parent rank r owns block r) to dst for the communicators c (makeStageComm(parent, dst)).
 
StageKind kind () const
 The kind of the target this topology was built for (InPlace before build()).
 
bool active () const
 Whether this rank holds target fields (dst in forward, the input of backward).
 
std::size_t numSourceCells () const
 Cells of this rank's current block (the extent srcIndex was called on).
 
std::size_t numTargetCells () const
 Cells of this rank's target block (0 on an inactive rank).
 
void forward (const std::vector< const T * > &src, const std::vector< T * > &dst)
 Level -> target.
 
void backward (const std::vector< const T * > &dst, const std::vector< T * > &src)
 Target -> level, overwriting src[f] on this rank's current block.
 

Static Public Attributes

static constexpr int kTagBase = 1
 Repartition's point-to-point tags: kTagBase + id for the per-topology id passed to build(), id in [0, kTagSpan) — [1, 10], below the AMR direct tags (11 / 41 / 45) and never the halo default 0 (core CLAUDE.md: direct tags stay below NBX's reserved [24576, 32768)).
 
static constexpr int kTagSpan = 10
 Number of distinct ids, hence the tags kTagBase .. kTagBase + kTagSpan - 1.
 

Detailed Description

template<int Dim, class T>
class peclet::core::decomp::RedistributeTopology< Dim, T >

The planned, repeatable movement of a multigrid level's fields onto a stage target and back (the file comment has the per-kind collectives and the layout contract).

Built once per hierarchy build by build(); forward() / backward() then move T payload with no handshake.

T must be trivially copyable (it travels as raw bytes). The topology stores the raw communicator handles of the StageComm given to build(), so that StageComm must outlive every forward()/backward(). The staging buffers are members: one topology is not safe to use from two threads at once. Host-staged, MPI only.

Definition at line 64 of file redistribute_topology.hpp.

Constructor & Destructor Documentation

◆ RedistributeTopology()

template<int Dim, class T >
peclet::core::decomp::RedistributeTopology< Dim, T >::RedistributeTopology ( )
default

Member Function Documentation

◆ build()

template<int Dim, class T >
template<class SrcIndex , class DstIndex >
void peclet::core::decomp::RedistributeTopology< Dim, T >::build ( const BlockDecomposer< Dim > &  src,
const StageTarget< Dim > &  dst,
const StageComm &  c,
SrcIndex &&  srcIndex,
DstIndex &&  dstIndex,
int  id = 0 
)
inline

Establish the movement from src (the level's current decomposition; parent rank r owns block r) to dst for the communicators c (makeStageComm(parent, dst)).

Collective-free: every rank derives the whole pattern from the replicated decompositions. srcIndex / dstIndex map a global cell (IVec<Dim>) of this rank's current / target block to its slot in the caller's arrays; each is called once per cell here and never again. id (Repartition only; ignored otherwise) is the per-topology tag offset — the level index — so two levels' stages on one communicator cannot pair messages across each other.

Preconditions: every rank passes the same replicated src and dst (with dst the target c was made for), and src.numBlocks() equals the size of the parent communicator. Throws std::invalid_argument for an InPlace target, a StageComm made for another target, source and target over different grids, a block count that is not one per parent rank, a Repartition id outside [0, kTagSpan) or a malformed Repartition target, or an index functor mapping two cells to one slot; std::logic_error when the blocks do not tile the target (a broken decomposition). build() does not communicate, so a throw is local: the checks on replicated inputs fire on every rank alike, the ones on the caller's index functors need not — treat any throw as fatal rather than letting the other ranks go on to forward().

Definition at line 95 of file redistribute_topology.hpp.

References peclet::core::decomp::StageComm::active, peclet::core::decomp::StageComm::group, peclet::core::decomp::StageComm::kind, peclet::core::decomp::StageComm::members, MPI_Comm_rank(), MPI_Comm_size(), peclet::core::decomp::StageComm::myTargetBlock, peclet::core::decomp::StageComm::parent, peclet::core::decomp::Repartition, peclet::core::decomp::Replicated, and peclet::core::decomp::SiblingMerge.

◆ kind()

template<int Dim, class T >
StageKind peclet::core::decomp::RedistributeTopology< Dim, T >::kind ( ) const
inline

The kind of the target this topology was built for (InPlace before build()).

Definition at line 157 of file redistribute_topology.hpp.

◆ active()

template<int Dim, class T >
bool peclet::core::decomp::RedistributeTopology< Dim, T >::active ( ) const
inline

Whether this rank holds target fields (dst in forward, the input of backward).

Definition at line 159 of file redistribute_topology.hpp.

◆ numSourceCells()

template<int Dim, class T >
std::size_t peclet::core::decomp::RedistributeTopology< Dim, T >::numSourceCells ( ) const
inline

Cells of this rank's current block (the extent srcIndex was called on).

Definition at line 161 of file redistribute_topology.hpp.

◆ numTargetCells()

template<int Dim, class T >
std::size_t peclet::core::decomp::RedistributeTopology< Dim, T >::numTargetCells ( ) const
inline

Cells of this rank's target block (0 on an inactive rank).

Definition at line 163 of file redistribute_topology.hpp.

◆ forward()

template<int Dim, class T >
void peclet::core::decomp::RedistributeTopology< Dim, T >::forward ( const std::vector< const T * > &  src,
const std::vector< T * > &  dst 
)
inline

Level -> target.

Collective on the movement's communicator: every rank takes part, active or not. src[f] is field f on this rank's current block; dst[f] (read on active ranks only; may be empty elsewhere) receives it on the target block. Target slots not named by dstIndex are untouched. The field count must be the same on every rank. Throws std::invalid_argument when an active rank's src and dst differ in field count (or, for Repartition, a rank that sends or receives lacks a field), and std::overflow_error when one message would exceed INT_MAX bytes (MPI's int counts) — both checked on the calling rank before its own MPI call, so a throw on one rank leaves its peers waiting: treat it as fatal.

Definition at line 173 of file redistribute_topology.hpp.

References MPI_BYTE, peclet::core::decomp::Repartition, and peclet::core::decomp::SiblingMerge.

◆ backward()

template<int Dim, class T >
void peclet::core::decomp::RedistributeTopology< Dim, T >::backward ( const std::vector< const T * > &  dst,
const std::vector< T * > &  src 
)
inline

Target -> level, overwriting src[f] on this rank's current block.

SiblingMerge: collective on the group communicator (dst read on the owner only). Replicated: no communication — every rank picks its own cells from its replicated target. Repartition: the mirror of forward on the parent communicator (dst read on active ranks only). Same field-count contract and throws as forward().

Definition at line 215 of file redistribute_topology.hpp.

References MPI_BYTE, peclet::core::decomp::Repartition, and peclet::core::decomp::Replicated.

Member Data Documentation

◆ kTagBase

template<int Dim, class T >
constexpr int peclet::core::decomp::RedistributeTopology< Dim, T >::kTagBase = 1
staticconstexpr

Repartition's point-to-point tags: kTagBase + id for the per-topology id passed to build(), id in [0, kTagSpan) — [1, 10], below the AMR direct tags (11 / 41 / 45) and never the halo default 0 (core CLAUDE.md: direct tags stay below NBX's reserved [24576, 32768)).

Definition at line 73 of file redistribute_topology.hpp.

◆ kTagSpan

template<int Dim, class T >
constexpr int peclet::core::decomp::RedistributeTopology< Dim, T >::kTagSpan = 10
staticconstexpr

Number of distinct ids, hence the tags kTagBase .. kTagBase + kTagSpan - 1.

Definition at line 75 of file redistribute_topology.hpp.


The documentation for this class was generated from the following file: