Matrix operations implemented with MPI in C. The programs apply an iterative stencil update over 2D or 3D matrices, splitting rows across MPI ranks and exchanging boundary values each time step.
Each program prompts for:
rows(I): number of matrix rows.cols(J): number of matrix columns.depth(W): number of layers (3D programs only).steps(T): number of time steps for the stencil update loop.
The number of MPI processes (size) must evenly divide the row count:
rows % size == 0.
make
make run-bi NP=2Common commands:
# Build one program
make mpi_mtrx_tri
# Run with a custom process count
make run-tri NP=4
# Use mpiexec instead of mpirun
make run-bi MPI_RUN=mpiexec NP=4
# Remove build artifacts
make cleanAll binaries are created under bin/.
In the run examples above, NP=2 or NP=4 controls the number of MPI
processes (ranks 0 through size-1).
Example inputs for -n 2:
- rows: 4
- cols: 4
- steps: 1
- The update is an in-place stencil (Gauss-Seidel style), using boundary exchanges between neighboring ranks each step.
- See the Docs section for the stencil formula details and MPI rationale.
- MPI terms:
rankis the ID of a process inMPI_COMM_WORLD(0 tosize-1), andsizeis the total number of MPI processes launched. For example,make run-bi NP=4starts four ranks, numbered 0, 1, 2, and 3. Rank 0 reads input and distributes it; the other ranks receive parameters and update their own row blocks.
@docs/MPI_RATIONALE.md: why MPI is used in this repository.@docs/STENCIL_GUIDE.md: stencil formula details and Gauss-Seidel rationale.@docs/mpi_mtrx_bi.md: documentation formpi_mtrx_bi.c.@docs/mpi_mtrx_bi_v3.md: documentation formpi_mtrx_bi_v3.c.@docs/mpi_mtrx_tri.md: documentation formpi_mtrx_tri.c.@docs/mpi_mtrx_tri_embedded.md: documentation formpi_mtrx_tri_embedded.c.