The following application is a simple Hello World style program that will demonstrate some of the features of MPI.
A list of supported MPI-based functions and datatypes can be reviewed at:
http://www.mpi-forum.org/docs/mpi-3.0/mpi30-report.pdf
You will need to log into the Master Raspberry Pi to start with.
On this machine create a new file in the code directory under mpich3
called hello_rpi.c
. For example:
vim /home/pi/mpich3/code/hello_rpi.c
To this file we are now going to add the following code:
/* Hello RPI implemented using MPI */ #include <stdio.h> #include <mpi.h>
Here we include the MPI-specific header directive: mpi.h
, which will give us access to the MPI library.
Following this we can add the main function to the code. Copy and paste the following under the header directives:
int main(int argc, char *argv[]) { int rpi; // The raspberry pi node int totalrpi; // The total number of rpi's MPI_Init(&argc, &argv); MPI_Comm_rank...