54 boost::mpi::communicator
const &comm,
int root = 0) {
55 auto const n_elem =
static_cast<int>(buffer.size());
57 if (comm.rank() == root) {
58 std::vector<int> sizes;
59 std::vector<int> displ;
62 detail::size_and_offset<T>(sizes, displ, n_elem, comm, root);
65 buffer.resize(
static_cast<unsigned int>(tot_size));
68 if (sizes[root] && displ[root]) {
69 for (
int i = sizes[root] - 1; i >= 0; --i) {
70 buffer[i + displ[root]] = buffer[i];
75 gatherv(comm, buffer.data(), tot_size, buffer.data(), sizes.data(),
79 detail::size_and_offset(n_elem, comm, root);
81 gatherv(comm, buffer.data(), n_elem,
static_cast<T *
>(
nullptr),
nullptr,
void gather_buffer(std::vector< T, Allocator > &buffer, boost::mpi::communicator const &comm, int root=0)
Gather buffer with different size on each node.
void gatherv(const boost::mpi::communicator &comm, const T *in_values, int in_size, T *out_values, const int *sizes, const int *displs, int root)