Compiling software
This page describes how to compile custom code for the HPC or other RCC systems using compilers on our login and compute nodes.
Although the RCC provides a large number of built-in, precompiled software packages on our systems, many users will need to compile custom code into an executable program before submitting it to the Slurm scheduler. For this, we provide compiler libraries on our systems.
The three most commonly used compilers on our systems include:
Note
For a comprehensive list of compilers that the RCC supports, refer to our software catalog
Each compiler includes executables to compile C, C++, and Fortran sourcecode. These are the three most commonly used languages for HPC computing. We also support Java, Python (which can be compiled to C using cython), and other languages.
In addition, we provide commonly used libraries for each of the compilers, including OpenMPI, NetCDF, and others.
Compilation Overview#
The general workflow for compiling an application on our systems is as follows:
- Copy source files into your home directory on our system.
- Import compiler paths using environment modules
- Load linked libraries
- Compile code using Intel, GNU, or NVHPC compiler
- Run application or submit job
Tutorial: trap.c#
Below is a tutorial for compiling a C program on the HPC login node using the Intel compiler with the MPI libraries for a simple program, trap.c. This script is a convenient example of how parallel execution on the HPC works.
The trap.c script is a classical trapezoid integration that uses MPI. The script calculates the integral of a function using a composite trapezium rule, and each node calculates it subpart for the entire domain. You do not need to understand the mechanics of what the script does in order to follow this tutorial.
Login to the HPC and copy the example trap.c and trap.sh files into your home directory:
trap.c
is the source code file for the trapezoid integration program, and trap.sh
is a shell script that submits the program to the HPC job scheduler.
First, import the GNU compiler module into your environment using environment modules. This will enable access to the GNU compiler executable commands:
After running this command, try running gcc --version
. You should see something similar to the following:
Warning
If you see a Command not found
error, ensure that you have run the module load gnu
command first.
Next, load the MPI libraries:
With both the compiler module and the parallelization libraries loaded, you can now compile your trap.c code into an executable:
This command will show no output when run, but if your run ls
after it completes, you will see a new executable file
appear: trap
.
This file is ready to be executed in an MPI environment, specifically the HPC.
To submit your compiled program, you can use the sbatch
command on .sh
files. In our example:
After submitting the job, you can expect an email upon the start and end of the job. Results will be in the slurm-<jobid>.out
file. Furthermore, you can check the status of your job using the squeue
command:
For more information on running compiled programs on the HPC, see our tutorial for submitting HPC jobs.
Compiler Reference#
This page provides an example using the GNU compiler. For a more comprehensive overview of all the compiler commands and options available, refer to our software documentation