Skip to content

Instantly share code, notes, and snippets.

@Weffe
Created February 13, 2019 20:41
Show Gist options
  • Select an option

  • Save Weffe/316a0dc5faa1454cde8f89ef9d83e802 to your computer and use it in GitHub Desktop.

Select an option

Save Weffe/316a0dc5faa1454cde8f89ef9d83e802 to your computer and use it in GitHub Desktop.
Calculate execution time for non-blocking communication in mpi4py
import numpy
from mpi4py import MPI
comm = MPI.COMM_WORLD
rank = comm.Get_rank()
size = comm.Get_size()
# Non Blocking Send & Recv
request = None
status = None
# create a buffer for Isend & Irecv
buf = numpy.zeros(1)
if rank == 0:
buf[0] = MPI.Wtime()
req = comm.Isend(buf, dest=1)
req.Wait()
if rank == 1:
req = comm.Irecv(buf, source=0)
req.Wait()
after_timestamp = MPI.Wtime()
elapsed = after_timestamp - buf[0]
print(f"It took {elapsed} for a non-blocking message to be sent")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment