Home CPSC 425

Lab 7: Collective Communication



To implement collective communication and to evaluate its performance relative to point to point communication.


For this lab, you will take a program that uses point to point communication, to send one million data values from process 0 to all other processes. You will time how long it takes to execute.

You will then estimate how much more quickly it may execute using a broadcast operation instead.

Then you will replace the point to point communications with a broadcast, and finally, time your program to see how much performance improved.



  1. Download the program testp2p.c which simply has process 0 send one million point to point messages to each of the other processes.
  2. Compile and run this program with 16 processes. Time how long it takes to execute with the 'time' command (using the "real" portion). Do three samples and average them, and record this value.
  3. Think about how this program sends data from process 0 to the other 15. For each data element sent, how many sequential communication steps are required? Record your answer to this question.
  4. If the program were to use a broadcast instead of point to point communication, how many sequential communication steps would be required? Record your answer to this question.
  5. Given your answers to the above three questions, how much time do you expect the broadcast version of the program to take? Record your answer to this question.
  6. Replace the point to point communication in the program above with calls to MPI_Bcast.
  7. Run your program on 16 processes again (averaging three runs like last time). Did it take roughly the same amount of time as you expected, less time, or more time?



For this lab, you should submit two things on Canvas: the version of the program which uses broadcast communications, and your answers to the above questions. You can answer the questions in a comment on the assignment or in a separate document.

Copyright © 2024 Ian Finlayson | Licensed under a Attribution-NonCommercial 4.0 International License.