Loading...
Searching...
No Matches
terra::mpi Namespace Reference

Namespaces

namespace  detail
 

Typedefs

using MPIRank = int
 

Functions

std::vector< MPI_Comm > build_level_comms (MPI_Comm root_comm, const std::vector< int > &factors)
 Build a nested ladder of sub-communicators for hierarchical agglomeration.
 
MPIRank agglomerate_rank (MPIRank parent_rank, int factor)
 Translate a parent-comm rank into its agglomerated sub-comm rank.
 
void free_level_comms (std::vector< MPI_Comm > &level_comms)
 Free a level-comm ladder. Call once at MG teardown.
 
MPIRank rank ()
 
MPIRank rank (MPI_Comm comm)
 
int num_processes ()
 
int num_processes (MPI_Comm comm)
 
void barrier ()
 
std::string mpi_error_string (int err)
 
template<typename T >
MPI_Datatype mpi_datatype ()
 
template<>
MPI_Datatype mpi_datatype< char > ()
 
template<>
MPI_Datatype mpi_datatype< signed char > ()
 
template<>
MPI_Datatype mpi_datatype< unsigned char > ()
 
template<>
MPI_Datatype mpi_datatype< int > ()
 
template<>
MPI_Datatype mpi_datatype< unsigned int > ()
 
template<>
MPI_Datatype mpi_datatype< short > ()
 
template<>
MPI_Datatype mpi_datatype< unsigned short > ()
 
template<>
MPI_Datatype mpi_datatype< long > ()
 
template<>
MPI_Datatype mpi_datatype< unsigned long > ()
 
template<>
MPI_Datatype mpi_datatype< long long > ()
 
template<>
MPI_Datatype mpi_datatype< unsigned long long > ()
 
template<>
MPI_Datatype mpi_datatype< float > ()
 
template<>
MPI_Datatype mpi_datatype< double > ()
 
template<>
MPI_Datatype mpi_datatype< long double > ()
 
template<>
MPI_Datatype mpi_datatype< bool > ()
 

Typedef Documentation

◆ MPIRank

using terra::mpi::MPIRank = typedef int

Function Documentation

◆ agglomerate_rank()

MPIRank terra::mpi::agglomerate_rank ( MPIRank  parent_rank,
int  factor 
)
inline

Translate a parent-comm rank into its agglomerated sub-comm rank.

Inverse of the color/key rule in build_level_comms: if agglomeration groups every factor consecutive parent ranks into a single sub-comm rank, then parent rank r maps to sub-comm rank r / factor.

Useful when remapping a subdomain_to_rank function to the coarser comm.

Parameters
parent_rankRank on the parent comm.
factorAgglomeration factor at this descent step.
Returns
Rank on the sub-comm (valid only if parent_rank % factor == 0).

◆ barrier()

void terra::mpi::barrier ( )
inline

◆ build_level_comms()

std::vector< MPI_Comm > terra::mpi::build_level_comms ( MPI_Comm  root_comm,
const std::vector< int > &  factors 
)
inline

Build a nested ladder of sub-communicators for hierarchical agglomeration.

Given a parent communicator (typically MPI_COMM_WORLD) and per-level agglomeration factors, constructs a sequence of communicators where each successor is a subset of the preceding one. Used by multigrid to run coarse levels on fewer ranks so collectives cost less at the bottom of the V-cycle.

Factor semantics: at descent step i, ranks whose index on the parent comm is divisible by factors[i] are kept, the rest drop out and get MPI_COMM_NULL at that and every deeper level.

The result has size factors.size() + 1: index 0 is the finest (= root), the rest are progressively smaller. The sizes on surviving ranks are {N, N/factors[0], N/(factors[0]*factors[1]), ...}.

Parameters
root_commThe finest-level communicator.
factorsPer-descent agglomeration factors. Must all be >= 1 and evenly divide the preceding level size.
Returns
Per-level communicators. Entries past the first drop-out are MPI_COMM_NULL for dropped ranks.

◆ free_level_comms()

void terra::mpi::free_level_comms ( std::vector< MPI_Comm > &  level_comms)
inline

Free a level-comm ladder. Call once at MG teardown.

MPI_Comm_free is collective on the comm, so every rank that got a non-null handle must call it. Ranks that got MPI_COMM_NULL at a level must skip. The root comm (index 0) is not freed here — caller owns it.

◆ mpi_datatype()

template<typename T >
MPI_Datatype terra::mpi::mpi_datatype ( )

◆ mpi_datatype< bool >()

template<>
MPI_Datatype terra::mpi::mpi_datatype< bool > ( )
inline

◆ mpi_datatype< char >()

template<>
MPI_Datatype terra::mpi::mpi_datatype< char > ( )
inline

◆ mpi_datatype< double >()

template<>
MPI_Datatype terra::mpi::mpi_datatype< double > ( )
inline

◆ mpi_datatype< float >()

template<>
MPI_Datatype terra::mpi::mpi_datatype< float > ( )
inline

◆ mpi_datatype< int >()

template<>
MPI_Datatype terra::mpi::mpi_datatype< int > ( )
inline

◆ mpi_datatype< long >()

template<>
MPI_Datatype terra::mpi::mpi_datatype< long > ( )
inline

◆ mpi_datatype< long double >()

template<>
MPI_Datatype terra::mpi::mpi_datatype< long double > ( )
inline

◆ mpi_datatype< long long >()

template<>
MPI_Datatype terra::mpi::mpi_datatype< long long > ( )
inline

◆ mpi_datatype< short >()

template<>
MPI_Datatype terra::mpi::mpi_datatype< short > ( )
inline

◆ mpi_datatype< signed char >()

template<>
MPI_Datatype terra::mpi::mpi_datatype< signed char > ( )
inline

◆ mpi_datatype< unsigned char >()

template<>
MPI_Datatype terra::mpi::mpi_datatype< unsigned char > ( )
inline

◆ mpi_datatype< unsigned int >()

template<>
MPI_Datatype terra::mpi::mpi_datatype< unsigned int > ( )
inline

◆ mpi_datatype< unsigned long >()

template<>
MPI_Datatype terra::mpi::mpi_datatype< unsigned long > ( )
inline

◆ mpi_datatype< unsigned long long >()

template<>
MPI_Datatype terra::mpi::mpi_datatype< unsigned long long > ( )
inline

◆ mpi_datatype< unsigned short >()

template<>
MPI_Datatype terra::mpi::mpi_datatype< unsigned short > ( )
inline

◆ mpi_error_string()

std::string terra::mpi::mpi_error_string ( int  err)
inline

◆ num_processes() [1/2]

int terra::mpi::num_processes ( )
inline

◆ num_processes() [2/2]

int terra::mpi::num_processes ( MPI_Comm  comm)
inline

◆ rank() [1/2]

MPIRank terra::mpi::rank ( )
inline

◆ rank() [2/2]

MPIRank terra::mpi::rank ( MPI_Comm  comm)
inline