Compilers

The programming language environment provided on the Research Computing clusters allows one to build codes written in C, C++ and Fortran. 

Selecting a Language

In general, we recommend the current version of the Intel compilers for new C, C++ and Fortran HPC programs. If you are using software created by someone else, using the same compiler that was used in that software's development may make your work easier. Most compilers become available after loading the appropriate environment module.

GNU Compiler Collection

All of our Linux clusters provide gcc on the head nodes. The system gcc is matched to the version of the operating system and is not alterable. However, newer versions of gcc are available by loading the rh/devtoolset module (e.g., module load rh/devtoolset/9). Additionally, every head node also has a matching version of g++, the GNU C++ compiler and gfortran, the GNU Fortran compiler.

The line below illustrates how to find the version of g++ and how to build a code:

$ g++ --version
$ g++ -o myexe mycode.cpp
$ ./myexe
Intel oneAPI and Classic Compilers

All of our Linux clusters provide Intel C, C++ and Fortran compilers. This group of compilers is produced by the manufacturer of most of the processors used in our clusters and generally generates very good code. Use the module command (module avail intel) to see the available modules that can be loaded to use the Intel oneAPI compilers (icx, icpx, ifx) or the classic Intel compilers (icc, icpc, ifort).

Below is an example of loading a oneAPI module and building a C++ code:

$ module load intel/2022.2
$ icpx -o myexe mycode.cpp
$ ./myexe
NVIDIA Compilers

All of our Linux clusters provide the NVIDIA C, C++ and Fortran compilers. These compilers are often the best choice when compiling a GPU code. These compilers should be used when compiling an OpenACC code. Use the command "module load nvhpc" to see the available environment modules.

The commands below illustrates how to load a module and build a C++ code:

$ module load nvhpc/22.5
$ nvc++ -o myexe mycode.cpp
$ ./myexe