如何做到所有减少boost::mpi
1.53? (这是CentOS 7的版本)
提升1.61有boost::mpi::inplace_t
(doc)但提升1.53没有(doc)。
对于1.61,我可以使用:
boost::mpi::all_reduce(
comm,
boost::mpi::inplace_t<int*>(ptr_int_array),
n_elements,
op);
答案 0 :(得分:1)
如果您不希望增加out_value
字段,可以通过设置返回函数的值来覆盖in_value
。
#include <boost/mpi.hpp>
int main()
{
boost::mpi::environment env;
boost::mpi::communicator comm;
// set in_value to whatever you want.
int in_value = comm.rank()
// overwrite.
in_value = all_reduce(comm, in_value, std::plus<double>());
return 0;
}