...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::scan — Compute a prefix reduction of values from all processes in the communicator.
// In header: <boost/mpi/collectives.hpp> template<typename T, typename Op> void scan(const communicator & comm, const T & in_value, T & out_value, Op op); template<typename T, typename Op> T scan(const communicator & comm, const T & in_value, Op op); template<typename T, typename Op> void scan(const communicator & comm, const T * in_values, int n, T * out_values, Op op);
scan
is a collective algorithm that combines the values stored by each process with the values of all processes with a smaller rank. The values can be arbitrarily combined, specified via a function object op
. 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 gather
to some process, followed by an std::prefix_sum()
over the gathered values using the operation op
. The ith process returns the ith value emitted by std::prefix_sum()
.
When the type T
has an associated MPI data type, this routine invokes MPI_Scan
to perform the reduction. If possible, built-in MPI operations will be used; otherwise, scan()
will create a custom MPI_Op
for the call to MPI_Scan.
Parameters: |
|
||||||||
Returns: |
If no |