12 lines
254 B
Python
12 lines
254 B
Python
|
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}")
|