HomeMPI Programming MPI 1.1 Index Using MPI on the AC <- Prev -- Index -- Next ->

Exercise 2: Ping pong

  1. Write a simple program to use MPI_Send() and MPI_Recv() to pass data between two processes.

  2. 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.

  3. Modify your program to repeatedly pass a message back and forth. Such a program is generally called pingpong.

  4. 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().

  5. 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 ]

APAC NATIONAL FACILITY<- Prev -- Index -- Next ->