CSE 557: Concurrent Concurrent Scientific Computing

CSE 557: Concurrent Scientific Computing  Home Page



MPI Examples

The package includes the following files:
cpi1.c
cpi2.c
hello_world.c
hello_world_cc.cc
Makefile
machines.sample
rhosts.sample

Before using MPI, you must:

setenv MPI_ROOT /home/software/mpich

set path = ( $path $MPI_ROOT/bin )
 


You must create a .rhosts file in your home directory.
A sample file rhost.sample is given:
1. Change raghavan to your login.
2. Add the machine you are logged into as the first line (with your userid)
4. Store as .rhosts, only ls -la will show this file.

 

cpi1.c and cpi2.c compute pi in parallel.
hello_world.c/cc is an even simpler example (see the code).
 

To compile the programs, type
> make
then you will get excutables: cpi1, cpi2, hello_world, hello_world_cc
 

To run the programs, type
> mpirun -np 4 -machinefile machines.sample <name of excutable>
"machines_sample" includes the list of machine names on
which you want to run the prgoram. You should use machines
listed in .rhosts file.