High Performance Computing

Project 3 (Timing MPI Communication Using Ping-pongs)

TASK: Write a parallel program using MPI that measures the time taken to perform a “ping-pong”.

Instructions for ‘pingpong.c’

A ping-pong is a communication in which two messages are sent, first from process A to process B (a ping) and then from process B back to process A (the pong). Timing blocks of repeated ping-pongs is a common way to estimate the cost of sending messages in MPI.

Here’s what you need to do:

  1. On the LittleFe machine, log in and create a new file called pingpong.c.

  2. Implement a ping-pong message program using MPI. Time your ping-pong program using the C clock() function, and also with MPI_Wtime().

  3. Some things to try testing: How long does the code have to run before you get a nonzero run-time? How do the times you got with the clock() function compare to times taken with MPI_Wtime()? Write these answers as comments at the bottom of your code.

  4. Your program should take two optional parameter when running it:

    1. The flag -t followed by how many messages to send (if not given, it should default to 10)
    2. The flag -a followed by how many numbers in an array to send (if you leave off this flag, your program will just send a single number instead of an array of numbers)
  5. The following would all be possible ways to run your program, so you’ll want to make sure each of these works:

    ./message
    ./message -t 1000
    ./message -t 20 -a 1000
    ./message -a 10000 -t 400
  6. Output your result in a format similar to the following (note that the times here are made up):

    Ping Pong Program
    
    Running... finished!
    
    RESULTS
        Sent 400 messages, each with 10000 numbers
        clock: 4.3 seconds
        MPI_Wtime: 4.4 seconds

Documentation

You should also document/comment your code. At the top of your source code file, give a description of the program, the author of the code, and the date the code was written. Also place comments throughout your program (you can decide when you have enough comments, but they should adequately describe your code).

Submit

Save your program as pingpong.c and submit it to Moodle by the due date at 11:59PM.