Q-Logic IB6054601-00 D Benutzerhandbuch

Seite von 122
3 – Using InfiniPath MPI
Getting Started with MPI
3-2
IB6054601-00 D
Q
These examples assume that:
 Your cluster administrator has properly installed InfiniPath MPI and the 
PathScale compilers. 
 Your cluster’s policy allows you to use the 
mpirun
 script directly, without having 
to submit the job to a batch queuing system. 
 You or your administrator has properly set up your 
ssh
 keys and associated files 
on your cluster. Se
 and 
 for details on 
ssh
 
administration.
To begin, copy the examples to your working directory:
cp /usr/share/mpich/examples/basic/* .
Next, create an MPI hosts file in the same working directory. It contains the host 
names of the nodes in your cluster on which you want to run the examples, with 
one host name per line. Name this file 
mpihosts
. The contents can be in the 
following format:
hostname1
hostname2
...
There is more information on the 
mpihosts
 file in 
3.3.1
An Example C Program
InfiniPath MPI uses some shell scripts to find the appropriate include files and 
libraries for each supported language. Use the script 
mpicc
 to compile an MPI 
program in C and the script 
mpirun
 to execute it.
The supplied example program 
cpi.c
 computes an approximation to pi. First, 
compile it to an executable named 
cpi
mpicc -o cpi cpi.c
mpicc
, by default, runs the PathScale pathcc or gcc compiler, and is used for 
both compiling and linking, exactly as you'd use the 
pathcc
 command.
NOTE:
On ppc64 systems, gcc is the default compiler. For information on using 
other compilers, see 
Then, run it with several different specifications for the number of processes: 
mpirun -np 2 -m mpihosts ./cpi
Process 0 on hostname1
Process 1 on hostname2
pi is approximately 3.1416009869231241, 
Error is 0.0000083333333309
wall clock time = 0.000149