KaMPIng 0.1.1
Flexible and (near) zero-overhead C++ bindings for MPI
Loading...
Searching...
No Matches
kamping::DistributedCommunicationGraph< DefaultContainer > Class Template Reference

A (vertex-centric) distributed communication graph. Each vertex of the graph corresponds to a rank and each edge (i,j) connect two ranks i and j which can communicate with each other. The distributed communication graph is vertex-centric in the sense that on each rank the local graph only contains the corresponding vertex and its in and out neighborhood. Note that MPI allow multiple edges between the same ranks i and j, i.e. the distributed communication graph can be a multi-graph. More...

#include <distributed_graph_communicator.hpp>

Public Member Functions

 DistributedCommunicationGraph ()=default
 Default constructor.
 
template<typename InNeighborsRange , typename OutNeighborsRange >
 DistributedCommunicationGraph (InNeighborsRange const &in_neighbors, OutNeighborsRange const &out_neighbors)
 Constructs a communication graph based on a range of in-going and out-going edges which might be weighted. A unweighted edge is simply an integer, wherea a weighted edge is a pair-like object consisting of two integers which can be decomposed by a structured binding via auto [rank, weight] = weighted_edge;.
 
 DistributedCommunicationGraph (DefaultContainer< int > &&in_ranks, DefaultContainer< int > &&out_ranks)
 Constructs a communication graph based on a range of unweighted in-going and out-going neighbors, i.e., ranks.
 
 DistributedCommunicationGraph (DefaultContainer< int > &&in_ranks, DefaultContainer< int > &&out_ranks, DefaultContainer< int > &&in_weights, DefaultContainer< int > &&out_weights)
 Constructs a communication graph based on a range of weighted in-going and out-going neighbors. The ownership of the underlying ranks/weights containers is transfered.
 
template<typename NeighborRange >
 DistributedCommunicationGraph (NeighborRange const &neighbors)
 Constructs a communication graph based where in and out neighbors are the same, i.e. a symmetric neighborhood/graph.
 
CommunicationGraphLocalView get_view () const
 Returns a view of the communication graph.
 
template<typename Map = std::unordered_map<size_t, size_t>>
auto get_rank_to_out_neighbor_idx_mapping ()
 In neighborhood collectives the order of sent and received data depends on the ordering of the underlying out and in neighbors (note that the MPI standard allows that a neighbor occurs multiple times within the neighbors list). For example in MPI_Neighbor_alltoall the k-th block in the send buffer is sent to the k-th neighboring process. Hence, to exchange data to rank r via neighborhood collectives it might be useful to know the index of rank r within the out neighbors (provided r is a neighbor at all). Therefore, this function returns a mapping from the rank of each out neighbor r to its index within the out neighbors. If r occurs multiple times, one of these positions is returned in the mapping.
 

Detailed Description

template<template< typename... > typename DefaultContainer = std::vector>
class kamping::DistributedCommunicationGraph< DefaultContainer >

A (vertex-centric) distributed communication graph. Each vertex of the graph corresponds to a rank and each edge (i,j) connect two ranks i and j which can communicate with each other. The distributed communication graph is vertex-centric in the sense that on each rank the local graph only contains the corresponding vertex and its in and out neighborhood. Note that MPI allow multiple edges between the same ranks i and j, i.e. the distributed communication graph can be a multi-graph.

Constructor & Destructor Documentation

◆ DistributedCommunicationGraph()

template<template< typename... > typename DefaultContainer = std::vector>
kamping::DistributedCommunicationGraph< DefaultContainer >::DistributedCommunicationGraph ( InNeighborsRange const & in_neighbors,
OutNeighborsRange const & out_neighbors )
inline

Constructs a communication graph based on a range of in-going and out-going edges which might be weighted. A unweighted edge is simply an integer, wherea a weighted edge is a pair-like object consisting of two integers which can be decomposed by a structured binding via auto [rank, weight] = weighted_edge;.

Template Parameters
InNeighborsRangeRange type of in-going neighbors.
OutNeighborsRangeRange type of out-going neighbors.
Parameters
in_neighborsRange of in-going neighbors.
out_neighborsRange of out-going neighbors.

Member Function Documentation

◆ get_rank_to_out_neighbor_idx_mapping()

template<template< typename... > typename DefaultContainer = std::vector>
template<typename Map = std::unordered_map<size_t, size_t>>
auto kamping::DistributedCommunicationGraph< DefaultContainer >::get_rank_to_out_neighbor_idx_mapping ( )
inline

In neighborhood collectives the order of sent and received data depends on the ordering of the underlying out and in neighbors (note that the MPI standard allows that a neighbor occurs multiple times within the neighbors list). For example in MPI_Neighbor_alltoall the k-th block in the send buffer is sent to the k-th neighboring process. Hence, to exchange data to rank r via neighborhood collectives it might be useful to know the index of rank r within the out neighbors (provided r is a neighbor at all). Therefore, this function returns a mapping from the rank of each out neighbor r to its index within the out neighbors. If r occurs multiple times, one of these positions is returned in the mapping.

Template Parameters
MapMap type storing the mapping, uses std::unordered_map<size_t, size_t> as default.
Returns
Returns the mapping.

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