摘自http://www.mcs.anl.gov/research/projects/mpi/www/www3/MPI_Allreduce.html
Computes the scan (partial reductions) of data on a collection of processesSynopsis
int MPI_Scan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
Input Parameters
-
sendbuf
- starting address of send buffer (choice) count
- number of elements in input buffer (integer) datatype
- data type of elements of input buffer (handle) op
- operation (handle) comm
- communicator (handle)
Output Parameter
-
recvbuf
starting address of receive buffer (choice)
下段摘自http://micro.ustc.edu.cn/Linux/MPI/MPICH/mpi411.htm
MPI_SCAN常用于对分布于组中的数据作前置归约操作.此操作将序列号为0,... ,i(包括i)的进程发送缓冲区的值的归约结果存入序列号为i 的进程的接收消息缓冲区中,这种操作支持的类型、语义以及对发送及接收缓冲区的限制和MPI_REDUCE相同.
意即:前一个进程缓冲区的结果与当前进程缓冲区的值为MPI_scan的操作数。
发现一个问题,时间久了就忘了
cite from
http://www.netlib.org/utk/papers/mpi-book/node31.html
http://www.mpi-forum.org/docs/mpi21-report/node45.htm
In C, status is a structure of type MPI_Status that contains three fields named MPI_SOURCE, MPI_TAG, and MPI_ERROR; the structure may contain additional fields. Thus, status.MPI_SOURCE, status.MPI_TAG and status.MPI_ERROR contain the source, tag and error code, respectively, of the received message.
In Fortran, status is an array of INTEGERs of length MPI_STATUS_SIZE. The three constants MPI_SOURCE, , MPI_TAG and MPI_ERROR are the indices of the entries that store the source, tag and error fields. Thus status(MPI_SOURCE), status(MPI_TAG) and status(MPI_ERROR) contain, respectively, the source, the tag and the error code of the received message.
The status argument also returns information on the length of the message received. However, this information is not directly available as a field of the status variable and a call to MPI_GET_COUNT is required to ``decode'' this information.
MPI_BCast
注意点:
要使当前处理器也得到MPI_Bcast的结果,要确保当前处理器上也调用了MPI_Bcast
如果当前处理器上(接收MPI_Bcast结果的处理器)未调用MPI_BCast语句,则无法获取广播的值