Get MPI Version
01 Sep 2018 Hpc tips MPIMessage Passing Interface (MPI) is a standard for parallel computing, which means it could be the dependency of many programs developed for cluster. Determining the version of MPI is helpful to solve the dependency issues.
There are several implementations of MPI: Open MPI, MPICH, Intel MPI Library and so on. While they follow the same API specification to ease programmers work. Most of time, if a program does compile with MPI, it complain the wrong MPI API version.
For Open MPI, there is an executable called ompi_info
,
which can print out the detailed information of MPI library.
Example output likes the following:
Package: Open MPI bambo@BW-E431 Distribution
Open MPI: 3.1.2
Open MPI repo revision: v3.1.2
Open MPI release date: Aug 22, 2018
......
MCA topo: basic (MCA v2.1.0, API v2.2.0, Component v3.1.2)
MCA topo: treematch (MCA v2.1.0, API v2.2.0, Component v3.1.2)
MCA vprotocol: pessimist (MCA v2.1.0, API v2.0.0, Component v3.1.2)
However,
this approach is neither reliable (mistake may happen when multiple versions exist),
nor adaptable (other implementations do not have).
A better way to check the MPI version is write a simple program calling the API function found in mpi.h
to report the version.
For example:
#include <iostream>
#include <mpi.h>
int main() {
int res, maj, min;
res = MPI_Get_version(&maj, &min);
std::cout << res << std::endl; // 0
std::cout << maj << std::endl; // 3
std::cout << min << std::endl; // 1
return 0;
}
Compile the above program with mpicxx
or whatever MPI compiler you want to use.
Execute the program and know the version of MPI API.
Credits
- How do you check the version of OpenMPI? - Thank Jonathan Dursi and Semih Ozmen for your answers.