Hardware Reference
In-Depth Information
Note that to put this on the path permanently you will need to edit
.profile
and add
at the bottom these two lines:
# Add MPI to path
PATH="$PATH:/home/rpimpi/mpich2-install/bin"
Check whether things installed successfully:
$ which mpicc
$ which mpiexec
Now you're ready to test whether MPI works for you on a single node. Change directory
back to home (
cd ~
), make a directory for testing (
mkdir mpi_testing
), and change
into your testing directory (
cd mpi_testing
). Get your IP address (
ifconfig
if neces-
sary) and put it into a single file called
machinefile
.
Then, test whether MPI works:
$ mpiexec -f machinefile -n <number> hostname
If you run:
$ mpiexec -f machinefile -n 1 hostname
The output should look like this:
raspberrypi
Now try a little C code. In the examples subdirectory of where you built MPI, you'll find
the famous CPI example, which you will now use MPI on your Pi to calculate pi:
$ cd /home/pi/mpi_testing
$ mpiexec -f machinefile -n 2 ~/mpich_build/examples/cpi
Process 0 of 2 is on raspberrypi
Process 1 of 2 is on raspberrypi
pi is approximately 3.1415926544231318, Error is 0.0000000008333387
Take a break and celebrate getting this far! (Perhaps a fourth cup of tea is in order?)
Flash Me… Once
You now have a master copy of the main node of the machine with all of the installed
files for MPI in a single place. It's time to clone the card. Shut down your Pi (
sudo
poweroff
). Remove the SD card and write the image
from
your SD card
back
to your
PC.
In
the
following
example,
we'll
call
that
file
wheezy-
raspbian_backup_mpi_master.img
.
Eject the card and put a fresh card into your SD card reader. Write the
wheezy-
raspbian_backup_mpi_master.img
image you just created to the SD card. Put this sec-