Installation via apt:
sudo apt update sudo apt install build-essential sudo apt install mpich sudo apt install libmpich-dev
Here are the steps:
Step 1 – Update the repository
sudo apt update
Step 2 – Install build essentials
To install build essentials read this post.
Step 3 – Install mpich
sudo apt install mpich
Step 4 – Install MPI development libraries
sudo apt install libmpich-dev
Step 5 – Install your desired IDE (optional)
The recommended IDE for C/C++ is Netbeans.
On how to install Netbeans read this article.
Step 6 – Create an MPI project
Create a new C/C++ project in Netbeans. Then perform the following steps:
- Set Warning level to More warnings
- Set compile tool to mpicc
- Configure: mpiexec -n 4 “${OUTPUT_PATH}” as the default run command (set n as appropriate)
- Compile and test an mpi hello world project like the one shown below:
#include <mpi.h> #include <stdio.h> int main(int argc, char* argv[]) { int rank, size; MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &size); printf("Hello world from process %d of %d\n", rank, size); MPI_Finalize(); return 0; }