NERSC logo National Energy Research Scientific Computing Center
  A DOE Office of Science User Facility
  at Lawrence Berkeley National Laboratory
 

Example

We'll put together things we've learned into an example program. This program uses collective operations to broadcast a value to all tasks and gather results from all tasks to task 0.

This example, flip.f90, available in $EXAMPLES/MPI_intro/flip, demonstrates these calls.

If we compile and run on the SP, we get

seaborg% mpxlf90 -o flip -qsuffix=f=f90 flip.f90
1501-510  Compilation successful for file flip.f90
seaborg% poe ./flip -procs 8 -nodes 1  
subfilter: default repo mpccc will be charged
 Flipping coin  1000000  times on each task.
 Processor  1  got  499614  heads.
 Processor  0  got  499493  heads.
 Processor  3  got  500017  heads.
 Processor  2  got  500595  heads.
 Processor  5  got  499306  heads.
 Processor  4  got  499778  heads.
 Processor  6  got  500008  heads.
 Processor  7  got  500830  heads.
 Heads came up  49.99551392  percent of the time.

LBNL Home
Page last modified: Mon, 24 May 2004 22:28:41 GMT
Page URL: http://www.nersc.gov/nusers/help/tutorials/mpi/intro/example.php
Web contact: webmaster@nersc.gov
Computing questions: consult@nersc.gov

Privacy and Security Notice
DOE Office of Science