MPI-3 small new function: MPI_GET_LIBRARY_VERSION

February 25, 2012 - 0 Comments

There’s been some discussion of Big New Features in MPI-3 recently (and more are coming!).  But today, I want to talk about a little new feature.  Something small, but still useful.

I’m talking about a new function named MPI_GET_LIBRARY_VERSION.

Its only purpose in life is to shed some light on to the implementation that you’re using.  It returns a simple string, and is intended to be human-readable (vs. being machine-parseable). The format of the string is not mandated, but it is assumed that MPI implementations will include reasonably detailed information about their specific version.

This information is useful in multiple ways:

  • Using the MPI that you think you’re using: are you sure that your run-time environment is picking up the right
  • Debugging information: seeing exactly what revision of your MPI implementation you’re using
  • Submitting trouble reports: include exact library build information

Note that MPI_GET_LIBRARY_VERSION is a little different than running a standalone debugging/diagnostic tool from an MPI implementation (e.g., Open MPI provides the


command). MPI_GET_LIBRARY_VERSION shows the MPI implementation that you’re using at run time; it shows exactly what is set in your MPI job’s environment (which may — accidentally — be different than your diagnostic commands’ environments).

For example, Open MPI’s implementation of MPI_GET_LIBRARY_VERSION returns a string that looks like this:

Open MPI v1.7a1, package: Open MPI Distribution, ident: 1.7a1r26051M, repo rev: r26051M, Unreleased developer copy

This string clearly indicates that this is an unreleased developer build, and gives all kinds of specific information about this particular build of Open MPI.

Indeed, you might want to put a call to MPI_GET_LIBRARY_VERSION at the beginning of all your MPI applications, just for diagnostic / verification purposes.  Perhaps something like this (with apologies for horrid blog code formatting):

int main(int argc, char* argv) {
    int len;
    char mpi_lib_ver[MPI_MAX_LIBRARY_VERSION_STRING];

    MPI_Init(NULL, NULL);
    MPI_Get_library_version(mpi_lib_ver, &len);
    printf("MPI library version: %s\n", mpi_lib_ver);
    /* of your application... */

You never know when you’ll need to know that information. So just include it in all your applications, and it may save you many hours of frustration someday when that printf alerts you to the fact that your LD_LIBRARY_PATH is set incorrectly, and you’re inadvertently using a different MPI library than you intended.


In an effort to keep conversations fresh, Cisco Blogs closes comments after 60 days. Please visit the Cisco Blogs hub page for the latest content.