...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::mpi::all_reduce — Combine the values stored by each process into a single value available to all processes.
// In header: <boost/mpi/collectives.hpp> template<typename T, typename Op> void all_reduce(const communicator & comm, const T * value, int n, T * out_value, Op op); template<typename T, typename Op> void all_reduce(const communicator & comm, const T & value, T & out_value, Op op); template<typename T, typename Op> T all_reduce(const communicator & comm, const T & value, Op op); template<typename T, typename Op> void all_reduce(const communicator & comm, inplace_t< T * > value, int n, Op op); template<typename T, typename Op> void all_reduce(const communicator & comm, inplace_t< T > value, Op op);
all_reduce
is a collective algorithm that combines the values stored by each process into a single value available to all processes. The values are combined in a user-defined way, specified via a function object. The type T
of the values may be any type that is serializable or has an associated MPI data type. One can think of this operation as a all_gather
, followed by an std::accumulate()
over the gather values and using the operation op
.
When the type T
has an associated MPI data type, this routine invokes MPI_Allreduce
to perform the reduction. If possible, built-in MPI operations will be used; otherwise, all_reduce()
will create a custom MPI_Op for the call to MPI_Allreduce.
If wrapped in a inplace_t
object, combine the usage of both input and $c out_value and the local value will be overwritten (a convenience function inplace
is provided for the wrapping).
Parameters: |
|
||||||||||
Returns: |
If no |