boost :: mpi 1.53到位all_reduce

时间:2017-04-14 08:10:51

标签: c++ boost mpi

如何做到所有减少boost::mpi 1.53? (这是CentOS 7的版本)

提升1.61有boost::mpi::inplace_tdoc)但提升1.53没有(doc)。

对于1.61,我可以使用:

boost::mpi::all_reduce(
    comm, 
    boost::mpi::inplace_t<int*>(ptr_int_array), 
    n_elements, 
    op);

1 个答案:

答案 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;
}