Tutorial 4

Point to Point Communication

Part 1:

To set up communications and use MPI in python there needs to be the creation of object MPI.COMM_WORLD. This sets up communication between all nodes as well as initializes all variables and contains all functions to use.

There are various ways to send data to other processors and or nodes in mpi4py. One of the most basic ways to do it is by using the send and recv commands which are better known as point-to-point communication.

The Raspberry Pi has 4 processors per node meaning that in the cluster there is always going to be 4n number of processors where n is the number of nodes active.

You can change it with the function setNodeNumber # talked about in previous tutorials.

This will change the overall processors available the total of which can be found with Get_size() command and the rank of the processor from Get_rank(). The name of the node can also be figured out using the MPI.Get_Processor_name().

The program then has an if conditional which has the first rank as the one sending the information and all the processors receiving the data and then printing it out.

In this case, the data is just the rank of the first processor but it can be int, string, or an array.

The if conditional sets the rank then goes through a for loop the size of all processors available using the data of rank 0 processor and sending it to dest=i which goes through each processor.

Then all processors receive using comm.recv and the source which is sending the data in this case source= 0.