core 1.8.1
Shared MPI block decomposition, asynchronous ghost-layer exchange, SDF geometry, load balancing (header-only C++20)
Loading...
Searching...
No Matches
grid_halo_topology.hpp
Go to the documentation of this file.
1// core — asynchronous ghost-layer exchange for a block-decomposed structured grid.
2//
3// Design (see suite/docs/INTERFACES.md): TOPOLOGY is separated from EXCHANGE.
4// * buildTopology() (done once, or on re-decomposition) figures out, for every ghost cell of this
5// rank's block, which rank owns the corresponding global cell (with periodic wrap), then does a
6// single NBX round so each owner learns which of its inner cells to send. The result is matched
7// send/recv index lists plus a local self-copy list (for periodic wrap onto one's own block).
8// * exchange*(field) (done every step) just moves payload. It is FIELD-AGNOSTIC: any type with
9// bytesPerElem()/pack(localIdx,dst)/unpack(localIdx,src) works, so a scalar grid field, a
10// vector grid field, or (later) a particle attribute array all flow through one path.
11//
12// Two interchangeable engines, identical results:
13// exchangeNbx(field) — nonblocking-consensus; robust for dynamic/sparse patterns.
14// exchangePersistent(field) — MPI_Neighbor_alltoallv on a cached distributed-graph communicator;
15// fastest for the STATIC neighbour pattern of a fixed grid.
16// Both support compute/comm overlap via start()/wait() (NBX) — see exchangeNbx.
17#ifndef PECLET_CORE_HALO_GRID_HALO_TOPOLOGY_HPP
18#define PECLET_CORE_HALO_GRID_HALO_TOPOLOGY_HPP
19
20#include <cstring>
21#include <map>
22#include <stdexcept>
23#include <string>
24#include <vector>
25
31
32namespace peclet::core::halo {
33
35template <typename T>
37 T* data;
38 std::size_t bytesPerElem() const { return sizeof(T); }
39 void pack(Index localIdx, char* dst) const { std::memcpy(dst, &data[localIdx], sizeof(T)); }
40 void unpack(Index localIdx, const char* src) { std::memcpy(&data[localIdx], src, sizeof(T)); }
41 // Accumulate (for reverseAdd — folding ghost-layer deposits back onto the owner).
42 void addFrom(Index localIdx, const char* src) {
43 T v;
44 std::memcpy(&v, src, sizeof(T));
45 data[localIdx] += v;
46 }
47};
48
52enum class Neighborhood { Full, Faces };
53
54template <int Dim>
56 public:
57 GridHaloTopology() = default;
58
64 void buildTopology(const decomp::BlockDecomposer<Dim>& dec, int rank, int ghostWidth,
65 const std::array<bool, Dim>& periodic, MPI_Comm comm = MPI_COMM_WORLD,
66 Neighborhood nb = Neighborhood::Full, int depth = -1) {
67 comm_ = comm;
68 rank_ = rank;
69 indexer_.init(dec.origins()[rank], dec.sizes()[rank], ghostWidth);
70 clear();
71
72 // For each ghost cell, find the owner of its (wrapped) global cell.
73 std::map<int, std::vector<Index>> recvIdxByRank; // local ghost cell indices to fill
74 std::map<int, std::vector<Index>> recvGlobByRank; // the global cells we need from that owner
75 const IVec<Dim>& gsize = dec.globalSize();
76
77 indexer_.forEachAll([&](const IVec<Dim>& lmd) {
78 if (indexer_.isInner(lmd))
79 return;
80 if (nb == Neighborhood::Faces) {
81 int outside = 0;
82 for (int i = 0; i < Dim; ++i)
83 outside +=
84 (lmd[i] < ghostWidth || lmd[i] >= ghostWidth + indexer_.sizeInner()[i]) ? 1 : 0;
85 if (outside != 1)
86 return; // edge or corner ghost: not part of a face neighbourhood
87 }
88 if (depth >= 0 && depth < ghostWidth)
89 for (int i = 0; i < Dim; ++i) {
90 const Index hi = ghostWidth + indexer_.sizeInner()[i];
91 const Index d =
92 lmd[i] < ghostWidth ? ghostWidth - lmd[i] : (lmd[i] >= hi ? lmd[i] - hi + 1 : 0);
93 if (d > depth)
94 return; // beyond the fill depth on this axis
95 }
96 IVec<Dim> g{}, gw{};
97 bool skip = false;
98 for (int i = 0; i < Dim; ++i) {
99 g[i] = lmd[i] + indexer_.originInclGhost()[i];
100 Index c = g[i];
101 if (c < 0 || c >= gsize[i]) {
102 if (periodic[i]) {
103 c = wrap(c, gsize[i]);
104 } else {
105 skip = true;
106 break;
107 }
108 }
109 gw[i] = c;
110 }
111 if (skip)
112 return; // non-periodic physical boundary: BC fills these, no comm
113 int owner = dec.ownerOf(gw);
114 Index ghostLocal = indexer_.localMdToLocal(lmd);
115 if (owner == rank_) {
116 // Periodic wrap onto our own block (e.g. single block, periodic): pure local copy.
117 selfDst_.push_back(ghostLocal);
118 selfSrc_.push_back(indexer_.globalToLocal(gw));
119 } else {
120 recvIdxByRank[owner].push_back(ghostLocal);
121 recvGlobByRank[owner].push_back(dec.linearGlobal(gw));
122 }
123 });
124
125 for (auto& [r, idx] : recvIdxByRank) {
126 recvRanks_.push_back(r);
127 recvIdx_.push_back(std::move(idx));
128 recvGlob_.push_back(std::move(recvGlobByRank[r]));
129 }
130
131 // One NBX round: tell each owner which global cells we need; learn what we must send.
132 NbxEngine nbx(comm_);
133 std::size_t k = 0;
134 auto packNext = [&](std::vector<char>& out) -> int {
135 if (k >= recvRanks_.size())
136 return -1;
137 int dest = recvRanks_[k];
138 const auto& g = recvGlob_[k];
139 ++k;
140 out.resize(g.size() * sizeof(Index));
141 std::memcpy(out.data(), g.data(), out.size());
142 return dest;
143 };
144 auto onRecv = [&](int src, std::vector<char>& msg) {
145 std::size_t n = msg.size() / sizeof(Index);
146 const Index* g = reinterpret_cast<const Index*>(msg.data());
147 std::vector<Index> sidx(n);
148 for (std::size_t i = 0; i < n; ++i) {
149 sidx[i] = indexer_.globalToLocal(dec.multiGlobal(g[i]));
150 }
151 sendRanks_.push_back(src);
152 sendIdx_.push_back(std::move(sidx));
153 };
154 nbx.exchange(packNext, onRecv, /*tag=*/7301);
155
156 // The pattern is symmetric by construction (every requested cell has exactly one owner), so
157 // the global number of cells promised equals the number requested. One allreduce; a mismatch
158 // means the consensus round lost a message, which would otherwise surface as a hang in the
159 // first exchange with nothing to say which rank never learned it had to send.
160 {
161 long cnt[2] = {0, 0};
162 for (const auto& g : recvGlob_)
163 cnt[0] += static_cast<long>(g.size());
164 for (const auto& sidx : sendIdx_)
165 cnt[1] += static_cast<long>(sidx.size());
166 long tot[2] = {0, 0};
167 MPI_Allreduce(cnt, tot, 2, MPI_LONG, MPI_SUM, comm_);
168 if (tot[0] != tot[1])
169 throw std::runtime_error("peclet.core GridHaloTopology: asymmetric halo topology (" +
170 std::to_string(tot[0]) + " cells requested, " +
171 std::to_string(tot[1]) +
172 " promised) -- the NBX round lost messages");
173 }
174
175 buildRecvLookup();
176 persistentReady_ = false;
177 }
178
179 // --- Field-agnostic exchange (NBX engine, with overlap support)
180 // ---------------------------------
181
183 template <typename Field>
184 void start(Field& field, int tag = 0) {
185 applySelfCopy(field);
186 const std::size_t es = field.bytesPerElem();
187
188 // Post receives first.
189 recvReqs_.assign(recvRanks_.size(), MPI_REQUEST_NULL);
190 recvBufs_.resize(recvRanks_.size());
191 for (std::size_t k = 0; k < recvRanks_.size(); ++k) {
192 recvBufs_[k].resize(recvIdx_[k].size() * es);
193 MPI_Irecv(recvBufs_[k].data(), static_cast<int>(recvBufs_[k].size()), MPI_BYTE, recvRanks_[k],
194 tag, comm_, &recvReqs_[k]);
195 }
196 // Pack and post sends.
197 sendReqs_.assign(sendRanks_.size(), MPI_REQUEST_NULL);
198 sendBufs_.resize(sendRanks_.size());
199 for (std::size_t k = 0; k < sendRanks_.size(); ++k) {
200 auto& buf = sendBufs_[k];
201 buf.resize(sendIdx_[k].size() * es);
202 for (std::size_t i = 0; i < sendIdx_[k].size(); ++i) {
203 field.pack(sendIdx_[k][i], buf.data() + i * es);
204 }
205 MPI_Isend(buf.data(), static_cast<int>(buf.size()), MPI_BYTE, sendRanks_[k], tag, comm_,
206 &sendReqs_[k]);
207 }
208 pendingTag_ = tag;
209 }
210
212 template <typename Field>
213 void wait(Field& field) {
214 const std::size_t es = field.bytesPerElem();
215 // Unpack receives as they arrive.
216 for (std::size_t done = 0; done < recvReqs_.size(); ++done) {
217 int k = 0;
218 MPI_Waitany(static_cast<int>(recvReqs_.size()), recvReqs_.data(), &k, MPI_STATUS_IGNORE);
219 if (k == MPI_UNDEFINED)
220 break;
221 for (std::size_t i = 0; i < recvIdx_[k].size(); ++i) {
222 field.unpack(recvIdx_[k][i], recvBufs_[k].data() + i * es);
223 }
224 }
225 if (!sendReqs_.empty()) {
226 MPI_Waitall(static_cast<int>(sendReqs_.size()), sendReqs_.data(), MPI_STATUSES_IGNORE);
227 }
228 }
229
231 template <typename Field>
232 void exchangeNbx(Field& field, int tag = 0) {
233 start(field, tag);
234 wait(field);
235 }
236
237 // --- Field-agnostic exchange (persistent neighborhood collective)
238 // -------------------------------
239
242 template <typename Field>
243 void exchangePersistent(Field& field) {
244 applySelfCopy(field);
245 const std::size_t es = field.bytesPerElem();
246 ensureGraphComm(es);
247
248 // Pack the contiguous send buffer in destination order.
249 for (std::size_t k = 0; k < sendRanks_.size(); ++k) {
250 char* dst = graphSendBuf_.data() + graphSendDispl_[k];
251 for (std::size_t i = 0; i < sendIdx_[k].size(); ++i) {
252 field.pack(sendIdx_[k][i], dst + i * es);
253 }
254 }
255 MPI_Neighbor_alltoallv(graphSendBuf_.data(), graphSendCnt_.data(), graphSendDispl_.data(),
256 MPI_BYTE, graphRecvBuf_.data(), graphRecvCnt_.data(),
257 graphRecvDispl_.data(), MPI_BYTE, graphComm_);
258 // Scatter the contiguous recv buffer into ghost cells (source order == recvRanks_ order).
259 for (std::size_t k = 0; k < recvRanks_.size(); ++k) {
260 const char* src = graphRecvBuf_.data() + graphRecvDispl_[k];
261 for (std::size_t i = 0; i < recvIdx_[k].size(); ++i) {
262 field.unpack(recvIdx_[k][i], src + i * es);
263 }
264 }
265 }
266
267 // Reverse (transpose) exchange with ACCUMULATE — the adjoint of the forward exchange: each rank
268 // sends its GHOST-cell values back to the owners, which ADD them into the matching owned cells
269 // (and the periodic self-copy folds ghost -> inner with +=). This is the fold a scatter/deposit
270 // needs across rank boundaries (CFD-DEM void-fraction / momentum feedback that lands in ghost
271 // cells). The Field must provide addFrom(localIdx, src) in addition to pack. Point-to-point
272 // (Isend/Irecv) so it needs no second graph comm.
273 template <typename Field>
274 void reverseAdd(Field& field, int tag = 0) {
275 const std::size_t es = field.bytesPerElem();
276 // self: owner (selfSrc) += ghost (selfDst)
277 std::vector<char> tmp(es);
278 for (std::size_t i = 0; i < selfSrc_.size(); ++i) {
279 field.pack(selfDst_[i], tmp.data());
280 field.addFrom(selfSrc_[i], tmp.data());
281 }
282 // I receive owner-updates for my SENT cells (sendIdx_) from the ranks I forward-send to.
283 std::vector<std::vector<char>> rbuf(sendRanks_.size());
284 std::vector<MPI_Request> rreq(sendRanks_.size(), MPI_REQUEST_NULL);
285 for (std::size_t k = 0; k < sendRanks_.size(); ++k) {
286 rbuf[k].resize(sendIdx_[k].size() * es);
287 MPI_Irecv(rbuf[k].data(), static_cast<int>(rbuf[k].size()), MPI_BYTE, sendRanks_[k], tag,
288 comm_, &rreq[k]);
289 }
290 // I send my GHOST cells (recvIdx_) back to the owners they came from (recvRanks_).
291 std::vector<std::vector<char>> sbuf(recvRanks_.size());
292 std::vector<MPI_Request> sreq(recvRanks_.size(), MPI_REQUEST_NULL);
293 for (std::size_t k = 0; k < recvRanks_.size(); ++k) {
294 sbuf[k].resize(recvIdx_[k].size() * es);
295 for (std::size_t i = 0; i < recvIdx_[k].size(); ++i)
296 field.pack(recvIdx_[k][i], sbuf[k].data() + i * es);
297 MPI_Isend(sbuf[k].data(), static_cast<int>(sbuf[k].size()), MPI_BYTE, recvRanks_[k], tag,
298 comm_, &sreq[k]);
299 }
300 // As owner-updates arrive, accumulate into my owned (sendIdx_) cells.
301 for (std::size_t done = 0; done < sendRanks_.size(); ++done) {
302 int k = 0;
303 MPI_Waitany(static_cast<int>(rreq.size()), rreq.data(), &k, MPI_STATUS_IGNORE);
304 if (k == MPI_UNDEFINED)
305 break;
306 for (std::size_t i = 0; i < sendIdx_[k].size(); ++i)
307 field.addFrom(sendIdx_[k][i], rbuf[k].data() + i * es);
308 }
309 if (!sreq.empty())
310 MPI_Waitall(static_cast<int>(sreq.size()), sreq.data(), MPI_STATUSES_IGNORE);
311 }
312
313 // --- Flattened topology (contiguous, device-friendly; consumed by the CUDA exchange) ---
316 std::vector<int> sendRanks, recvRanks; // neighbour ranks
317 std::vector<int> sendCounts, recvCounts; // elements per neighbour (same order)
318 std::vector<Index> sendIdx, recvIdx; // flattened local indices, grouped by neighbour
319 std::vector<Index> selfSrc, selfDst; // local periodic self-copy (inner -> ghost)
320
325 FlatTopology stacked(int k, Index stride) const {
326 FlatTopology t;
327 t.comm = comm;
330 const auto rep = [&](const std::vector<Index>& src, const std::vector<int>& counts,
331 std::vector<Index>& dst, std::vector<int>* outCounts) {
332 std::size_t off = 0;
333 for (std::size_t g = 0; g < counts.size(); ++g) {
334 for (int j = 0; j < k; ++j)
335 for (int i = 0; i < counts[g]; ++i)
336 dst.push_back(src[off + static_cast<std::size_t>(i)] +
337 static_cast<Index>(j) * stride);
338 off += static_cast<std::size_t>(counts[g]);
339 if (outCounts)
340 outCounts->push_back(counts[g] * k);
341 }
342 };
345 const std::vector<int> selfCount(1, static_cast<int>(selfSrc.size()));
346 rep(selfSrc, selfCount, t.selfSrc, nullptr);
347 rep(selfDst, selfCount, t.selfDst, nullptr);
348 return t;
349 }
350 };
351
353 FlatTopology t;
354 t.comm = comm_;
355 t.sendRanks = std::vector<int>(sendRanks_.begin(), sendRanks_.end());
356 t.recvRanks = std::vector<int>(recvRanks_.begin(), recvRanks_.end());
357 for (const auto& v : sendIdx_) {
358 t.sendCounts.push_back(static_cast<int>(v.size()));
359 t.sendIdx.insert(t.sendIdx.end(), v.begin(), v.end());
360 }
361 for (const auto& v : recvIdx_) {
362 t.recvCounts.push_back(static_cast<int>(v.size()));
363 t.recvIdx.insert(t.recvIdx.end(), v.begin(), v.end());
364 }
365 t.selfSrc = selfSrc_;
366 t.selfDst = selfDst_;
367 return t;
368 }
369
370 // --- Introspection (used by tests/benchmarks) ---
371 const decomp::BlockIndexer<Dim>& indexer() const { return indexer_; }
372 std::size_t numNeighbors() const { return recvRanks_.size(); }
373 std::size_t numGhostRecv() const {
374 std::size_t n = 0;
375 for (auto& v : recvIdx_)
376 n += v.size();
377 return n;
378 }
379
380 ~GridHaloTopology() { freeGraphComm(); }
381
384
385 private:
386 // Free the cached graph communicator, but never after MPI_Finalize (e.g. if this object outlives
387 // finalize on the stack of main()). Calling MPI_Comm_free post-finalize aborts the job.
388 void freeGraphComm() {
389 if (graphComm_ == MPI_COMM_NULL)
390 return;
391 int finalized = 0;
392 MPI_Finalized(&finalized);
393 if (!finalized)
394 MPI_Comm_free(&graphComm_);
395 graphComm_ = MPI_COMM_NULL;
396 }
397
398 void clear() {
399 sendRanks_.clear();
400 sendIdx_.clear();
401 recvRanks_.clear();
402 recvIdx_.clear();
403 recvGlob_.clear();
404 selfSrc_.clear();
405 selfDst_.clear();
406 freeGraphComm();
407 persistentReady_ = false;
408 }
409
410 void buildRecvLookup() {
411 recvRankPos_.clear();
412 for (std::size_t k = 0; k < recvRanks_.size(); ++k)
413 recvRankPos_[recvRanks_[k]] = k;
414 }
415
416 template <typename Field>
417 void applySelfCopy(Field& field) {
418 // Periodic copy within our own block: read inner cell, write ghost cell. We go through the
419 // field's pack/unpack so it works for any payload type.
420 if (selfSrc_.empty())
421 return;
422 std::vector<char> tmp(field.bytesPerElem());
423 for (std::size_t i = 0; i < selfSrc_.size(); ++i) {
424 field.pack(selfSrc_[i], tmp.data());
425 field.unpack(selfDst_[i], tmp.data());
426 }
427 }
428
429 void ensureGraphComm(std::size_t es) {
430 if (persistentReady_ && graphElemSize_ == es)
431 return;
432 if (graphComm_ != MPI_COMM_NULL)
433 MPI_Comm_free(&graphComm_);
434
435 // Distributed graph: sources = ranks we receive from, destinations = ranks we send to.
436 std::vector<int> sources(recvRanks_.begin(), recvRanks_.end());
437 std::vector<int> dests(sendRanks_.begin(), sendRanks_.end());
438 MPI_Dist_graph_create_adjacent(comm_, static_cast<int>(sources.size()), sources.data(),
439 MPI_UNWEIGHTED, static_cast<int>(dests.size()), dests.data(),
440 MPI_UNWEIGHTED, MPI_INFO_NULL, /*reorder=*/0, &graphComm_);
441
442 // Counts/displacements (in bytes) in the graph's neighbour ordering, which for
443 // create_adjacent matches the order we passed sources/dests.
444 graphSendCnt_.resize(dests.size());
445 graphSendDispl_.resize(dests.size());
446 int off = 0;
447 for (std::size_t k = 0; k < dests.size(); ++k) {
448 graphSendCnt_[k] = static_cast<int>(sendIdx_[k].size() * es);
449 graphSendDispl_[k] = off;
450 off += graphSendCnt_[k];
451 }
452 graphSendBuf_.resize(off);
453
454 graphRecvCnt_.resize(sources.size());
455 graphRecvDispl_.resize(sources.size());
456 off = 0;
457 for (std::size_t k = 0; k < sources.size(); ++k) {
458 graphRecvCnt_[k] = static_cast<int>(recvIdx_[k].size() * es);
459 graphRecvDispl_[k] = off;
460 off += graphRecvCnt_[k];
461 }
462 graphRecvBuf_.resize(off);
463
464 graphElemSize_ = es;
465 persistentReady_ = true;
466 }
467
468 MPI_Comm comm_ = MPI_COMM_WORLD;
469 int rank_ = 0;
470 decomp::BlockIndexer<Dim> indexer_;
471
472 // Matched topology: element i of send list k corresponds to element i of the peer's recv list.
473 std::vector<int> sendRanks_;
474 std::vector<std::vector<Index>> sendIdx_; // local inner-cell indices to send
475 std::vector<int> recvRanks_;
476 std::vector<std::vector<Index>> recvIdx_; // local ghost-cell indices to fill
477 std::vector<std::vector<Index>> recvGlob_; // global cells requested (build-time only)
478 std::map<int, std::size_t> recvRankPos_;
479 std::vector<Index> selfSrc_, selfDst_; // local periodic self-copy (inner -> ghost)
480
481 // NBX exchange scratch.
482 std::vector<MPI_Request> sendReqs_, recvReqs_;
483 std::vector<std::vector<char>> sendBufs_, recvBufs_;
484 int pendingTag_ = 0;
485
486 // Persistent neighborhood-collective state.
487 MPI_Comm graphComm_ = MPI_COMM_NULL;
488 bool persistentReady_ = false;
489 std::size_t graphElemSize_ = 0;
490 std::vector<int> graphSendCnt_, graphSendDispl_, graphRecvCnt_, graphRecvDispl_;
491 std::vector<char> graphSendBuf_, graphRecvBuf_;
492};
493
494} // namespace peclet::core::halo
495
496#endif // PECLET_CORE_HALO_GRID_HALO_TOPOLOGY_HPP
Orthogonal recursive bisection of a Dim-dimensional global cell grid into numBlocks axis-aligned bloc...
const std::vector< IVec< Dim > > & sizes() const
Extent in cells of every block, indexed by block.
const std::vector< IVec< Dim > > & origins() const
Inclusive lower corner of every block, in global cell coordinates, indexed by block.
const IVec< Dim > & globalSize() const
Global grid size in cells per axis.
Index linearGlobal(const IVec< Dim > &g) const
Global multi-index -> global linear index (x-fastest: I = x + y*nx + z*nx*ny).
int ownerOf(const IVec< Dim > &g) const
Owning block index of a global cell coordinate. Caller must wrap into [0, globalSize) first.
IVec< Dim > multiGlobal(Index lin) const
Global linear index -> global multi-index (inverse of linearGlobal).
void start(Field &field, int tag=0)
Post all sends/recvs; returns immediately so the caller can compute the block interior.
void reverseAdd(Field &field, int tag=0)
void buildTopology(const decomp::BlockDecomposer< Dim > &dec, int rank, int ghostWidth, const std::array< bool, Dim > &periodic, MPI_Comm comm=MPI_COMM_WORLD, Neighborhood nb=Neighborhood::Full, int depth=-1)
Build the halo topology for rank's block of dec, with the given ghost width and per-axis periodicity.
const decomp::BlockIndexer< Dim > & indexer() const
void exchangeNbx(Field &field, int tag=0)
Convenience: full blocking exchange via the NBX-style engine (start + wait).
void wait(Field &field)
Complete a started exchange: wait for receives and scatter them into the ghost cells.
GridHaloTopology(const GridHaloTopology &)=delete
GridHaloTopology & operator=(const GridHaloTopology &)=delete
void exchangePersistent(Field &field)
Full exchange via MPI_Neighbor_alltoallv on a cached distributed-graph communicator.
void exchange(PackNext &&packNext, OnRecv &&onRecv, int baseTag=0)
Definition nbx.hpp:96
#define MPI_COMM_NULL
Definition mpi_stub.hpp:28
int MPI_Allreduce(const void *sbuf, void *rbuf, int count, MPI_Datatype dt, MPI_Op, MPI_Comm)
Definition mpi_stub.hpp:114
int MPI_Comm
Definition mpi_stub.hpp:17
#define MPI_COMM_WORLD
Definition mpi_stub.hpp:27
int MPI_Waitall(int, MPI_Request *, MPI_Status *)
Definition mpi_stub.hpp:160
#define MPI_REQUEST_NULL
Definition mpi_stub.hpp:29
#define MPI_UNWEIGHTED
Definition mpi_stub.hpp:35
int MPI_Comm_free(MPI_Comm *)
Definition mpi_stub.hpp:107
#define MPI_STATUS_IGNORE
Definition mpi_stub.hpp:31
#define MPI_BYTE
Definition mpi_stub.hpp:38
#define MPI_STATUSES_IGNORE
Definition mpi_stub.hpp:32
int MPI_Waitany(int, MPI_Request *, int *idx, MPI_Status *)
Definition mpi_stub.hpp:163
int MPI_Isend(const void *, int, MPI_Datatype, int, int, MPI_Comm, MPI_Request *)
Definition mpi_stub.hpp:132
int MPI_Finalized(int *f)
Definition mpi_stub.hpp:58
#define MPI_INFO_NULL
Definition mpi_stub.hpp:30
#define MPI_SUM
Definition mpi_stub.hpp:43
#define MPI_LONG
Definition mpi_stub.hpp:40
int MPI_Irecv(void *, int, MPI_Datatype, int, int, MPI_Comm, MPI_Request *)
Definition mpi_stub.hpp:135
int MPI_Neighbor_alltoallv(const void *, const int *, const int *, MPI_Datatype, void *, const int *, const int *, MPI_Datatype, MPI_Comm)
Definition mpi_stub.hpp:175
int MPI_Dist_graph_create_adjacent(MPI_Comm c, int, const int *, const int *, int, const int *, const int *, MPI_Info, int, MPI_Comm *out)
Definition mpi_stub.hpp:170
#define MPI_UNDEFINED
Definition mpi_stub.hpp:34
Neighborhood
Which ghost cells a topology fills.
Index wrap(Index x, Index n)
Periodic wrap of a coordinate into [0, n): wrap(x, n) = (x % n + n) % n.
Definition types.hpp:37
std::int64_t Index
Signed index type for grids and particles (supersedes block_decomposer's long int IndxT).
Definition types.hpp:15
std::array< Index, Dim > IVec
Multi-dimensional integer index / coordinate (x-fastest order by convention).
Definition types.hpp:22
A contiguous local array of T (one per cell of the extended block) viewed as a packable field.
void addFrom(Index localIdx, const char *src)
void pack(Index localIdx, char *dst) const
void unpack(Index localIdx, const char *src)
FlatTopology stacked(int k, Index stride) const
The same pattern for k fields at once: copy j of every list is offset by j * stride (the fields lie a...