Building MPICH Programs

MPICH programs are those written to the MPI specification and linked with the Scyld ClusterWare MPICH libraries. This section discusses how to build (or compile) MPICH programs on Scyld ClusterWare using open source and commercial compilers.

MPICH mpicc, mpiCC, mpif77 and mpif90

Scyld ClusterWare provides the mpicc, mpiCC, mpif77 and mpif90 compile wrappers to build C, C++, Fortran 77 and Fortran 90 MPICH binaries. These wrappers are found in /usr/bin. For example, to compile the C program my_prog.c into an MPICH-compatible binary my_prog:

 [user@cluster ~]$ mpicc -o my_prog my_prog.c
By default, the Scyld ClusterWare compile wrappers use the GNU Compiler Collection (GCC) to build and link the code. You can see the parameters used to execute GCC tools by using the -show switch with mpicc, mpiCC, mpif77 and mpif90:
 [user@cluster ~]$ mpicc -show
 gcc -L/usr/lib64/MPICH/p4/gnu -I/usr/include -lmpi -lbproc

 [user@cluster ~]$ mpif77 -show
 f77 -L/usr/lib64/MPICH/p4/gnu -I/usr/include -lmpi -lmpichfarg -lbproc -lmpe

Using non-GNU compilers to build MPICH programs

You can change the compiler used to build and link MPICH programs by using the -cc switch with mpicc. Use -cxx for mpiCC, -f77 for mpif77, and -fc for mpif90. For example, to compile a program my_prog.c with the Intel icc compiler, use:

 [user@cluster examples]$ mpicc -cc=icc -o my_prog my_prog.c
Scyld ClusterWare supports the Intel, PathScale and PGI compilers. Again, you can use -show to see how the Scyld ClusterWare compile wrappers will build and link your program:
 [user@cluster examples]$ mpicc -cc=icc -o my_prog my_prog.c -show
 icc -L/usr/lib64/MPICH/p4/intel -I/usr/include -o my_prog my_prog.c \
     -lmpi -lbproc
Notice that the Intel-compatible MPICH libraries from /usr/lib64/MPICH/p4/intel are linked in. Corresponding libraries exist in /usr/lib64/MPICH for PathScale and PGI compilers.