2017-04-14 72 views
1

如何做到所有減少與boost::mpi 1.53? (即CentOS 7的版本)boost :: mpi 1.53 in place all_reduce

增強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

如果你不希望有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; 
} 
相關問題