Created
February 13, 2019 20:41
-
-
Save Weffe/316a0dc5faa1454cde8f89ef9d83e802 to your computer and use it in GitHub Desktop.
Calculate execution time for non-blocking communication in mpi4py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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