def recv(shape, dtype, source, tag): """ Blocking receive. """ return MPIRecvWait(tag)(*irecv(shape, dtype, source, tag)) # Ordering keys for scheduling def mpi_send_wait_key(a): """Wait as long as possible on Waits, Start Send/Recvs early.""" if isinstance(a.op, (MPIRecvWait, MPISendWait)): return 1 if isinstance(a.op, (MPIRecv, MPISend)): return -1 return 0 def mpi_tag_key(a): """Break MPI ties by using the variable tag - prefer lower tags first.""" if isinstance(a.op, (MPISend, MPIRecv, MPIRecvWait, MPISendWait)): return a.op.tag else: return 0 mpi_send_wait_cmp = key_to_cmp(mpi_send_wait_key) mpi_tag_cmp = key_to_cmp(mpi_tag_key) mpi_keys = (mpi_send_wait_key, mpi_tag_key) mpi_cmps = (mpi_send_wait_cmp, mpi_tag_cmp)
def send(var, dest, tag): return MPISendWait(tag)(*isend(var, dest, tag)) def irecv(shape, dtype, source, tag): return MPIRecv(source, tag, shape, dtype)() def recv(shape, dtype, source, tag): return MPIRecvWait(tag)(*irecv(shape, dtype, source, tag)) # Ordering keys for scheduling def mpi_send_wait_key(a): """ Wait as long as possible on Waits, Start Send/Recvs early """ if isinstance(a.op, (MPIRecvWait, MPISendWait)): return 1 if isinstance(a.op, (MPIRecv, MPISend)): return -1 return 0 def mpi_tag_key(a): """ Break MPI ties by using the variable tag - prefer lower tags first """ if isinstance(a.op, (MPISend, MPIRecv, MPIRecvWait, MPISendWait)): return a.op.tag else: return 0 mpi_send_wait_cmp = key_to_cmp(mpi_send_wait_key) mpi_tag_cmp = key_to_cmp(mpi_tag_key) mpi_keys = (mpi_send_wait_key, mpi_tag_key) mpi_cmps = (mpi_send_wait_cmp, mpi_tag_cmp)