boost::mpi::scan — 计算通信器中所有进程值的prefix归约。
// 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
是一种集体算法,它将每个进程存储的值与所有秩较小的进程的值组合起来。这些值可以任意组合,通过函数对象 op
指定。值的类型 T
可以是任何可序列化的类型或具有关联 MPI 数据类型的类型。可以将此操作视为 gather 到某个进程,然后使用操作 op
对收集的值执行 std::prefix_sum()
。第 i 个进程返回 std::prefix_sum()
发出的第 i 个值。
当类型 T
具有关联的 MPI 数据类型时,此例程会调用 MPI_Scan
来执行归约。如果可能,将使用内置的 MPI 操作;否则,scan()
将创建一个自定义的 MPI_Op
来调用 MPI_Scan。
参数 |
|
||||||||
返回值 |
如果未提供 |