Parallel Processing and Algorithms

Module: PVM and MPI

MPI shell scripts

MPI compile scripts

With MPI you will need additional libraries and parameters to compile the C code. To make the live easier for you it is better to use a shell script, which includes all the needed parameters. For that reason you should create a new file in your mpi_directory called "mcc".
Add the following rows into this file:

#!/bin/sh
#script to compile all C-progs in the subdirs
if [ $1 ]
then
echo "start compiling"
hcc $1.c -o $1
echo "done"
else
echo "Parameter (filename without ending .c) missing."
fi

Save the file and make it executable with chmod: "chmod u+x mcc"
Now you can compile your code just with a simple command "mcc program_name"

Before you can try to test your program you need to start the MPI daemon. Just execute the following command.

lamboot /etc/bhosts

Use the following command to run your MPI program on more than one processor:
mpirun -np 2 program_name (the 2 stand for two nodes, change the number to run it on more nodes)

Do not forget to stop the MPI daemon after you finished your work. Use the following command:

lamhalt

examples

Here is a simple MPI example:
cpi.c


back to the main page

© Oliver Otto - The University of Reading / Salford