Compute Canada

How do I compile MPI code on HPCVL?

Please note: The FAQ pages at the HPCVL website are continuously being revised. Some pages might pertain to an older configuration of the system. Please let us know if you encounter problems or inaccuracies, and we will correct the entries.

The compilation of MPI programs requires a few compiler options to direct the compiler to the location of header files and libraries. Since these switches are always the same, they have been collected in a macro to avoid unnecessary typing. The macro is has an mp or mpi prefix before the normal compiler name, for ClusterTools 6 or ClusterTools 7 and higher, repsectively. The commands are mpf90 or mpi90 for Fortran 90 compiler, and mpcc, mpicc, mpCC, and mpiCC for the C and C++ compilers, respectively. For instance, if a serial C program is compiled by

cc -xO3 -c test.c

the corresponding parallel (MPI) program is compiled by

mpcc -xO3 -c test_mpi.c [ClusterTools 6]
mpicc -xO3 -c test_mpi.c [ClusterTools 8.1]

In the linking stage, the specification of the MPI libraries is required for ClusterTools 6. This is done via the -lmpi option. For ClusterTools 7 and higher this inclusion is automatic. For example, the above MPI program should be linked with something like this:

mpcc -o test_mpi.exe test_mpi.o -lmpi [ClusterTools 6] 
mpicc -o test_mpi.exe test_mpi.o [ClusterTools 8.1]

Compiling and linking may also be combined.