Compilers
Algorithms to executables
Compilers Algorithms to executables Outline What does compiling - - PowerPoint PPT Presentation
Compilers Algorithms to executables Outline What does compiling mean? - Where do libraries come in? Anatomy of a compiler Compiler optimisations Can the compiler parallelise my code? Why are there differences in
Algorithms to executables
2
What does compiling mean?
3
readable language.
code.
possible on the processors
4
multiple programs
transformations
(MPI), OpenMP
code generated from the user’s program to produce the final executable.
shared libraries).
5
How does it actually work?
6
Link Stage Compile Stage Source code files Machine code
(*.o) Libraries Executable binary file
7
Compile Stage Source code files Machine code
(*.o)
8
Link Stage Compile Stage Source code files Machine code
(*.o) Libraries Executable binary file
9
application
at this stage
instead this code is called and executed dynamically when the executable is run
10
Program A Program B Dynamic libraries (*.so) Static linking at compile time, executable contains the libraries Dynamic linking at runtime, no libraries contained in the executable and these are loaded in when the program runs Program A Static libraries (*.a) Program B Static libraries (*.a)
11
What do they do? When should/shouldn’t I use them?
12
machine code) and can include the reordering of operations
misnomer
to produce performance gains for some codes.
13
arithmetic
disables correctness checking.)
14
the order you specified
levels
extreme
15
with or without that optimisation enabled.
the code still produces “correct” results
problem you can turn them off gradually
levels so you can turn it off gradually
O3 to O2
16
Feature Cray Intel GNU
Listing
Free format (ftn)
Vectorization By default at -O1 and above By default at -O2 and above By default at -O3 or using
Inter-Procedural Optimization
Floating-point optimizations
[fast|fast=2|precise| except|strict]
Suggested Optimization (default)
Aggressive Optimization
OpenMP recognition (default)
Variables size (ftn)
Debugging
17
Can compilers parallelise my code?
18
parallelism required for scaling on multiple cores or nodes
level of parallism
task parallelism
automatically parallelising floating point operations at the CPU instruction level
19
available on processor cores’ floating point units.
20
Why are there differences between compilers?
21
standards for languages
architects to select the behaviour
(Intel) and can take advantage of detailed knowledge about hardware behaviour
22
23
workflow
benefits
compilers and whether your code requires a specific compiler
24