CSCI 338
Parallel Processing
Home | Lectures | Programming Assignments | Links | CS@Williams
Program 4: Rewriting Graph Algs with MPI
Assigned | Monday, March 10, 2025 |
---|---|
Final Due Dates |
|
Overview
In this assignment, you will revise the 3 (or 4) graph algorithms assigned to your group to use MPI. You will be building off of the design documents you created for program 3.
How the Honor Code Applies to This Assignment
This is a group-eligible assignment. Meaning, you should work with your class-approved team of students to produce your assigments, evaluation, and final reports. You are also encouraged to to ask non-team members questions of clarification, language syntax, and error message interpretation, but are not permitted to view/share each others code or written design notes for part1. Please see the syllabus for more details.
Rewriting Your Graph Algorithms
For this assignment, you will rewrite your graph
algorithms to use MPI. To do this, you'll want to look for
places where OpenMP pragmas are used to parallelize the code
currently. You'll need to transform these structured blocks of
code in several ways.
This shift of programming environment will take some careful planning. Remember that MPI is SPMD, so each process will be running the exact same executable, so differentiation of work will be based on rank within the MPI communicator. You also want to think about how to efficiently perform any communication that needs to happen.
Some of your algorithms may be using parallel versions of library code written using OpenMP. If this is the case, you'll need to either use a serial version of that library code or implement a version using MPI. Please reach out to me for help with this issue.
Enabling MPI and Disabling OpenMP
To get started, you will want to remove
the -fopenmp
flag in the compilation line in
CMakeLists.txt at the top level and rebuild your code. Once you
do this, compiler errors should help you figure out what changes
need to be made.
To help you with this process, I have copied a version of
the GMS code into ~kshaw/Public/CS338/gms-removed-openmp/
.
In this code base, I have gone and updated cmake
files
to use MPI and not use OpenMP. I also needed to explicitly modify
some files that directly called some OpenMP functions; these files
were mostly located in the gms/algorithms/preprocessing/parallel/
and gms/representations/graphs/log_graphs/
directories.
My suggestion to you is NOT to copy this directory, but for you to look for differences between your code base and this code base when compiling your files. I specifically suggest this because some of the commented out code was written in a parallel manner and is now only using a single thread; you may want to rewrite these pieces of code to execute in parallel using MPI calls. You should be able to use the files' timestamp modification times to locate which files I modified.
One specific example of where I added in
MPI calls is in the examples/triangle_counting.cpp
file, in addition to
modifying its CMakeLists.txt
file in that directory. Another example can be found in the algorithms/non_set_based/coloring/coloring.cc
file. If you'd like to see a basic cmake
project that uses MPI, check out ~kshaw/Public/cs338/cmake-mpi-test
.
Please reach out to me with questions as you work on getting your code to compile with MPI.
Evaluating Your Graph Algorithms
You are not expected to come up with the abolutely most efficient MPI version of your algorithms. However, you are expected to make smart design decisions. For example, your code should not send unnecessary data to processes and should try to use MPI's collective communication functions to perform efficient communication.
For evaluation of the performance of your code, please collect timing information for your code when it is run with 1 to 8 MPI processes. If you find that more processes result in diminished performance, investigate the cause of this reduced performance and try to fix the bottleneck if possible.
You also want to evaluate the original OpenMP version of the code using 1 to 8 processors for comparison.
Evaluation
This assignment will be evaluated based on the design of your coding approach as well as your presentation of your design choices and performance results. When presenting your approach, you will want to explain why you made the choices regarding computational grouping and communication. You'll also want to explain any performance losses you observe both across platforms and when your number of MPI processes increases. As a reminder, you are not expected to have the most efficient MPI versions of these code; I just want to see that you were thoughtful in your approach.
Submitting Your Work
Please submit your code and your presentation slides as PDF via gitlab.