22#include <boost/mpi/communicator.hpp>
23#include <boost/mpi/request.hpp>
34inline std::vector<int> displacements(std::span<int const> sizes) {
35 std::vector<int> displ(sizes.size());
38 for (std::size_t i = 0u; i < displ.size(); i++) {
47std::vector<boost::mpi::request>
48iall_gatherv_impl(boost::mpi::communicator
const &comm, T
const *in_values,
49 int in_size, T *out_values,
int const *sizes,
51 auto const n_nodes = comm.size();
52 auto const rank = comm.rank();
55 if (in_values != out_values) {
56 std::copy_n(in_values, in_size, out_values + displs[rank]);
59 std::vector<boost::mpi::request> req;
60 for (
int i = 0; i < n_nodes; i++) {
62 req.emplace_back(comm.isend(i, 42, out_values + displs[rank], in_size));
63 req.emplace_back(comm.irecv(i, 42, out_values + displs[i], sizes[i]));
73auto iall_gatherv(boost::mpi::communicator
const &comm, T
const *in_values,
74 int in_size, T *out_values,
int const *sizes) {
76 detail::displacements({sizes,
static_cast<size_t>(comm.size())});
78 return detail::iall_gatherv_impl(comm, in_values, in_size, out_values, sizes,
auto iall_gatherv(boost::mpi::communicator const &comm, T const *in_values, int in_size, T *out_values, int const *sizes)