52 auto bsize = v.size();
54 if (c.rank() != root) v.resize(bsize);
89 std::vector<regular_t<T>> res(c.rank() == root || all ? v.size() : 0);
107 auto bsize = v.size();
109 std::vector<T> res(
chunk_length(bsize, c.size(), c.rank()));
128 std::vector<T> res(c.rank() == root || all ? bsize : 0);
C++ wrapper around MPI_Comm providing various convenience functions.
Provides a C++ wrapper class for an MPI_Comm object.
Provides generic implementations for a subset of collective MPI communications (broadcast,...
void reduce_in_place_range(R &&rg, communicator c={}, int root=0, bool all=false, MPI_Op op=MPI_SUM)
Implementation of an in-place MPI reduce for an mpi::contiguous_sized_range object.
auto mpi_reduce(std::array< T, N > const &arr, communicator c={}, int root=0, bool all=false, MPI_Op op=MPI_SUM)
Implementation of an MPI reduce for a std::array.
void reduce_range(R1 &&in_rg, R2 &&out_rg, communicator c={}, int root=0, bool all=false, MPI_Op op=MPI_SUM)
Implementation of an MPI reduce for an mpi::contiguous_sized_range.
void scatter_range(R1 &&in_rg, R2 &&out_rg, long in_size, communicator c={}, int root=0, long chunk_size=1)
Implementation of an MPI scatter for an mpi::contiguous_sized_range.
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.
auto mpi_scatter(std::vector< T > const &v, communicator c={}, int root=0)
Implementation of an MPI scatter for a std::vector.
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.
void mpi_reduce_in_place(std::array< T, N > &arr, communicator c={}, int root=0, bool all=false, MPI_Op op=MPI_SUM)
Implementation of an in-place MPI reduce for a std::array.
long chunk_length(long end, int nranges, int i, long min_size=1)
Get the length of the ith subrange after splitting the integer range [0, end) as evenly as possible a...
Provides an MPI broadcast, reduce, scatter and gather for contiguous ranges.
Provides general utilities related to MPI.