DNDSR 0.1.0.dev1+gcd065ad
Distributed Numeric Data Structure for CFV
Loading...
Searching...
No Matches
DNDS::OffsetAscendIndexMapping Class Reference

Mapping between a rank's main data and its ghost copies. More...

#include <IndexMapping.hpp>

Collaboration diagram for DNDS::OffsetAscendIndexMapping:
[legend]

Public Member Functions

template<class TpullSet >
 OffsetAscendIndexMapping (index nmainOffset, index nmainSize, TpullSet &&pullingIndexGlobal, const GlobalOffsetsMapping &LGlobalMapping, const MPIInfo &mpi)
 Construct the mapping from a pull specification.
 
template<class TpushSet , class TpushStart >
 OffsetAscendIndexMapping (index nmainOffset, index nmainSize, TpushSet &&pushingIndexesLocal, TpushStart &&pushingStarts, const GlobalOffsetsMapping &LGlobalMapping, const MPIInfo &mpi)
 Construct the mapping from a push specification.
 
void sort ()
 Sort ghostIndex into ascending order. Required invariant maintained after pull construction.
 
indexghostAt (MPI_int rank, index ighost)
 Direct mutable access to the ighost-th ghost global index for peer rank.
 
bool searchInMain (index globalQuery, index &val) const
 Check whether a global index lies within the main block.
 
bool searchInGhost (index globalQuery, MPI_int rank, index &val) const
 Search a single peer rank's ghost slab for a global index.
 
bool searchInAllGhost (index globalQuery, MPI_int &rank, index &val) const
 Search the concatenated ghost array for a global index (O(log nGhost)).
 
bool search (index globalQuery, MPI_int &rank, index &val) const
 Search main + ghost in one call. rank == -1 signals "hit in main".
 
std::tuple< bool, MPI_int, indexsearch (index globalQuery) const
 Tuple-return overload of the main search. (success, rank, local).
 
bool search_indexAppend (index globalQuery, MPI_int &rank, index &val) const
 Like search, but the returned val is in the concatenated father+son address space.
 
std::tuple< bool, MPI_int, indexsearch_indexAppend (index globalQuery) const
 Tuple-return overload of search_indexAppend.
 
bool search_indexRank (index globalQuery, MPI_int &rank, index &val) const
 Like search, but val is expressed relative to the owner rank's ghost slab (ghostStart[rank]-relative).
 
std::tuple< bool, MPI_int, indexsearch_indexRank (index globalQuery) const
 Tuple-return overload of search_indexRank.
 
index operator() (MPI_int rank, index val) const
 Reverse (local -> global) mapping.
 

Public Attributes

tMPI_intVec ghostSizes
 Number of ghost rows pulled from each peer rank. (a.k.a. pullIndexSizes)
 
t_IndexVec ghostIndex
 Global indices of all ghost rows on this rank, ascending. (a.k.a. pullingIndexGlobal)
 
t_MapIndexVec ghostStart
 Per-peer prefix-sum offsets into ghostIndex (size == nRanks + 1). (a.k.a. pullIndexStarts)
 
tMPI_intVec pushIndexSizes
 Per-peer number of rows this rank will send out on a push.
 
t_MapIndexVec pushIndexStarts
 Per-peer prefix-sum offsets into pushingIndexGlobal.
 
t_IndexVec pushingIndexGlobal
 Global indices this rank sends to others, grouped by receiver.
 
t_IndexVec pullingRequestLocal
 Optional cached local-index form of ghostIndex (unused in current code).
 

Detailed Description

Mapping between a rank's main data and its ghost copies.

main data (owned rows) is a contiguous range [mainOffset, mainOffset + mainSize) in the global index space. ghost data (rows needed from other ranks) is stored in globally ascending order so that binary search may be used for the reverse mapping.

Two construction modes:

  • Pull: the caller provides the set of global indices this rank needs.
  • Push: the caller provides which local rows to send to which ranks. Both modes exchange the complementary information via MPI_Alltoall(v) so the resulting mapping is valid on both sides.

Internal structure (all vectors are per-peer-rank layouts, sorted by rank):

  • ghostSizes / ghostStart / ghostIndex: what this rank pulls from each other rank.
  • pushIndexSizes / pushIndexStarts / pushingIndexGlobal: what this rank sends to each other rank.
Warning
Ghost indices carry only 32-bit payload in MPI calls; the total per-rank ghost count must fit in int32_t.

Definition at line 165 of file IndexMapping.hpp.

Constructor & Destructor Documentation

◆ OffsetAscendIndexMapping() [1/2]

template<class TpullSet >
DNDS::OffsetAscendIndexMapping::OffsetAscendIndexMapping ( index  nmainOffset,
index  nmainSize,
TpullSet &&  pullingIndexGlobal,
const GlobalOffsetsMapping LGlobalMapping,
const MPIInfo mpi 
)
inline

Construct the mapping from a pull specification.

Template Parameters
TpullSetRange of index (vector-like, supports sort/unique/erase).
Parameters
nmainOffsetGlobal offset of this rank's main data block.
nmainSizeNumber of main rows owned by this rank.
pullingIndexGlobalGlobal indices this rank wants to see as ghosts. Sorted and deduplicated in-place.
LGlobalMappingGlobally-known offsets, used to attribute each global index to its owner rank.
mpiMPI context; the constructor is collective.
Warning
pullingIndexGlobal is mutated (sorted / uniquified / shrunk). The resulting ghostIndex ends up in ascending global-index order regardless of the caller's original ordering.

*make sorted and unique!

Definition at line 214 of file IndexMapping.hpp.

Here is the call graph for this function:

◆ OffsetAscendIndexMapping() [2/2]

template<class TpushSet , class TpushStart >
DNDS::OffsetAscendIndexMapping::OffsetAscendIndexMapping ( index  nmainOffset,
index  nmainSize,
TpushSet &&  pushingIndexesLocal,
TpushStart &&  pushingStarts,
const GlobalOffsetsMapping LGlobalMapping,
const MPIInfo mpi 
)
inline

Construct the mapping from a push specification.

The caller supplies, for every peer rank, a list of local row indices that this rank should send. The constructor flips this into the pull view via MPI_Alltoall(v).

Template Parameters
TpushSetRange-like of local indices.
TpushStartSize-nRanks+1 prefix-sum offsets.
Parameters
nmainOffsetGlobal offset of this rank's main block.
nmainSizeNumber of main rows owned by this rank.
pushingIndexesLocalLocal indices to push, grouped by receiver (flat array; [pushingStarts[r], pushingStarts[r+1]) are the indices going to rank r).
pushingStartsPrefix sums of per-receiver counts, size nRanks+1.
LGlobalMappingRank-offset table (to convert local -> global).
mpiMPI context; collective.

Definition at line 297 of file IndexMapping.hpp.

Here is the call graph for this function:

Member Function Documentation

◆ ghostAt()

index & DNDS::OffsetAscendIndexMapping::ghostAt ( MPI_int  rank,
index  ighost 
)
inline

Direct mutable access to the ighost-th ghost global index for peer rank.

Definition at line 344 of file IndexMapping.hpp.

Here is the caller graph for this function:

◆ operator()()

index DNDS::OffsetAscendIndexMapping::operator() ( MPI_int  rank,
index  val 
) const
inline

Reverse (local -> global) mapping.

  • rank == -1: val indexes the concatenated father+son address space. val < mainSize returns the main global index; val >= mainSize returns the corresponding ghost global index.
  • rank >= 0: val indexes into that peer's ghost slab (like search_indexRank's output).

if rank == -1, return the global index of local main data, or else return the ghosted global index of local ghost data.

Definition at line 509 of file IndexMapping.hpp.

◆ search() [1/2]

std::tuple< bool, MPI_int, index > DNDS::OffsetAscendIndexMapping::search ( index  globalQuery) const
inline

Tuple-return overload of the main search. (success, rank, local).

Definition at line 432 of file IndexMapping.hpp.

Here is the call graph for this function:

◆ search() [2/2]

bool DNDS::OffsetAscendIndexMapping::search ( index  globalQuery,
MPI_int rank,
index val 
) const
inline

Search main + ghost in one call. rank == -1 signals "hit in main".

Returned val is in the ghost address space (relative to ghostStart[0]) when rank != -1, else it is the main-local index. See also search_indexAppend for the combined (father+son) index space.

returns rank and place in ghost array, rank==-1 means main data

Definition at line 418 of file IndexMapping.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ search_indexAppend() [1/2]

std::tuple< bool, MPI_int, index > DNDS::OffsetAscendIndexMapping::search_indexAppend ( index  globalQuery) const
inline

Tuple-return overload of search_indexAppend.

Definition at line 462 of file IndexMapping.hpp.

Here is the call graph for this function:

◆ search_indexAppend() [2/2]

bool DNDS::OffsetAscendIndexMapping::search_indexAppend ( index  globalQuery,
MPI_int rank,
index val 
) const
inline

Like search, but the returned val is in the concatenated father+son address space.

val < mainSize means main row; val >= mainSize means ghost row at val - mainSize. Matches ArrayPair::operator[] layout.

returns rank and place in ghost array, rank==-1 means main data; returned val is used for pair indexing

Definition at line 446 of file IndexMapping.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ search_indexRank() [1/2]

std::tuple< bool, MPI_int, index > DNDS::OffsetAscendIndexMapping::search_indexRank ( index  globalQuery) const
inline

Tuple-return overload of search_indexRank.

Definition at line 492 of file IndexMapping.hpp.

Here is the call graph for this function:

◆ search_indexRank() [2/2]

bool DNDS::OffsetAscendIndexMapping::search_indexRank ( index  globalQuery,
MPI_int rank,
index val 
) const
inline

Like search, but val is expressed relative to the owner rank's ghost slab (ghostStart[rank]-relative).

Warning
Do not confuse with search, whose val is relative to the concatenated ghost array.

returns rank and place in ghost of rank, rank==-1 means main data

Warning
search returns index that applies to local ghost array, this only goes for the ith of rank

Definition at line 476 of file IndexMapping.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ searchInAllGhost()

bool DNDS::OffsetAscendIndexMapping::searchInAllGhost ( index  globalQuery,
MPI_int rank,
index val 
) const
inline

Search the concatenated ghost array for a global index (O(log nGhost)).

Parameters
[out]rankPeer rank that owns the found index.
[out]valOffset relative to ghostStart[0] (== 0).

Definition at line 395 of file IndexMapping.hpp.

Here is the caller graph for this function:

◆ searchInGhost()

bool DNDS::OffsetAscendIndexMapping::searchInGhost ( index  globalQuery,
MPI_int  rank,
index val 
) const
inline

Search a single peer rank's ghost slab for a global index.

Parameters
[out]valOffset relative to ghostStart[rank] on success.

Definition at line 375 of file IndexMapping.hpp.

Here is the caller graph for this function:

◆ searchInMain()

bool DNDS::OffsetAscendIndexMapping::searchInMain ( index  globalQuery,
index val 
) const
inline

Check whether a global index lies within the main block.

Parameters
globalQueryGlobal index to look up.
[out]valOn success, local offset within the main block.
Returns
true if globalQuery is owned by this rank.

Definition at line 361 of file IndexMapping.hpp.

Here is the caller graph for this function:

◆ sort()

void DNDS::OffsetAscendIndexMapping::sort ( )
inline

Sort ghostIndex into ascending order. Required invariant maintained after pull construction.

Definition at line 338 of file IndexMapping.hpp.

Here is the caller graph for this function:

Member Data Documentation

◆ ghostIndex

t_IndexVec DNDS::OffsetAscendIndexMapping::ghostIndex

Global indices of all ghost rows on this rank, ascending. (a.k.a. pullingIndexGlobal)

Definition at line 179 of file IndexMapping.hpp.

◆ ghostSizes

tMPI_intVec DNDS::OffsetAscendIndexMapping::ghostSizes

Number of ghost rows pulled from each peer rank. (a.k.a. pullIndexSizes)

Definition at line 175 of file IndexMapping.hpp.

◆ ghostStart

t_MapIndexVec DNDS::OffsetAscendIndexMapping::ghostStart

Per-peer prefix-sum offsets into ghostIndex (size == nRanks + 1). (a.k.a. pullIndexStarts)

Definition at line 183 of file IndexMapping.hpp.

◆ pullingRequestLocal

t_IndexVec DNDS::OffsetAscendIndexMapping::pullingRequestLocal

Optional cached local-index form of ghostIndex (unused in current code).

Encoding: >=0 means array[i], <0 means ghost_array[-i-1]. Retained for potential future reconstruction paths.

Definition at line 195 of file IndexMapping.hpp.

◆ pushIndexSizes

tMPI_intVec DNDS::OffsetAscendIndexMapping::pushIndexSizes

Per-peer number of rows this rank will send out on a push.

Definition at line 186 of file IndexMapping.hpp.

◆ pushIndexStarts

t_MapIndexVec DNDS::OffsetAscendIndexMapping::pushIndexStarts

Per-peer prefix-sum offsets into pushingIndexGlobal.

Definition at line 188 of file IndexMapping.hpp.

◆ pushingIndexGlobal

t_IndexVec DNDS::OffsetAscendIndexMapping::pushingIndexGlobal

Global indices this rank sends to others, grouped by receiver.

Definition at line 190 of file IndexMapping.hpp.


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