Exercise 2: Ping pong
- Write a simple program to use
MPI_Send() and MPI_Recv() to pass
data between two processes.
- Try using
MPI_SSend() with messages going in both directions
simultaneously .
Proc 0: Proc 1:
MPI_Ssend() MPI_Ssend()
MPI_Recv() MPI_Recv()
Now try it with MPI_Send() - by increasing the message size you should
be able to determine the system buffer size.
- Modify your program to repeatedly pass a message back and forth.
Such a program is generally called pingpong.
- Use
MPI_Wtime() to time the data transfers for different size messages.
The timer probably does not have great resolution so for short messages
you will need to time multiple transfers. Try comparing the times for
MPI_Send(), MPI_Bsend() and
MPI_Ssend().
- Try using
MPI_Bsend(). Try just replacing MPI_Send() by
MPI_Bsend() -- does it work? Now use MPI_Buffer_attach(buffer, size)
to provide buffer space.
[Solution in pingpong.f/f90/c ]
|