MPI_REDUCE combines the elements in the input sendbuf of
each processor, and returns the combined value at the root process in
recvbuf. There are several predefined operations op
including MPI_MAX, MPI_MIN, MPI_SUM, and
MI_PROD.
MPI_REDUCE( sendbuf, recvbuf, count, datatype, op, root, comm)
[ IN sendbuf] address of send buffer (choice)
[ OUT recvbuf] address of receive buffer (choice, significant only at root)
[ IN count] number of elements in send buffer (integer)
[ IN datatype] data type of elements of send buffer (handle)
[ IN op] reduce operation (handle)
[ IN root] rank of root process (integer)
[ IN comm] communicator (handle)
Code int MPI_Reduce(void* sendbuf, void* recvbuf, int count,
MPI_Datatype datatype, MPI_Op op, into root, MPI_Comm
comm)