TRIQS/mpi 1.3.0
C++ interface to MPI
Loading...
Searching...
No Matches
generic_communication.hpp File Reference
#include "./communicator.hpp"
#include "./datatypes.hpp"
#include "./macros.hpp"
#include "./utils.hpp"
#include <mpi.h>
#include <algorithm>
#include <concepts>
#include <ranges>
#include <type_traits>
#include <vector>

Detailed Description

Provides generic implementations for a subset of collective MPI communications (broadcast, reduce, gather, scatter).

The generic functions (mpi::broadcast, mpi::reduce, mpi::scatter, ...) call their more specialized counterparts (e.g. mpi::mpi_broadcast, mpi::mpi_reduce, mpi::mpi_scatter, ...). They depend on ADL.

Definition in file generic_communication.hpp.

Go to the source code of this file.

Concepts

concept  mpi::MPICompatibleRange
 A concept that checks if a range type is contiguous and sized and has an MPI compatible value type.
 

Functions

template<typename T>
bool mpi::all_equal (T const &x, communicator c={})
 Checks if a given object is equal across all ranks in the given communicator.
 
template<typename T>
decltype(auto) mpi::all_gather (T &&x, communicator c={})
 Generic MPI all-gather.
 
template<typename T1, typename T2>
void mpi::all_gather_into (T1 &&x_in, T2 &&x_out, communicator c={})
 Generic MPI all-gather that gathers directly into an existing output object.
 
template<typename T>
decltype(auto) mpi::all_reduce (T &&x, communicator c={}, MPI_Op op=MPI_SUM)
 Generic MPI all-reduce.
 
template<typename T>
void mpi::all_reduce_in_place (T &&x, communicator c={}, MPI_Op op=MPI_SUM)
 Generic MPI all-reduce in place.
 
template<typename T1, typename T2>
void mpi::all_reduce_into (T1 &&x_in, T2 &&x_out, communicator c={}, MPI_Op op=MPI_SUM)
 Generic MPI all-reduce that reduces directly into an existing output object.
 
template<typename T>
void mpi::broadcast (T &&x, communicator c={}, int root=0)
 Generic MPI broadcast.
 
template<typename T>
decltype(auto) mpi::gather (T &&x, communicator c={}, int root=0, bool all=false)
 Generic MPI gather.
 
template<typename T1, typename T2>
void mpi::gather_into (T1 &&x_in, T2 &&x_out, communicator c={}, int root=0, bool all=false)
 Generic MPI gather that gathers directly into an existing output object.
 
template<typename T>
requires (has_mpi_type<T>)
void mpi::mpi_broadcast (T &x, communicator c={}, int root=0)
 Implementation of an MPI broadcast for types that have a corresponding MPI datatype.
 
template<typename T>
requires (has_mpi_type<T>)
std::vector< T > mpi::mpi_gather (T const &x, communicator c={}, int root=0, bool all=false)
 Implementation of an MPI gather for types that have a corresponding MPI datatype.
 
template<typename T, MPICompatibleRange R>
requires (has_mpi_type<T> && std::same_as<T, std::remove_cvref_t<std::ranges::range_value_t<R>>>)
void mpi::mpi_gather_into (T const &x, R &&rg, communicator c={}, int root=0, bool all=false)
 Implementation of an MPI gather that gathers directly into an existing output range for types that have a corresponding MPI datatype.
 
template<typename T>
requires (has_mpi_type<T>)
mpi::mpi_reduce (T const &x, communicator c={}, int root=0, bool all=false, MPI_Op op=MPI_SUM)
 Implementation of an MPI reduce for types that have a corresponding MPI datatype.
 
template<typename T>
requires (has_mpi_type<T>)
void mpi::mpi_reduce_into (T const &x_in, T &x_out, communicator c={}, int root=0, bool all=false, MPI_Op op=MPI_SUM)
 Implementation of an MPI reduce that reduces directly into an existing output object for types that have a corresponding MPI datatype.
 
template<typename T>
decltype(auto) mpi::reduce (T &&x, communicator c={}, int root=0, bool all=false, MPI_Op op=MPI_SUM)
 Generic MPI reduce.
 
template<typename T>
void mpi::reduce_in_place (T &&x, communicator c={}, int root=0, bool all=false, MPI_Op op=MPI_SUM)
 Generic in place MPI reduce.
 
template<typename T1, typename T2>
void mpi::reduce_into (T1 &&x_in, T2 &&x_out, communicator c={}, int root=0, bool all=false, MPI_Op op=MPI_SUM)
 Generic MPI reduce that reduces directly into an existing output object.
 
template<typename T>
decltype(auto) mpi::scatter (T &&x, mpi::communicator c={}, int root=0)
 Generic MPI scatter.
 
template<typename T1, typename T2>
void mpi::scatter_into (T1 &&x_in, T2 &&x_out, communicator c={}, int root=0)
 Generic MPI scatter that scatters directly into an existing output object.