Before we begin, I will reiterate that everything written here needs to be copied to all nodes. You may eventually have a specific master-node script and then worker-node scripts, though this is not really necessary for us at the moment.
I will be storing scripts, like the following:
~/Desktop/sct/sct2.py
Here's the code for sct2.py
from mpi4py import MPI comm = MPI.COMM_WORLD name=MPI.Get_processor_name() print("hello world") print(("name:",name,"my rank is",comm.rank))
First we need to import mpi4py, then we establish communications.
Grab processor name, output generic message, then output dynamic info
To run this:
mpirun.openmpi -np 2 -machinefile /home/pi/mpi_testing/machinefile python ~/Desktop/sct/sct2.py
Output will be something like this, I used different print outs in the picture, but same idea: