Вот часть моего кода, где происходит обмен данными:
Код: Выделить всё
if self.color == 0:
current_point = self.run_MD(self.atoms, self.dyn)
i += 1
logging.info(f"Sampled point {i}.")
for dest in range(1, MPI.COMM_WORLD.Get_size()):
MPI.COMM_WORLD.isend(current_point, dest=dest, tag=0)
if req is None:
req = MPI.COMM_WORLD.irecv(source=1, tag=1)
if req.Test():
sampled_points = req.wait()
logging.info(f"Received {sampled_points}.")
req = None
elif self.color == 1:
if req is None:
req = MPI.COMM_WORLD.irecv(source=0, tag=0)
# Get the current point (blocking)
current_point = req.wait()
i += 1
if RANK == 1:
logging.info(f"Recalculating point {i} with DFT.")
sampled_points.append(self.recalc_aims(current_point))
if RANK == 1:
logging.info(f'len(sampled_points): {len(sampled_points)}')
req_send = MPI.COMM_WORLD.isend(sampled_points, dest=0, tag=1)
req_send.wait()
req = None
Подробнее здесь: https://stackoverflow.com/questions/792 ... d-mpi-comm