In boost/mpi/collectives/reduce.hpp
The template function specialization for reduce-ing a std::vector, should probably be modified.
Ffrom
template
void
reduce(const communicator & comm, std::vector<T> const & in_values,
std::vector<T> & out_values, Op op, int root)
{
out_values.resize(in_values.size());
reduce(comm, &in_values.front(), in_values.size(), &out_values.front(), op,
root);
}
To
template
void
reduce(const communicator & comm, std::vector<T> const & in_values,
std::vector<T> & out_values, Op op, int root)
{
if( comm.rank() == root ) out_values.resize(in_values.size());
reduce(comm, &in_values.front(), in_values.size(), &out_values.front(), op,
root);
}
This will save an extraneous allocation on the non-root nodes.
-steve