ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
GhostComm::anonymous_namespace{HaloExchange.cpp} Namespace Reference

Enumerations

enum  GhostTag : int {
  TAG_POSITION = 100 , TAG_FORCE = 101 , TAG_PARTNUM = 102 , TAG_DEFAULT = 103 ,
  TAG_BONDS = 104
}
 MPI tags for ghost communications. More...
 

Functions

int main_tag (unsigned data_parts)
 
std::span< ParticleList *const > as_span (std::vector< ParticleList * > const &v)
 View a list of cell pointers as a span for the packing routines.
 
std::vector< ParticleList * > region_cells (std::vector< SendRegion > const &send)
 Extract the plain cell pointers from a list of send regions.
 
void pack_regions (CommBuf &buf, std::vector< SendRegion > const &regions, BoxGeometry const &box, unsigned data_parts)
 Pack all send regions of one NeighborComm into a single buffer.
 
void run_collective (HaloPlan const &plan, BoxGeometry const &box, unsigned data_parts, ExchangeOp op)
 Collective (broadcast/reduce-sum) section.
 

Enumeration Type Documentation

◆ GhostTag

enum GhostComm::anonymous_namespace{HaloExchange.cpp}::GhostTag : int

MPI tags for ghost communications.

One tag per exchange-kind keeps concurrent exchanges (a future goal) from aliasing: within a single exchange each message is already uniquely matched by (peer, tag). The BONDS transfer needs its own tag because it is sent as a second message to the same peer, mirroring the legacy two-transfer.

Enumerator
TAG_POSITION 
TAG_FORCE 
TAG_PARTNUM 
TAG_DEFAULT 
TAG_BONDS 

Definition at line 61 of file HaloExchange.cpp.

Function Documentation

◆ as_span()

std::span< ParticleList *const > GhostComm::anonymous_namespace{HaloExchange.cpp}::as_span ( std::vector< ParticleList * > const &  v)

View a list of cell pointers as a span for the packing routines.

Definition at line 83 of file HaloExchange.cpp.

References as_span().

Referenced by as_span(), and pack_regions().

◆ main_tag()

int GhostComm::anonymous_namespace{HaloExchange.cpp}::main_tag ( unsigned  data_parts)

◆ pack_regions()

void GhostComm::anonymous_namespace{HaloExchange.cpp}::pack_regions ( CommBuf buf,
std::vector< SendRegion > const &  regions,
BoxGeometry const &  box,
unsigned  data_parts 
)

Pack all send regions of one NeighborComm into a single buffer.

All regions are packed with a single pack_cells call so that bonds produce exactly one boost binary archive per neighbor message – matching the single unpack_cells call on the receive side. Concatenating per-region archives would corrupt the bond stream (the second archive header is misread as bond data by the receiver).

Per-region shifts are honored via the common shift. All SendRegion.shift values within a NeighborComm are equal — RegularDecomposition:: make_halo_plan() sets them all to {}. This lets us pack every region's cells in one pack_cells call (a single bond archive, matching the receiver's single unpack_cells).

Note
If a future decomposition (e.g. a Lees-Edwards refactor) ever stores DISTINCT per-region shifts, pack_regions must be generalized to pack each region's non-bond (flat) data with its own shift while still writing all bonds into ONE shared archive — do not simply concatenate per-region archives (that was the bond-corruption bug fixed in commit 314e7c366b).

Definition at line 117 of file HaloExchange.cpp.

References as_span(), Utils::Vector< T, N >::empty(), Utils::Vector< T, N >::front(), GhostComm::pack_cells(), pack_regions(), and region_cells().

Referenced by pack_regions().

◆ region_cells()

std::vector< ParticleList * > GhostComm::anonymous_namespace{HaloExchange.cpp}::region_cells ( std::vector< SendRegion > const &  send)

Extract the plain cell pointers from a list of send regions.

Definition at line 88 of file HaloExchange.cpp.

References region_cells().

Referenced by pack_regions(), and region_cells().

◆ run_collective()

void GhostComm::anonymous_namespace{HaloExchange.cpp}::run_collective ( HaloPlan const &  plan,
BoxGeometry const &  box,
unsigned  data_parts,
ExchangeOp  op 
)

Collective (broadcast/reduce-sum) section.

For each root rank in [0, comm.size()):

  1. Broadcast (Push): root packs its owned cell (cells[root]) and broadcasts the buffer to all ranks; every non-root rank unpacks into cells[root] (their ghost copy of root's data).
  2. ReduceSum (Reduce): every rank packs cells[root] (ghost-force contribution) and reduces to root with std::plus on the raw double buffer; root unpacks into cells[root] (the owned cell, so forces accumulate there).

The legacy code uses one GHOST_BCST (or GHOST_RDCE) step per rank, each step addressing a single cell pointer (ghost_comm.part_lists[0] == &cells.at(n)). We replicate that loop exactly.

Definition at line 155 of file HaloExchange.cpp.

References GhostComm::CommBuf::bonds(), GhostComm::calc_transmit_size(), GhostComm::HaloPlan::collective, GhostComm::HaloPlan::comm, GhostComm::ExchangeOp::direction, GhostComm::None, GhostComm::pack_cells(), GhostComm::Push, GhostComm::CommBuf::resize(), run_collective(), GhostComm::CommBuf::size(), and GhostComm::unpack_cells().

Referenced by run_collective().