Versions Installed

Kay: 8.2.0, 9.4.0


gcc is the flagship c/c++ compiler from Gnu.


gcc is licensed to the public under the terms of the GNU Public License (GPL).



Job Submission Example on Kay

The following example shows how to compile a simple C++ 'Hello world'-style program and run it on a compute node on Kay.

The program listing is simply the following:

#include <iostream>

using std::cout;
using std::endl;

int main(int argc, char** argv)
    cout << "Hello world!" << endl;

    return 0;

We save this in the C++ file named helloworld.cc.  The program is compiled as follows:

-bash-4.2$ module load gcc/9.4.0
-bash-4.2$ g++ helloworld.cc -o helloworld -O3

This outputs an executable file called helloworld.  Here we have shown how to compile on the login node (i.e. at the command prompt when logged in to Kay), but be aware for very intensive compilations you should compile in a script and submit a job for this.  However, for most situations it is fine to compile on the login node.  Next, we show a script that can be used to run the program on Kay, on a single node.

# All the information about queues can be obtained using 'sinfo'
# DevQ         up    1:00:00  
# ProdQ*       up 3-00:00:00   
# LongQ        up 6-00:00:00   
# ShmemQ       up 3-00:00:00   
# PhiQ         up 1-00:00:00  
# GpuQ         up 2-00:00:00    

# Slurm flags
#SBATCH -p ProdQ
#SBATCH -t 00:05:00
#SBATCH --job-name=gccrun

# Charge job to myproject
#SBATCH -A MyProject

# Write stdout+stderr to file
#SBATCH -o output.txt

# Mail me on job start & end
#SBATCH --mail-user=myEmail@domain.ie
#SBATCH --mail-type=BEGIN,END


module load gcc/9.4.0




Further information on gcc can be obtained here. 

Supported By

File Browser Reference
Department FHERIS
NUI Galway
HEA Logo