Boost logo

Boost Users :

Subject: [Boost-users] Boost MPI Collective
From: Nolen, Steven Douglas (drnuke_at_[hidden])
Date: 2014-08-25 11:59:21


In boost/mpi/collectives/reduce.hpp
The template function specialization for reduce-ing a std::vector, should probably be modified.

Ffrom

template<typename T, typename Op>
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<typename T, typename Op>
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



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net