Skip to content
Snippets Groups Projects
Commit 709b8af6 authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

[BL/MPI] allreduce version for vectors

parent 8a69e0a2
No related branches found
No related tags found
No related merge requests found
......@@ -112,6 +112,18 @@ static T allreduce(T const& value, MPI_Op const& mpi_op, Mpi const& mpi)
return result;
}
template <typename T>
static std::vector<T> allreduce(std::vector<T> const& vector,
MPI_Op const& mpi_op, Mpi const& mpi)
{
std::size_t const size = vector.size();
std::vector<T> result(vector.size());
MPI_Allreduce(vector.data(), result.data(), size, mpiType<T>(), mpi_op,
mpi.communicator);
return result;
}
template <typename T>
static void allreduceInplace(std::vector<T>& vector,
MPI_Op const& mpi_op,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment