A comprehensive collection of Message Passing Interface (MPI) programming examples for teaching parallel computing concepts. This repository is designed for students learning MPI programming in Windows environments with Microsoft MPI and Visual Studio.
Each tutorial is a self-contained project with full CMake support, detailed documentation, and batch files for easy building and execution:
- 01-mpi-basics - Introduction to MPI, environment setup, and simple communication
- 02-point-to-point - Point-to-point communication patterns
- 03-collective-communication - Collective communication operations
- 04-derived-datatypes - Creating and using derived datatypes
- 05-virtual-topologies - Cartesian and graph topologies
- 06-one-sided - One-sided communication (Remote Memory Access)
- 07-hybrid-parallelism - Hybrid MPI+OpenMP programming
- 08-non-blocking - Non-blocking communications
- 09-performance-optimization - Performance tuning and optimization
- 10-mpi-io - Parallel I/O with MPI
- 11-fault-tolerance - Fault tolerance and error handling
- 12-process-manager - Process management and dynamic processes
- 13-custom-communicators - Creating and managing custom communicators
- 14-advanced-patterns - Advanced communication patterns and algorithms
- 15-debugging - Debugging MPI applications
- Windows 10/11
- Visual Studio 2022 Community Edition
- Microsoft MPI (MS-MPI)
- CMake 3.20 or higher
- C++17 compatible compiler
-
Install Visual Studio 2022 Community Edition
- During installation, select "Desktop development with C++"
- Ensure MSBuild tools are installed
-
Install Microsoft MPI (MS-MPI)
- Download both the runtime and SDK from Microsoft MPI
- Install both packages
- Add the MPI installation directory to your system PATH (typically
C:\Program Files (x86)\Microsoft SDKs\MPI\Bin) - Verify the installation with
mpiexec -helpin a command prompt
-
Install CMake
- Download from CMake
- Add CMake to the system PATH during installation
Each project follows the same pattern for building and execution:
- Navigate to the project directory
cd 01-mpi-basics
- Configure the project
configure.bat
- Build the project
build_all.bat
- Run the example
run.bat
Most examples support additional command-line parameters:
run.bat --np 4 # Run with 4 processes
run.bat --debug # Run in debug mode with additional information
run.bat --verbose # Show detailed output
run.bat --help # Show all available options
For the best learning experience, follow the tutorials in numerical order:
- Start with 01-mpi-basics to understand MPI fundamentals
- Move through point-to-point and collective communication (02 through 03)
- Learn advanced data handling with derived datatypes and virtual topologies (04 and 05)
- Explore advanced communication models like one-sided and non-blocking (06 and 08)
- Study performance optimization and parallel I/O (09 and 10)
- Master advanced topics like fault tolerance, process management, and custom communicators (11 through 13)
- Finally, learn about advanced patterns and debugging techniques (14 and 15)
Each directory contains its own detailed README.md with:
- Concepts explanation
- Code walkthrough
- Build and run instructions
- Expected output and interpretation
- Exercises and further exploration ideas
- Make sure both the runtime and SDK are installed
- Verify the PATH environment variable includes the MPI bin directory
- Check installation by running
mpiexec -helpin a command prompt
- Check if CMake can find MPI with
cmake .. -G "Visual Studio 17 2022" -A x64 - Ensure Microsoft MPI SDK is properly installed
- Check Visual Studio has the necessary C++ components installed
- Make sure
mpiexecis available in your PATH - Check that processes can be launched with
mpiexec -n 2 hostname - Try running examples with fewer processes if you encounter resource limitations
- MPI Forum - Official MPI specification
- Microsoft MPI Documentation
- MPI Tutorial - Excellent resource for learning MPI
- Using MPI - Classic book on MPI programming
- Designing and Building Parallel Programs - Free online book
Contributions to improve the tutorials are welcome! Please feel free to submit pull requests or open issues to suggest improvements.
This project is licensed under the MIT License - see the LICENSE file for details.
- MPI Forum for the MPI specification
- Microsoft for MS-MPI implementation
- The parallel computing community for sharing knowledge and best practices
- All contributors who help improve these teaching materials
Happy MPI Programming!