Generic MPI

Generic MPI is a small set of routines and C include file that allows you to create a single library that can work with multiple MPI implementations. While there are a few restrictions (described in Building Library Components That Can Use Any MPI Implementation), libraries built using Generic MPI instead of a particular MPI implementation can eliminate the need to build multiple versions of a parallel library.

For example, using generic MPI, you can build a single application library that uses MPI:

    # Independent of MPI implementation (generic mpi.h in /usr/local/gmpi)
    cc -c myprog.c -I/usr/local/gmpi
    cc -c dot.c -I/usr/local/gmpi
    ar cr libmylib.a mylib.o
    ranlib libmylib.a
Here, the library libmylib.a is created from dot.c. The program myprog.c calls this routine.

Then users may link to your library using their favorite MPI:

    # For MPICH
    cc -o myprog myprog.o -lmylib -lgmpitompich -L/usr/local/mpich/lib -lmpich
    # For LAM/MPI
    cc -o myprog myprog.o -lmylib -lgmpitolam -L/usr/local/lam/lib -lmpi
This example has used cc instead of mpicc to show that there is no other dependence on other tools. Normally, users will use the compilation scripts appropriate for their MPI, either by using a software tool that selects a particular implementation, or an explicit choice of path, as in
/usr/local/mpich/bin/mpicc -o myprog myprog.o -lmylib -lgmpitompich
/usr/local/lammpi/bin/mpicc -o myprog myprog.o -lmylib -lgmpitolam

The example above shows how many MPI programs can be built for any MPI implementaiton without any source code changes. Some codes will require a few changes; an example is programs that make use of MPI_Status. Generic MPI provides a solution for these codes as well; an example is shown in gstatus.c.


GMPI is freely available in source form: (to be available soon). Questions and bug reports may be sent to gropp@mcs.anl.gov.
MCS Division Argonne National Laboratory University of Chicago