TutorialsTutorials HomeMPI IntroductionIndexBasic Concepts Initialization Data Types Basic Send Basic Receive Broadcast Reduction Example
FullDocument
Related InfoMPI ResourcesIBM DocsProgramming GuideSubroutine Reference |
ReductionOften you will have calculated some quantity or quantities on many processors and you will need to collect or reduce that data onto one or all processors. MPI provides routines to perform these reductions. One Collector
If each task in your job has calculated a private value for some
variable, var, with the same name on all tasks,
the FortranFORTRAN_TYPE:: sendbuf, recbuf INTEGER:: count, root, ierr CALL MPI_REDUCE(sendbuf, recbuf, count, & MPI_TYPE, MPI_OP, root, comm, ierr) Cint MPI_Reduce( void *sendbuf, void *recbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm) where
Possible values for MPI_OP are:
Everyone Collects
You may wish to have the reduction available to all tasks.
The routine FortranFORTRAN_TYPE:: sendbuf, recbuf INTEGER:: count, ierr CALL MPI_ALLREDUCE(sendbuf, recbuf, count, MPI_TYPE, MPI_OP, comm, ierr) Cint MPI_Allreduce( void *sendbuf, void *recbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm )
The only difference between this call and |
![]() |
Page last modified: Fri, 21 May 2004 22:25:58 GMT Page URL: http://www.nersc.gov/nusers/help/tutorials/mpi/intro/reduce.php Web contact: webmaster@nersc.gov Computing questions: consult@nersc.gov Privacy and Security Notice |
![]() |