Skip to content

Compiling and testing your software on the HPC#

All nodes in the HPC cluster are running the "RHEL 8.8 (accelgor, doduo, donphan, gallade, joltik, skitty)" Operating system, which is a specific version of Red Hat Enterprise Linux. This means that all the software programs (executable) that the end-user wants to run on the HPC first must be compiled for RHEL 8.8 (accelgor, doduo, donphan, gallade, joltik, skitty). It also means that you first have to install all the required external software packages on the HPC.

Most commonly used compilers are already pre-installed on the HPC and can be used straight away. Also many popular external software packages, which are regularly used in the scientific community, are also pre-installed.

Check the pre-installed software on the HPC#

In order to check all the available modules and their version numbers, which are pre-installed on the HPC enter:

$ module av 2>&1 | more
--- /apps/gent/SL6/sandybridge/modules/all ---
ABAQUS/6.12.1-linux-x86_64
AMOS/3.1.0-ictce-4.0.10
ant/1.9.0-Java-1.7.0_40
ASE/3.6.0.2515-ictce-4.1.13-Python-2.7.3
ASE/3.6.0.2515-ictce-5.5.0-Python-2.7.6
...

Or when you want to check whether some specific software, some compiler or some application (e.g., MATLAB) is installed on the HPC.

$ module av 2>&1 | grep -i -e "matlab"
MATLAB/2010b
MATLAB/2012b
MATLAB/2013b

As you are not aware of the capitals letters in the module name, we looked for a case-insensitive name with the "-i" option.

When your required application is not available on the HPC please contact any HPC member. Be aware of potential "License Costs". "Open Source" software is often preferred.

Porting your code#

To port a software-program is to translate it from the operating system in which it was developed (e.g., Windows 7) to another operating system (e.g., Red Hat Enterprise Linux on our HPC) so that it can be used there. Porting implies some degree of effort, but not nearly as much as redeveloping the program in the new environment. It all depends on how "portable" you wrote your code.

In the simplest case the file or files may simply be copied from one machine to the other. However, in many cases the software is installed on a computer in a way, which depends upon its detailed hardware, software, and setup, with device drivers for particular devices, using installed operating system and supporting software components, and using different directories.

In some cases software, usually described as "portable software" is specifically designed to run on different computers with compatible operating systems and processors without any machine-dependent installation; it is sufficient to transfer specified directories and their contents. Hardware- and software-specific information is often stored in configuration files in specified locations (e.g., the registry on machines running MS Windows).

Software, which is not portable in this sense, will have to be transferred with modifications to support the environment on the destination machine.

Whilst programming, it would be wise to stick to certain standards (e.g., ISO/ANSI/POSIX). This will ease the porting of your code to other platforms.

Porting your code to the RHEL 8.8 (accelgor, doduo, donphan, gallade, joltik, skitty) platform is the responsibility of the end-user.

Compiling and building on the HPC#

Compiling refers to the process of translating code written in some programming language, e.g., Fortran, C, or C++, to machine code. Building is similar, but includes gluing together the machine code resulting from different source files into an executable (or library). The text below guides you through some basic problems typical for small software projects. For larger projects it is more appropriate to use makefiles or even an advanced build system like CMake.

All the HPC nodes run the same version of the Operating System, i.e. RHEL 8.8 (accelgor, doduo, donphan, gallade, joltik, skitty). So, it is sufficient to compile your program on any compute node. Once you have generated an executable with your compiler, this executable should be able to run on any other compute-node.

A typical process looks like:

  1. Copy your software to the login-node of the HPC

  2. Start an interactive session on a compute node;

  3. Compile it;

  4. Test it locally;

  5. Generate your job scripts;

  6. Test it on the HPC

  7. Run it (in parallel);

We assume you've copied your software to the HPC. The next step is to request your private compute node.

$ qsub -I
qsub: waiting for job 123456 to start

Compiling a sequential program in C#

Go to the examples for chapter Compiling and testing your software on the HPC and load the foss module:

$ cd ~/examples/Compiling-and-testing-your-software-on-the-HPC
$ module load foss

We now list the directory and explore the contents of the "hello.c" program:

$ ls -l
total 512
-rw-r--r-- 1 vsc40000 214 Sep 16 09:42 hello.c
-rw-r--r-- 1 vsc40000 130 Sep 16 11:39 hello.pbs*
-rw-r--r-- 1 vsc40000 359 Sep 16 13:55 mpihello.c
-rw-r--r-- 1 vsc40000 304 Sep 16 13:55 mpihello.pbs

hello.c

/*
 * VSC        : Flemish Supercomputing Centre
 * Tutorial   : Introduction to HPC
 * Description: Print 500 numbers, whilst waiting 1 second in between
 */
#include "stdio.h"
int main( int argc, char *argv[] )
{
  int i;
  for (i=0; i<500; i++)
  {
    printf("Hello #%d\n", i);
    fflush(stdout);
    sleep(1);
  }
}

The "hello.c" program is a simple source file, written in C. It'll print 500 times "Hello #<num>", and waits one second between 2 printouts.

We first need to compile this C-file into an executable with the gcc-compiler.

First, check the command line options for "gcc" (GNU C-Compiler), then we compile and list the contents of the directory again:

$ gcc -help
$ gcc -o hello hello.c
$ ls -l
total 512
-rwxrwxr-x 1 vsc40000 7116 Sep 16 11:43 hello*
-rw-r--r-- 1 vsc40000  214 Sep 16 09:42 hello.c
-rwxr-xr-x 1 vsc40000  130 Sep 16 11:39 hello.pbs*

A new file "hello" has been created. Note that this file has "execute" rights, i.e., it is an executable. More often than not, calling gcc -- or any other compiler for that matter -- will provide you with a list of errors and warnings referring to mistakes the programmer made, such as typos, syntax errors. You will have to correct them first in order to make the code compile. Warnings pinpoint less crucial issues that may relate to performance problems, using unsafe or obsolete language features, etc. It is good practice to remove all warnings from a compilation process, even if they seem unimportant so that a code change that produces a warning does not go unnoticed.

Let's test this program on the local compute node, which is at your disposal after the "qsub --I" command:

$ ./hello
Hello #0
Hello #1
Hello #2
Hello #3
Hello #4
...

It seems to work, now run it on the HPC

$ qsub hello.pbs

Compiling a parallel program in C/MPI#

$ cd ~/examples/Compiling-and-testing-your-software-on-the-HPC

List the directory and explore the contents of the "mpihello.c" program:

$ ls -l
total 512
total 512
-rw-r--r-- 1 vsc40000 214 Sep 16 09:42 hello.c
-rw-r--r-- 1 vsc40000 130 Sep 16 11:39 hello.pbs*
-rw-r--r-- 1 vsc40000 359 Sep 16 13:55 mpihello.c
-rw-r--r-- 1 vsc40000 304 Sep 16 13:55 mpihello.pbs

mpihello.c

/*
 * VSC        : Flemish Supercomputing Centre
 * Tutorial   : Introduction to HPC
 * Description: Example program, to compile with MPI
 */
#include <stdio.h>
#include <mpi.h>

main(int argc, char **argv)
{
  int node, i, j;
  float f;

  MPI_Init(&argc,&argv);
  MPI_Comm_rank(MPI_COMM_WORLD, &node);

  printf("Hello World from Node %d.\n", node);
  for (i=0; i<=100000; i++)
    f=i*2.718281828*i+i+i*3.141592654;

  MPI_Finalize();
}

The "mpi_hello.c" program is a simple source file, written in C with MPI library calls.

Then, check the command line options for "mpicc" (GNU C-Compiler with MPI extensions), then we compile and list the contents of the directory again:

$ mpicc --help
$ mpicc -o mpihello mpihello.c
$ ls -l

A new file "hello" has been created. Note that this program has "execute" rights.

Let's test this program on the "login" node first:

$ ./mpihello
Hello World from Node 0.

It seems to work, now run it on the HPC.

$ qsub mpihello.pbs

Compiling a parallel program in Intel Parallel Studio Cluster Edition#

We will now compile the same program, but using the Intel Parallel Studio Cluster Edition compilers. We stay in the examples directory for this chapter:

$ cd ~/examples/Compiling-and-testing-your-software-on-the-HPC

We will compile this C/MPI -file into an executable with the Intel Parallel Studio Cluster Edition. First, clear the modules (purge) and then load the latest "intel" module:

$ module purge
$ module load intel

Then, compile and list the contents of the directory again. The Intel equivalent of mpicc is mpiicc.

$ mpiicc -o mpihello mpihello.c
$ ls -l

Note that the old "mpihello" file has been overwritten. Let's test this program on the "login" node first:

$ ./mpihello
Hello World from Node 0.

It seems to work, now run it on the HPC.

$ qsub mpihello.pbs

Note: The AUGent only has a license for the Intel Parallel Studio Cluster Edition for a fixed number of users. As such, it might happen that you have to wait a few minutes before a floating license becomes available for your use.

Note: The Intel Parallel Studio Cluster Edition contains equivalent compilers for all GNU compilers. Hereafter the overview for C, C++ and Fortran compilers.

Sequential Program Parallel Program (with MPI)
GNU Intel GNU Intel
C gcc icc mpicc mpiicc
C++ g++ icpc mpicxx mpiicpc
Fortran gfortran ifort mpif90 mpiifort