55 boost::mpi::communicator
const &comm,
int root = 0) {
56 auto const n_elem =
static_cast<int>(buffer.size());
58 if (comm.rank() == root) {
59 static std::vector<int> sizes;
60 static std::vector<int> displ;
63 detail::size_and_offset<T>(sizes, displ, n_elem, comm, root);
66 buffer.resize(
static_cast<unsigned int>(tot_size));
69 if (sizes[root] && displ[root]) {
70 for (
int i = sizes[root] - 1; i >= 0; --i) {
71 buffer[i + displ[root]] = buffer[i];
76 gatherv(comm, buffer.data(), tot_size, buffer.data(), sizes.data(),
80 detail::size_and_offset(n_elem, comm, root);
82 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)