19#ifndef OPM_COMMUNICATION_UTILS_HPP
20#define OPM_COMMUNICATION_UTILS_HPP
42template<
class T,
class A,
class C>
43std::pair<std::vector<T, A>,
47 std::vector<int> sizes(comm.size());
48 std::vector<int> displ(comm.size() + 1, 0);
49 int mySize = input.size();
50 comm.allgather(&mySize, 1, sizes.data());
51 std::partial_sum(sizes.begin(), sizes.end(), displ.begin()+1);
52 std::vector<T,A> output(displ.back());
53 comm.allgatherv(input.data(), input.size(), output.data(), sizes.data(), displ.data());
54 return {output, displ};
72template<
class T,
class A,
class C>
73std::pair<std::vector<T, A>,
75gatherv(
const std::vector<T,A>& input,
const C& comm,
int root)
77 bool isRoot = (comm.rank() == root);
78 std::vector<int> sizes;
79 std::vector<int> displ;
80 std::vector<T,A> output;
84 sizes.resize(comm.size());
85 displ.resize(comm.size() + 1);
87 int mySize = input.size();
88 comm.gather(&mySize, sizes.data(), 1, root);
92 std::partial_sum(sizes.begin(), sizes.end(),
94 output.resize(displ.back());
97 comm.gatherv(input.data(), input.size(), output.data(), sizes.data(), displ.data(), root);
98 return {output, displ};
Holds the implementation of the CpGrid as a pimple.
Definition: CellQuadrature.hpp:26
std::pair< std::vector< T, A >, std::vector< int > > allGatherv(const std::vector< T, A > &input, const C &comm)
Gathers vectors from all processes on all processes.
Definition: CommunicationUtils.hpp:45
std::pair< std::vector< T, A >, std::vector< int > > gatherv(const std::vector< T, A > &input, const C &comm, int root)
Gathers vectors from all processes on a root process.
Definition: CommunicationUtils.hpp:75