from mpi4py import MPI
import numpy as np

comm = MPI.COMM_WORLD
rank = comm.Get_rank()
size = comm.Get_size()
#modify this function so we don't have a deadlock
send_data = np.random.randint(0,2**20, size=2**20, dtype='int')
#send_data = np.array([1,2,4,5], dtype='int')
recv_data =np.zeros(2*2**20, dtype='int')
#recv_data =np.zeros(4, dtype='int')
next = (rank + 1)%size
prev = (size + rank -1) % size
comm.Send([send_data, MPI.INT], dest=next, tag=11)
comm.Recv([recv_data, MPI.INT], source=prev, tag=11)



