A08 - AutoPI MPI
Assignment: GitHub Classroom
Late Policy
- You have until the assigned due date, after that you will receive 0 points.
Automating π Calculation with MPI (25 points)
Overview
In this assignment, you will extend your previous Monte Carlo implementation of π to create a new program, autopiMPI.cc
. This new program will automatically calculate π to various levels of precision using MPI for distributed processing. The program will also measure the computational effort—the number of iterations and the execution time required for each precision level—and output this data into a CSV file.
Objectives and Expected Learning Outcomes
The primary objectives of this assignment are:
Automate the Monte Carlo Method
Extend your code to calculate π to different significant digits automatically using MPI for distributed computing.
Distributed Performance Measurement
Measure and record the number of iterations and the computation time required to reach each precision level (at least five levels should be included, large enough to highlight the benefits of distributed computation). For timing, use MPI_Wtime()
:
// Record the start time using MPI's wall-clock timer
double startTime = MPI_Wtime();
// Example distributed work: calculate π using the Monte Carlo method in parallel
// (The actual Monte Carlo implementation should be modified to work with MPI)
// Record the end time
double endTime = MPI_Wtime();
Note: Use MPI_Wtime()
since it seamlessly integrates with MPI and provides accurate wall-clock timings for distributed applications.
Data Visualization
Generate a plot from the CSV file that illustrates the relationship between significant digits and computational effort. The plot should display:
- Iterations vs. Significant Digits
- Time vs. Significant Digits
Build System Proficiency
Create a Makefile
to compile your C++ code efficiently into an executable named autopiMPI
. The Makefile
should include targets for make all
and make clean
.
Expected Outcomes:
-
Enhanced C++ Programming Skills:
- Modify and extend existing C++ code to automate precision testing, data logging, and MPI-based parallel computation.
-
Effective Distributed Processing:
- Utilize MPI to distribute the Monte Carlo simulation, making your computations more efficient on multi-node systems.
-
Accurate Performance Measurement:
- Use
MPI_Wtime()
to accurately measure and record the execution time across multiple MPI processes.
- Use
-
Data Visualization:
- Create clear, well-labeled plots from your CSV output to visually demonstrate the scaling of computational effort with precision.
-
Makefile Development:
- Construct a
Makefile
that manages the build process efficiently and cleans up build artifacts as needed.
- Construct a
Instructions
Part 1: Extending the C++ Program
-
Create a File:
Copy your previous π calculation code to a new file namedautopiMPI.cc
. -
Implement the Following Features:
-
Automate Precision Calculation:
Calculate π from 1 to 6 significant digits. -
Distribute Computations with MPI:
Modify your Monte Carlo method to distribute the work across MPI processes. -
Performance Measurement:
- Track the number of iterations required for each precision.
- Record computation time using
MPI_Wtime()
.
-
CSV Output:
Your program should output results to a CSV file namedautopiMPI.csv
with the following format:Precision, Iterations, Time, Pi, Processes, Experiment 1, <iterations>, <time>, <pi value>, <number of processes>, <experiment identifier> 2, <iterations>, <time>, <pi value>, <number of processes>, <experiment identifier> ... 8, <iterations>, <time>, <pi value>, <number of processes>, <experiment identifier>
-
-
Error Handling and Documentation:
- Ensure proper error handling for file and MPI operations.
- Include in-code comments to explain your design decisions and logic.
Part 2: Makefile
-
Create a
Makefile
:- The
Makefile
should compileautopiMPI.cc
into an executable namedautopiMPI
. - Include targets for
make all
(build) andmake clean
(remove build artifacts).
- The
-
Validate the Build:
Test yourMakefile
on UIC or ALCF systems (e.g.,lakeshore.acer.uic.edu
orcrux.alcf.anl.gov
).
Part 3: Data Analysis and Visualization
-
Generate Plot
- Read the CSV file (
autopiMPI.csv
). - Generate and save plots that illustrate: - The relationship between significant digits and iterations. - The relationship between significant digits and computation time. - Optional: Create a dual-axis plot to combine iterations and time into one visualization.
- Read the CSV file (
-
Best Practices for Plotting:
- Use clear titles, axis labels, and legends.
- Format your plots for clarity and professional presentation.
-
Save the Plots:
Save your plots asautopiMPI_plot.png
(or separate files likeautopiMPI_iterations.png
andautopiMPI_time.png
).
Submission Guidelines and Evaluation Criteria
- Add/edit the following files in your GitHub repository:
-
autopiMPI.cc
– Your MPI-based C++ source code. -
Makefile
– To build the executable. -
autopiMPI.csv
– A sample CSV file with output for 1-8 significant digits (including data from multiple processes). -
autopiMPI_plot.png
(or equivalent plot files) – Visual representation of the experimental results. -
autopiMPIreflection.txt
– A brief reflection describing your approach, challenges faced, and lessons learned—especially comparing distributed MPI performance against shared-memory approaches like OpenMP.
-
- Follow the Assignment Submission Instructions when committing and pushing your repository.
- Your work will be evaluated based on adherence to the instructions, file naming, code quality, completeness, and the depth of your reflection.