61 const std::vector<MPI_int> &partition,
74 const std::vector<index> &old2new,
91 template <
class TPair>
109 bool found =
pair.trans.pLGhostMapping->search_indexAppend(
110 oldGlobal, rank, val);
112 fmt::format(
"LookupResult::resolve: old global {} not found", oldGlobal));
126 const std::vector<index> &pullSet,
142 const std::vector<MPI_int> &partition,
152 std::vector<index> pushSizes(mpi.size, 0);
153 for (
auto r : partition)
160 pushSizes.assign(mpi.size, 0);
166 std::vector<index> localCounts(mpi.size, 0);
167 for (
auto r : partition)
171 std::vector<index> totalCounts(mpi.size);
172 MPI_Allreduce(localCounts.data(), totalCounts.data(), mpi.size,
178 for (
int r = 0;
r < mpi.size;
r++)
182 std::vector<index> prevCounts(mpi.size);
183 MPI_Scan(localCounts.data(), prevCounts.data(), mpi.size,
186 for (
int r = 0;
r < mpi.size;
r++)
187 prevCounts[
r] -= localCounts[
r];
192 std::vector<index> fillCounters(mpi.size, 0);
198 fillCounters[target]++;
203 for (
auto r : partition)
210 MPI_Allreduce(&localFlag, &globalFlag, 1, MPI_INT, MPI_LAND, mpi.comm);
217 DNDS_assert(myOffset == (*oldGlobalMapping)(mpi.rank, 0));
231 const std::vector<index> &old2new,
241 std::vector<bool> seen(
nLocal,
false);
245 fmt::format(
"fromLocalPermutation: old2new[{}] = {} out of [0, {})",
248 fmt::format(
"fromLocalPermutation: duplicate mapping to {}",
250 seen[old2new[
i]] =
true;
258 index myOffset = (*oldGlobalMapping)(mpi.rank, 0);
266 for (
int r = mpi.rank + 2;
r <= mpi.size;
r++)
273 for (
int r = 0;
r < mpi.size;
r++)
284 template <
class TPair>
294 "transferRows: localOld2New size mismatch");
295 using TArr =
typename decltype(pair.father)::element_type;
296 auto tmp = std::make_shared<TArr>(*pair.father);
300 fmt::format(
"transferRows: localOld2New[{}] = {} out of [0, {})",
303 if constexpr (TPair::IsCSR())
304 pair.father->Decompress();
308 if constexpr (TPair::IsCSR())
309 pair.father->ResizeRow(iNew, tmp->RowSize(
i));
311 pair.father->operator()(iNew,
j) = (*tmp)(
i,
j);
313 if constexpr (TPair::IsCSR())
314 pair.father->Compress();
319 using TArr =
typename decltype(pair.father)::element_type;
320 auto oldFather = pair.father;
321 pair.father = make_ssp<TArr>(
ObjName{
"PermTransfer.new"}, mpi);
325 trans.createFatherGlobalMapping();
327 trans.createMPITypes();
331 pair.father->createGlobalMapping();
344 const std::vector<index> &pullSet,
348 result.
pair.InitPair(
"PermTransfer_lookup", mpi);
353 result.pair.TransAttach();
354 result.pair.trans.createFatherGlobalMapping();
355 std::vector<index> pullSetMut(pullSet);
356 result.pair.trans.createGhostMapping(pullSetMut);
357 result.pair.trans.createMPITypes();
358 result.pair.trans.pullOnce();
Father-son array pairs with device views and ghost communication.
#define DNDS_assert_info(expr, info)
Debug-only assertion with an extra std::string info message.
#define DNDS_assert(expr)
Debug-only assertion (compiled out when DNDS_NDEBUG is defined). Prints the expression + file/line + ...
MPI wrappers: MPIInfo, collective operations, type mapping, CommStrategy.
the host side operators are provided as implemented
const MPI_Datatype DNDS_MPI_INDEX
MPI datatype matching index (= MPI_INT64_T).
DNDS_CONSTANT const index UnInitIndex
Sentinel "not initialised" index value (= INT64_MIN).
int32_t rowsize
Row-width / per-row element-count type (signed 32-bit).
void AccumulateRowSize(const TtRowsizeVec &rowsizes, TtIndexVec &rowstarts)
Build a prefix-sum table from a row-size vector.
constexpr MPI_int UnInitMPIInt
Sentinel "not initialised" MPI_int value (= -1, invalid rank).
int64_t index
Global row / DOF index type (signed 64-bit; handles multi-billion-cell meshes).
std::shared_ptr< T > ssp
Shortened alias for std::shared_ptr used pervasively in DNDSR.
int MPI_int
MPI counterpart type for MPI_int (= C int). Used for counts and ranks in MPI calls.
Convenience bundle of a father, son, and attached ArrayTransformer.
Lightweight bundle of an MPI communicator and the calling rank's coordinates.
Tag type for naming objects created via make_ssp.
Result of buildLookup: ghost-pullable old-global -> new-global map.
ArrayAdjacencyPair< 1 > pair
index resolve(index oldGlobal) const
LookupResult buildLookup(const std::vector< index > &pullSet, const MPIInfo &mpi) const
std::vector< index > newGlobalIndices
New global index for each father slot (same size as targetRanks).
std::vector< index > pushStart
index size() const
Number of entities (father slots) in this transfer.
std::vector< index > localOld2New
static PermutationTransfer fromPartition(const std::vector< MPI_int > &partition, const ssp< GlobalOffsetsMapping > &oldGlobalMapping, const MPIInfo &mpi)
std::vector< index > pushIndex
std::vector< MPI_int > targetRanks
Per father slot: target rank after reorder.
std::vector< index > newGlobalOffsets
void transferRows(TPair &pair, const MPIInfo &mpi) const
static PermutationTransfer fromLocalPermutation(const std::vector< index > &old2new, const ssp< GlobalOffsetsMapping > &oldGlobalMapping, const MPIInfo &mpi)
bool isLocalOnly
Whether this is a pure rank-local permutation (no cross-rank traffic).