TutorialsTutorials HomeMPI IntroductionIndexBasic Concepts Initialization Data Types Basic Send Basic Receive Broadcast Reduction Example
FullDocument
Related InfoMPI ResourcesIBM DocsProgramming GuideSubroutine Reference |
Broadcast
Often you will have data on one processor that it needs to
share with all other processors. You accomplish this
by using
a broadcast, which sends data to a group of processes.
The MPI routine FortranFORTRAN_TYPE:: buff INTEGER:: count, root, ierr CALL MPI_BCAST(buff, count, MPI_TYPE, root, comm, ierr) Cint MPI_Bcast( void *buff, int count, MPI_Datatype datatype, int root, MPI_Comm comm) where the variables are the same as before, except
ExampleThis sample program, bcast.f90 is available in $EXAMPLES/mpi/intro/bcast/. The program has task 0 calculate a value for the variable rsq and then broadcast that value to all the other tasks. Each task then prints out the value, thus verifying the broadcast. If we compile and run, we get these results franklin% ftn -o bcast bcast.f90 franklin% qsub -I -lmppwidth=8 frnaklin% cd $PBS_O_WORKDIR franklin% aprun -n 8 ./bcast TASK # 0 has rsq= 27.562500 TASK # 1 has rsq= 27.562500 TASK # 2 has rsq= 27.562500 TASK # 3 has rsq= 27.562500 TASK # 4 has rsq= 27.562500 TASK # 5 has rsq= 27.562500 TASK # 6 has rsq= 27.562500 TASK # 7 has rsq= 27.562500 Each task ends up with the same value of the variable rsq. |
![]() |
Page last modified: Fri, 07 Mar 2008 21:50:17 GMT Page URL: http://www.nersc.gov/nusers/help/tutorials/mpi/intro/bcast.php Web contact: webmaster@nersc.gov Computing questions: consult@nersc.gov Privacy and Security Notice |
![]() |