37

I'm compiling my code on a server that has OpenMPI, but I need to know which version I'm on so I can read the proper documentation. Is there a constant in <mpi.h> that I can print to display my current version?

Zak
  • 12,213
  • 21
  • 59
  • 105

4 Answers4

45

As explained in this tutorial, you may also check the MPI version running the command:

mpiexec --version

or

mpirun --version

in your terminal.

Foad S. Farimani
  • 12,396
  • 15
  • 78
  • 193
26

With OpenMPI, the easiest thing to do is to run ompi_info; the first few lines will give you the information you want. In your own code, if you don't mind something OpenMPI specific, you can look at use OMPI_MAJOR_VERSION, OMPI_MINOR_VERSION, and OMPI_RELEASE_VERSION in mpi.h. That obviously won't work with MPICH2 or other MPI implementations.

More standardly, as part of MPI-3, there is a standard MPI routine called MPI_Get_library_version which gives you detailed library information at run time. This is small enough and useful enough that newer versions of MPI implementations will have this very quickly - for instance it's in the OpenMPI 1.7 development trunk - but it doesn't really help you today.

Demi-Lune
  • 1,868
  • 2
  • 15
  • 26
Jonathan Dursi
  • 50,107
  • 9
  • 127
  • 158
  • 1
    This is exactly what I was looking for. MPI_Get_version(*int, *int) lets you know which version of the MPI standard OpenMPI adheres to, not the actual release version of OpenMPI. – Zak Apr 07 '12 at 18:59
3

I am not familier with OpenMPI but MPI has a function MPI_Get_Version, please check your mpi.h for similar functions.

Semih Ozmen
  • 571
  • 5
  • 20
  • That's a start, but only gives the version of the standard to which the MPI library conforms; eg, most MPI implementations today will return 2 and 1 (or 0) for major/minor versions, but it doesn't let you distinguish between (say) OpenMPI 1.4.4 and OpenMPI 1.5.3. The former is certainly important when you're writing code, but the latter sort of information can be pretty important if you're trying to solve an implementation or configuration issue. – Jonathan Dursi Apr 07 '12 at 18:05
  • Thank you for this comment, the information returned by MPI_Get_version(*int, *int) coupled with the MPI website http://www.mpi-forum.org/docs/ is the key to tons of information! – Zak Apr 07 '12 at 19:01
1

You can also get the version of OpenMPI that the compiler wrapper (e.g. mpicxx/mpic++/mpicc/mpifort) comes from:

mpicxx --showme:version

This can be useful if (for any reason) you have different versions of MPI compiler wrapper and executor.

(Just mpicxx --showme will additionally show you where MPI is installed and which compiler flags uses, see the manual for more.)

MakisH
  • 967
  • 1
  • 9
  • 23