A high-performance computing project that parallelizes numerical integration with C++ and MPI and evaluates strong-scaling behavior on the Bridges2 supercomputer using SLURM.
The program approximates π by numerically integrating
4 / (1 + x^2)
over [0, 1] with the midpoint rule. The workload is distributed across MPI ranks, local partial sums are computed independently, and the final result is combined with MPI_Reduce.
The numerical problem is intentionally simple so the experiment can focus on the systems question: how does distributed execution scale as additional MPI processes are introduced?
The project demonstrates both the benefit and the limit of parallelism. Runtime drops dramatically from 1 to 12 processes, but additional ranks provide almost no further improvement for the tested workload.
- C++
- MPI / OpenMPI
MPI_ReduceMPI_Wtime- SLURM
- Bridges2 Supercomputer
- Numerical integration
- Parallel performance analysis
All reported runs used 1 × 10^9 integration steps.
The integration domain was divided among the available MPI processes. Each process computed a local sum, after which the partial results were reduced to rank 0 with MPI_Reduce.
Timing was measured with MPI_Wtime around the parallel computation and reduction.
| MPI Processes | Runtime (s) | Approx. Speedup | Parallel Efficiency |
|---|---|---|---|
| 1 | 3.500 | 1.00× | 100.0% |
| 12 | 0.345 | 10.14× | 84.5% |
| 24 | 0.346 | 10.12× | 42.2% |
| 48 | 0.345 | 10.14× | 21.1% |
All configurations produced approximately:
π = 3.1415926535904264
The runtime values above come from the experimental report included in this repository. Speedup is computed relative to the 1-process runtime, and efficiency is speedup / process_count.
The most important result is the scaling plateau.
Moving from 1 to 12 MPI processes reduces runtime from approximately 3.50 s to 0.345 s, corresponding to about 10.14× speedup and 84.5% parallel efficiency.
Increasing the process count from 12 to 24 or 48 does not materially reduce runtime. As a result, parallel efficiency falls to roughly 42% at 24 processes and 21% at 48 processes.
This illustrates a fundamental HPC principle: adding compute resources does not guarantee proportional acceleration. Once the useful parallel work per process becomes sufficiently small, communication, synchronization, scheduling, and other overheads limit additional speedup.
High-Performance-Parallel-Pi-Approximation-Using-MPI-and-SLURM/
├── pi1.cpp
├── pi2.cpp
├── pi3.cpp
├── pi4.cpp
├── job-pi2-01.slurm
├── job-pi2-12.slurm
├── job-pi2-24.slurm
├── job-pi2-48.slurm
├── report.txt
└── README.md
The four C++ files represent stages/variants of the MPI implementation, while the SLURM scripts capture the execution configurations used for the scaling experiment.
The parallel implementation follows this general structure:
Initialize MPI
|
v
Determine rank and process count
|
v
Partition integration work
|
v
Compute local partial sum
|
v
MPI_Reduce(local sums -> rank 0)
|
v
Report π approximation and runtime
|
v
Finalize MPI
Compile an implementation with an MPI-aware compiler, for example:
mpic++ pi2.cpp -o pi2Example execution:
mpirun -np 12 ./pi2On Bridges2, the included SLURM scripts represent the batch configurations used for the reported experiments.
sbatch job-pi2-12.slurm
sbatch job-pi2-24.slurm
sbatch job-pi2-48.slurm- Distributed-memory parallel programming
- MPI collective communication
- C++ numerical computing
- Work partitioning
- Parallel timing and benchmarking
- Speedup and efficiency analysis
- Strong-scaling interpretation
- SLURM batch scheduling
- Supercomputing workflows
This project originated in HPC coursework and is presented as a focused distributed-computing experiment. The goal is not the π approximation itself; the value is the implementation and analysis of MPI parallelism on real HPC infrastructure.
The results apply to the tested numerical workload and Bridges2 execution configurations and should not be interpreted as universal MPI scaling behavior.
Jesús Gil
Computer Science · Applied Mathematics · Quantum Computing · Machine Learning · HPC