I'm new to the concept of parallel programming. I'm supposed to use mpi4run for a project, but I don't know how to actually run it. For example, if I want to run this code :
from mpi4py import MPI
import numpy as np
comm = MPI.COMM_WORLD
rank = comm.Get_rank()
if rank == 0:
numData = 5
data = np.linspace(0.0,3.14,numData)
else:
numData = None
numData = comm.bcast(numData, root=0)
if rank != 0:
data = np.empty(numData, dtype='d')
comm.Bcast(data, root=0)
print('Rank: ',rank, ', data received: ',data)
If i run from directly from my IDLE i get:
Rank: 0 , data received: [0. 0.785 1.57 2.355 3.14 ]
But, if I understand correctly, that's not the way we should run it to do the parallel computing, right? On the internet, I find that one runs it with writing
mpirun -n 4 python script.py.
My question is, where do I type that? I have tried on the cmd and the python shell but I get errors, syntaxerrors and so on. I feel there is something I don't understand here. Any tips?