Compiling your Code

Print

 

* Compute Canada documentation: https://docs.computecanada.ca/wiki/Installing_software_in_your_home_directory

The following compiler suites are installed on Guillimin, and are currently supported by us and corresponding vendors:

  • Intel Compiler Suite
  • Portland Group Compiler Suite
  • GNU Compilers

Compiling a serial code

We recommend to start with Intel compilers, unless another compiler family is required by your code due to specific reasons. Intel compiler suite includes ifort (Fortran-90), icc (C), and icpc (C++) compilers. The whole family of Intel compilers can be "loaded" to your environment using the following command:

user@guillimin$ module add ifort_icc

Then you compile your Fortran code with the following command (For C and C++ compilers use icc and icpc compiler names respectively):

user@guillimin$ ifort -O3 yourcode.F -o <your_binary_name>

The optimization of the third level (-O3) is quite aggressive and for some programs it may lead to significant slowing down (or even hanging) of compilation process, as well as reducing of performance of the binary code. If this is the case for your program, a lower-level optimization (-O2) should be used. We advise you to start with -O3, and then go to -O2 in case you find problems.

If you are compiling and linking several program files into one binary (which is usually the case when using Makefile), the "-ipo" optimization option is also advised. It performs inter-procedural optimizations between parts of your code, saved in different files.

Compiling a parallel code

For the codes, parallelized with OpenMP, the compilation procedure is the same as for the serial codes, except for the additional "-openmp"  option should be added to compiler flags.

For compilation of MPI-parallelized program you need to load an MPI module, corresponding to the compiler that you use. The compiler module itself should also be loaded. We currently support MVAPICH and OpenMPI packages, built with all 3 supported compiler suits. You can see all these packages among available software modules by issuing "module avail" command.

Let's assume, for example, that you would like to build your MPI program using Intel compiler and MVAPICH package. First, you load software modules for compiler suite and MPI package:

user@guillimin$ module add ifort_icc mvapich2-intel

Any MPI module provides you with wrappers (mpif90, mpicc, mpicxx), which automatically link your code with all necessary MPI librararies. You compile your MPI code with the following command:

user@guillimin$ mpif90 -O3 yourcode.F -o <your_binary_name>

IMPORTANT:

  • Please, ALWAYS make sure that you loaded MPI package, compiled with the SAME compiler as you are using to compile your application !

  • If you are always using a particular compiler (and a particular MPI package), it is a good idea to add corresponding "module add" command to your ".bashrc" file. In this way these modules will be automatically loaded every time you login to Guillimin.

  • PLease, do not compile your own MPI packages from the source codes, and ALWAYS use our MPI modules to compile your MPI code. Each node of Guillimin cluster is equipped with high-speed InfiniBand network interface card. Our MPI modules were especially compiled on top of InfiniBand libraries, and guarantie that network traffic, generated by the parallel run of your code, will always go through this high-speed interface. 

  • Please, be advised that both MVAPICH and MVAPICH2 packages are installed on Guillimin. You should load one or another depending on what MPI interface is programmed in your code. These two standards (MPI-1 and MPI-2) are different both in programming and, in some cases, also in the procedure of launching your application