12 lines
254 B
Python
Raw Permalink Normal View History

2023-11-23 16:02:33 +01:00
from mpi4py import MPI
comm = MPI.COMM_WORLD
rank = comm.Get_rank()
if rank == 0:
data = "Hello, from process 0!"
comm.send(data, dest=1)
elif rank == 1:
received_data = comm.recv(source=0)
print(f"Process 1 received: {received_data}")