• 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 (Decommissioned)
        • Einstein Cluster (Decommissioned)
        • Isaac Newton HPC Facility (Decommissioned)
      • HPC User Guides and FAQs
        • Getting started on CQUniversity’s Ada Lovelace HPC System
        • Basics of working on the HPC
        • Finding Installed Software
        • Graphical connection HPC via Open On Demand
        • 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 HPC Scheduler on Ada Lovelace Cluster
        • Using MATLAB
        • Using R
        • Virtualisation and Containers
        • Creating a Conda Enviroment
        • LLM’s on Ada Cluster
        • Running Python on Ada
        • Machine and Deep Learning modules on Ada
        • PBS to Slurm Command tables (HPC Scheduler)
        • Compiling Programs (and using the optimization flags)
        • Frequently Asked Questions
        • HPC Trouble Shooting
      • 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

COMPILER USAGE EXAMPLE NOTES ON EXAMPLE
C/C++
GNU C  gcc myprogram.c -o myprogram.exe The gcc compiler will compile the myprogram.c “c” code to the executable myprogram.exe
GNU C++ g++ myprogram.cpp -o myprogram.exe The g++ compiler will compile the myprogram.cpp C++ code to the executable myprogram.exe
Intel C  icc myprogram.c -o myprogram.exe The icc compiler will compile the myprogram.c “C” code to the executable myprogram.exe
Intel C++  icc myprogram.cpp -o myprogram.exe The icc compiler will compile the myprogram.cpp c++ code to the executable myprogram.exe
FORTRAN
Intel Fortran ifort myprogram.f -o myprogram.exeifort myprogram.f90 -o myprogram.exeifort myprogram.f95 -o myprogram.exe The 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.exe The 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.exe The 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 -lmpi The 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 needed gnatmake myprogram -o myprogram.exe The 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 LEVEL FLAG COMPILING EXAMPLE
GNU COMPILER
No Optimization -O0 g++ -O0 myprogram.cpp -o myprogram.exe.
Level 1 -O1 g++ -O1 myprogram.cpp -o myprogram.exe.
Level 2 -O2 g++ -O2 myprogram.cpp -o myprogram.exe.
Level 3 -O3 g++ -O3 myprogram.cpp -o myprogram.exe.
Fast -fast g++ -fast myprogram.cpp -o myprogram.exe.
INTEL COMPILER
No Optimization -O0 icc -O0 myprogram.cpp -o myprogram.exe.
Level 1 -O1 icc -O1 myprogram.cpp -o myprogram.exe.
Level 2 -O2 icc -O2 myprogram.cpp -o myprogram.exe.
Level 3 -O3 icc -O3 myprogram.cpp -o myprogram.exe.
Fast -fast icc -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