Parallel Power Iteration using MPI
Parallel power iteration with MPI, featuring custom C++ matrix and vector classes, and left stochastic matrix generation using a Bernoulli distribution with a configurable seed.
Links
Repository: git/mpi-eigen-value
Link to Documentation
Overview
This project implements a parallel dense matrix and vector format in C++ using MPI and the C++ Standard Template Library (STL). The implementation includes:
- Custom C++ matrix and vector classes, utilizing dynamically allocated arrays for efficient data handling.
- Link matrix generation using a Bernoulli distribution with a user-defined random seed.
- Parallel power iteration to approximate the largest eigenvalue and left stochastic matrix ( P ) derived from the generated link matrix ( L ).
Features
- C++ Matrix and Vector Classes:
- Custom implementations with dynamically allocated arrays.
- Efficient memory management and operator overloading.
- Link Matrix Generation:
- Constructed using a Bernoulli distribution (0/1 values).
- Accepts a user-defined random seed for reproducibility.
- Transformed into a left stochastic matrix ( P ) by normalizing row sums.
- Parallel Matrix-Vector Computation:
- Utilizes MPI for distributed Rayleigh method iterations.
- Supports scatter/gather for efficient communication.
- Power Iteration Algorithm:
- Iteratively approximates the dominant eigenvalue.
- Implements convergence checks for numerical stability.
Dependencies
- MPI Library (e.g., OpenMPI or MPICH)
- CMake
- C++ Standard Template Library (STL)
Installation
-
Install an MPI implementation and CMake:
-
Clone the repository:
-
Compile the program using CMake:
-
For just a sequential implementation (which does not depend on MPI):
-
For a parallel implementation (which depends on MPI):
-
For just a sequential implementation and to build tests:
-
Usage
Run the program with the desired matrix size:
where:
<num_processes>
is the number of MPI processes.<matrix_size>
defines the dimension ( N \times N ) of the link matrix.
Example
Implementation Details
Matrix and Vector Classes
- Matrix Class (
Matrix
):- Uses a dynamically allocated 2D array (or 1D row-major storage).
- Implements matrix operations (e.g., matrix-vector multiplication).
- Includes MPI distribution functions for parallel computation.
- Vector Class (
Vector
):- Uses a dynamically allocated array.
- Implements vector operations (e.g., dot product, normalization).
- Overloads operators for clean syntax.
Parallelization Strategy
- Row-wise distribution of the matrix among MPI processes.
- Uses MPI Scatter/Gather for communication efficiency.
Performance Considerations
- Minimized MPI communication overhead via optimized data distribution.
- Memory-efficient storage using dynamically allocated arrays.
- Scalability: Supports large matrices distributed across multiple processes.
References
- MPI Documentation: https://www.mpi-forum.org/
- Power Iteration Method: https://en.wikipedia.org/wiki/Power_iteration