• eResearch
    • Collaborative Technologies
      • ARDC (Australian Research Data Commons)
      • ARDC Nectar Research Cloud
      • Australian Access Federation
      • QRIScloud
      • Video Collaboration
    • Data Management
      • Research Data Management Plans
    • Data Services
      • Australian and International Data Portals
      • CQUni Research Data Storage Options
      • CQUniversity Research Data Storage
      • GEOSCIENCE DATA PORTALS
    • eResearch and Security: MFA and CyberSafety
      • Encrypting Data on Portable Devices
    • High Performance Computing
      • The History of CQU’s HPC Facilities
        • Ada Lovelace Cluster (Current)
        • Marie Curie Cluster (Decommissioning)
        • Einstein Cluster (Decommissioned)
        • Isaac Newton HPC Facility (Decommissioned)
      • HPC User Guides and FAQs
        • Basics of working on the HPC
        • Getting started on CQUniversity’s Ada Lovelace HPC System
        • Compiling Programs (and using the optimization flags)
        • Creating a Conda Enviroment
        • Finding Installed Software
        • Frequently Asked Questions
        • Graphical connection HPC via Open On Demand
        • HPC Trouble Shooting
        • LLM’s on Ada Cluster
        • Machine and Deep Learning modules on Ada
        • PBS to Slurm Command tables (HPC Scheduler)
        • Running Python on Ada
        • Simple Unix Commands
        • Slurm Commands
        • Software Module Information
        • Transferring Files to the HPC System (Ada)
        • Using Abaqus
        • Using ANSYS (Fluent) on the HPC System
        • Using APSIM
        • Using HPC Scheduler on Ada Lovelace Cluster
        • Using MATLAB
        • Using R
        • Virtualisation and Containers
      • HPC Community
      • HPC Related Links
      • HPC Sample Code Scripts
        • Multiple Job Submission – Slurm
        • Parameter sweep multiple job – Slurm
        • R Sample Scripts – Slurm
        • Sample Slurm Submission Script
      • HPC Software
    • Research Software
    • Scholarly Communication
    • Survey Tools
    • Training
      • QCIF – Queensland Cyber Infrastructure Foundation
      • Teaching Lab Skills for Scientific Computing

eResearch

Compiling Programs (and using the optimization flags)

Compiling

COMPILERUSAGE EXAMPLENOTES ON EXAMPLE
C/C++
GNU C gcc myprogram.c -o myprogram.exeThe gcc compiler will compile the myprogram.c “c” code to the executable myprogram.exe
GNU C++g++ myprogram.cpp -o myprogram.exeThe g++ compiler will compile the myprogram.cpp C++ code to the executable myprogram.exe
Intel C icc myprogram.c -o myprogram.exeThe icc compiler will compile the myprogram.c “C” code to the executable myprogram.exe
Intel C++ icc myprogram.cpp -o myprogram.exeThe icc compiler will compile the myprogram.cpp c++ code to the executable myprogram.exe
FORTRAN
Intel Fortranifort myprogram.f -o myprogram.exeifort myprogram.f90 -o myprogram.exeifort myprogram.f95 -o myprogram.exeThe ifort compiler will compile the myprogram.f (or *.90 or *.95) fortran code to the executable myprogram.exe
GNU FortranNote: you will need to load
the gnu-gcc-4.8.1 or gcc-fortran
module, before the gfortran compiler is available.
gfortran myprogram.f -o myprogram.exegfortran myprogram.f90 -o myprogram.exegfortran myprogram.f95 -o myprogram.exeThe gfortran compiler will compile the myprogram.f (or *.90 or *.95) fortran code to the executable myprogram.exe
MPI
C/C++ for MPI (GNU Compiler)mpicc myprogram.c -o myprogram.exeThe gcc compiler will compile the myprogram.c “C” code to the executable myprogram.exe using the mpi wrapper mpicc 
C/C++ for MPI (Intel Compiler)icc myprogram.c -o myprogram.exe -lmpiThe icc compiler will compile the myprogram.c “C” code to the executable myprogram.exe using the mpi wrapper mpiicc
ADA
GNU ADA(Note – ADA not currently available on Login Node)Can provide access to compiler if neededgnatmake myprogram -o myprogram.exeThe gcc compiler will compile the myprogram.adb ADA code to the executable myprogram.exe using the gnatmake program

Optimization

The selection and modification of variables and options during the compile process can have a significant effect on program execution and results. One simple technique is to use optimization flags when compiling the code. Optimization flags encourage the compiler to improve upon performance (however this can come at the expense of correct results). Optimization flags are represented in syntax as “-O#” (The letter O and then a number), which are the compiling flag option used to select the level of optimization applied to produce an executable.

An example of compile syntax would be:

g++ (or icc) -O2 myprogram.cpp -o myprogram.exe

Programs initially compiled using the default compile options for each compiler are set to the following levels of optimization, GNU compilers use no optimization (“-O0”) and the Intel compiler uses level 2 optimization (“-O2”).

Example compile syntax include:

OPTIMIZATION LEVELFLAGCOMPILING EXAMPLE
GNU COMPILER
No Optimization-O0g++ -O0 myprogram.cpp -o myprogram.exe.
Level 1-O1g++ -O1 myprogram.cpp -o myprogram.exe.
Level 2-O2g++ -O2 myprogram.cpp -o myprogram.exe.
Level 3-O3g++ -O3 myprogram.cpp -o myprogram.exe.
Fast-fastg++ -fast myprogram.cpp -o myprogram.exe.
INTEL COMPILER
No Optimization-O0icc -O0 myprogram.cpp -o myprogram.exe.
Level 1-O1icc -O1 myprogram.cpp -o myprogram.exe.
Level 2-O2icc -O2 myprogram.cpp -o myprogram.exe.
Level 3-O3icc -O3 myprogram.cpp -o myprogram.exe.
Fast-fasticc -fast myprogram.cpp -o myprogram.exe.

Support

eresearch@cqu.edu.au

tasac@cqu.edu.au OR 1300 666 620

Hacky Hour (3pm – 4pm every Tuesday)

High Performance Computing Teams site