48 size_t len = s.size();
50 if (c.
rank() != root) s.resize(len);
66 long len =
static_cast<long>(
all_reduce(s.size(), c));
68 if (c.rank() == root || all) res.resize(len);
C++ wrapper around MPI_Comm providing various convenience functions.
int rank() const
Get the rank of the calling process in the communicator.
Provides a C++ wrapper class for an MPI_Comm object.
Provides generic implementations for a subset of collective MPI communications (broadcast,...
void broadcast_range(R &&rg, communicator c={}, int root=0)
Implementation of an MPI broadcast for an mpi::contiguous_sized_range object.
void gather_range(R1 &&in_rg, R2 &&out_rg, long out_size, communicator c={}, int root=0, bool all=false)
Implementation of an MPI gather for an mpi::contiguous_sized_range.
void mpi_broadcast(std::array< T, N > &arr, communicator c={}, int root=0)
Implementation of an MPI broadcast for a std::arr.
decltype(auto) all_reduce(T &&x, communicator c={}, MPI_Op op=MPI_SUM)
Generic MPI all-reduce.
void broadcast(T &&x, communicator c={}, int root=0)
Generic MPI broadcast.
std::string mpi_gather(std::string const &s, communicator c={}, int root=0, bool all=false)
Implementation of an MPI gather for a std::string.
Provides an MPI broadcast, reduce, scatter and gather for contiguous ranges.