I have 2 processes in my program. Where process(0)
is the master and process(1)
is slave. There is a common loop for both (which increments from 0 to 4).
I am trying to send a value(i
) to process(1)
from process(0)
. But process(1)
does not get the new values of i
from process(0)
.
cw = MPI.COMM_WORLD
rank = cw.Get_rank()
nProcesses = cw.Get_size()
currentTrial = np.zeros(nProcesses-1, dtype='int32')
receivedTrial = np.zeros(1, dtype='int32')
i = 0
while (i < 5):
if (rank == 0):
currentTrial[0] = 0
#print(i)
sendToSlave = cw.Isend(currentTrial[0:1], dest=1)
print(sendToSlave.Test())
i = i+ 1
currentTrial[0] = i
if (rank != 0):
#receive a trial number
receiveFromMaster = cw.Recv(receivedTrial[:], source=0)
print("rank", rank,receivedTrial)
This is currently the output I get:
True
rank 1 [0]
True
True
True
True
rank 1 [0]
rank 1 [0]
rank 1 [0]
rank 1 [0]
Ideally, process(1)
should print [0] [1] [2] [3] [4]