|
Boost Users : |
Subject: [Boost-users] [mpi] could all_reduce handle MPI_IN_PLACE ?
From: Alain Miniussi (Alain.Miniussi_at_[hidden])
Date: 2009-06-05 18:58:32
Hi,
There doesn't seems to be an elgant way to do an in place all_reduce
on array right now (Although I only stumbled on the issue after
I moved to openmpi 1.3.2).
That is, if all_reduce_impl is called with (in_values == out_values)
MPI is allowed to compain with a MPI_ERR_BUF. Of course, one
can call all_reduce with static_cast<T*>(MPI_IN_PLACE) but I do not
find that solution very elegant.
Would it be a problem to modify all_reduce_impl into:
template<typename T, typename Op>
void
all_reduce_impl(const communicator& comm, const T* in_values, int n,
T* out_values, Op /*op*/, mpl::true_ /*is_mpi_op*/,
mpl::true_ /*is_mpi_datatype*/)
{
if (in_values == out_values) {
in_values = static_cast<T*>(MPI_IN_PLACE);
}
BOOST_MPI_CHECK_RESULT(MPI_Allreduce,
(const_cast<T*>(in_values), out_values, n,
boost::mpi::get_mpi_datatype<T>(*in_values),
(is_mpi_op<Op, T>::op()), comm));
}
It worked for me, and if there is an agreement I can propose a patch.
Regards,
-- Alain Miniussi http://www.oca.eu/alainm Equipe CRIMSON https://crimson.oca.eu +33 492 00 30 09
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