HEPTANE (Hades Embedded Processor Timing ANalyzEr) A Modular Tool for Sta>c WCET Analysis ALF research group, IRISA/INRIA Rennes TuTor’16, Vienna, April 2016 Damien Hardy
HEPTANE (Hades Embedded Processor Timing ANalyzEr)
A Modular Tool for Sta>c WCET Analysis
ALF research group, IRISA/INRIA Rennes
TuTor’16, Vienna, April 2016
Damien Hardy
About HEPTANE • Developed at IRISA/University of Rennes
• Stable research prototype • Licenced under GPL • C++ code • Supported architectures
– MIPS – Par>ally: ARM v7, Patmos (under construc>on) – Not supported anymore: Power PC
• The first version has been designed around 2000 • Many updates since then! • Available online
hTps://team.inria.fr/alf/soVware/heptane/
2
Developers over the ages – Isabelle Puaut – Antoine Colin – Jean-‐François Deverge – Thomas Piquet – Damien Hardy – Benjamin Lesage – Erven Rohou – François Joulaud – MaThieu Avila – Nicolas Kiss – Loïc Besnard
3
Research based on Heptane
• Cache analysis (cache hierarchies, mul>-‐cores) • Branch predic>on (analysis, compiler-‐directed) • Cache locking, par>>oning • Scratchpad management • CRPD es>ma>on • Sta>c probabilis>c WCET • Traceability of flow informa>on
4
Outlines – Quick overview
• Framework • Installa>on
– How to use it • HeptaneExtract • HeptaneAnalysis
– Low level analysis – High level analysis – Extra analysis
– Inside Heptane • build your analysis • Source • Cfglib • Useful func>ons
5
Heptane Framework
• CFG Library – Extensible program representa>on
• Program, CFG, Loop, basic block, instruc>on…
• HeptaneExtract – CFG building from the binary – Loops extrac>on
• HeptaneAnalysis – Mul>ple analyses step – Interface to define new analyses
CFG LIBRARY
Analysis 1
Analysis 2
Analysis 3 Based on
1&2
6
Function: Multiply
loop [maxiter=20]
loop [maxiter=20]
loop [maxiter=20]
@0x400330 (BB)
@0x400224 (BB) @0x40033c (BB)
@0x40032c (BB)
@0x400320 (BB)
@0x40022c (BB)
@0x40031c (BB)
@0x400310 (BB)
@0x40025c (BB)
@0x40020c (BB)
Heptane toolchain
.c file
& loops bounds
Compiler (gcc/LLVM)
CFG extraction
Binary
XML file
Low-Level Analysis
High-Level Analysis
• WCET • WCEP • Statistics • HTML
7
HeptaneExtract
HeptaneAnalysis
Installa>on (1/2)
• Requirements – OS: Linux or Mac OS X – Libxml2 – ILP solver (lp-‐solve, cplex)
• Op>onal – Doxygen – Dot – epstopdf
8
Installa>on (2/2) • For the tutorial
– Virtual machine hTps://tutor2016.inria.fr/heptane
• Otherwise – Script: install.sh
System dependent
Part to install
9
Outlines – Quick overview
• Framework • Installa>on
– How to use it • HeptaneExtract • HeptaneAnalysis
– Low level analysis – High level analysis – Extra analysis
– Inside Heptane • build your analysis • Source • Cfglib • Useful func>ons
10
How to use it
• Source code in C – With annota>on for the loops bounds: ANNOT_MAXITER(cst)
Include needed
ANNOT_MAXITER for each loop
Some restric>ons – No pointers – No malloc – Natural loops – No recursion
11
How to use it: HeptaneExtract
.c file
& loops bounds
configuration file (.xml)
Compiler (gcc/LLVM)
CFG extraction
Binary
HeptaneExtract
CFG
.xml
+ optional files (binary, objdump…)
12
HeptaneExtract: configura>on file
Compiler configuration
Target
Binutils configuration
13
HeptaneExtract: configura>on file
in/tmp/out directories
Output files and information
14
HeptaneExtract: configura>on file
Program to extract
15
HeptaneExtract: Good news!
• Automa>c configura>on (for simple cases) – In the directory benchmarks
• configExtract_template.xml • extract.sh
./extract.sh <benchmark_name>
16
CFG.xml
17
How to use it: HeptaneAnalysis
configuration file (.xml)
Low Level
Analysis
High Level
Analysis
HeptaneAnalysis
CFG
.xml
• WCET • WCEP • Statistics • HTML
18
HeptaneAnalysis: configura>on file
Directory of the program
Architecture information
LRU/PLRU/FIFO/MRU/RANDOM
19
HeptaneAnalysis: configura>on file
20
HeptaneAnalysis: Good news!
• Automa>c configura>on – In the directory config_files: configWCET_template.xml – analysis.sh: ./analysis.sh <benchmark_name> – Or: ./bin/HeptaneAnalysis <configWCET.xml>
21
HeptaneAnalysis: Analyses
• Each analysis can be seen as a pass – Performed in the order of declara>on in the config file
• Each analysis extends the XML file (CFG) – Informa>on added with aTributes
• Program, CFG, Node, Loop, Edge, Instruc>on
• 3 steps per analysis – CheckInputATributes – PerformAnalysis – RemovePrivateATributes
22
HeptaneAnalysis: common parameters
23
Input file Keep results in memory Output file
Analyses
• Low-‐level analysis: Timing informa>on per basic block
• High-‐level analysis: WCET es>ma>on – Implicit Path Enumera>on Technique (IPET) – No Tree based method anymore
• Extra analysis: sta>s>cs & some informa>on
24
Address Analysis
Cache Analysis
Pipeline Analysis
Address analysis (1/2)
• Instruc>on address analysis – Performed during the CFG extrac>on (OUTPUTCODEADDRESS)
• Data address analysis – Contextual analysis (calling context) – Performed at the basic block granularity – Pointers not supported (currently)
25
Initial stack pointer address
Address analysis (2/2) • For each func>on: stack informa>on per context
• For each access
26
Cache analysis
• Instruc>on & data caches – Contextual analysis (calling context) – Based on abstract interpreta>on (must, may, persistence) – Mul>-‐level non inclusive cache hierarchies
• write-‐through no-‐write allocate data caches – Input aTributes: instruc>on & data addresses
27
Cache analysis: inside
• Computa>on of Abstract Cache States (ACS) – Contains all possible cache contents considering “all” possible execu>on paths
• 3 Analyses (Fixpoint computa>on) – Must, May and Persistence – Modifica>on of ACS
• Update: at every reference • Join: at every path merging point
• Access categoriza>on from ACS – Cache Hit Miss Classifica>on (CHMC)
• Always hit, Always miss, First miss, Not-‐classified
28
Must analysis
Age +
Join Intersection + max age
a b c d b e d a
{} b {} d,a
Update Apply replacement policy (ex: LRU)
a b c d
e a b c
[e]
ACS contain all program lines guaranteed to be in the cache at a given point
29
Age + Age +
Cache analysis: Mul>-‐level • Filtering informa>on between cache levels
– Cache Access Classifica>on (CAC) • Always, Never, Uncertain
• Modifica>on of the update func>on – Always: the ACS is updated as before – Never: no modifica>on of the ACS – Uncertain
30
Classification
Cache analysisLevel L+1
Cache analysisLevel L
Filtering
referencesMemory
FilteringCache Hit/MissClassificationCache Access
Always access
out
inACS
Update Identity
Join function
Update function for uncertain accessm
Never access
ACS
Cache analysis: output
31
Pipeline analysis • Pipeline analysis: compute the >ming of basic blocks
– Contextual analysis (calling context) – Input aTributes: CHMC of I$ and D$
32
Pipeline analysis: inside
Principle : parallelism between instruc>ons • Intra basic-‐block
• Inter basic-‐block
33
Time
Time
Fetch Decode Execute Memory Write Back
Time
IF ID EX ME WB
Time
33
Analyses
• Low-‐level analysis: Timing informa>on per basic block
• High-‐level analysis: WCET es7ma7on – Implicit Path Enumera>on Technique (IPET) – No Tree based method anymore
• Extra analysis: sta>s>cs & some informa>on
34
Address Analysis
Cache Analysis
Pipeline Analysis
IPET analysis
• IPET analysis: final WCET computa>on – Contextual analysis (calling context) – Input aTributes: CHMC of I$ and D$ or >ming of basic blocks
35
METHOD_CACHE_NOPIPELINE METHOD_CACHE_PIPELINE METHOD_NOCACHE_NOPIPELINE
Solver: lp_solve or cplex
Integer Linear Programming (ILP)
– Constant: Ti Variable: fi – Objective function: max: f1T1+f2T2+…+fnTn – Structural constraints
∀ bbi : fi = Σ aj = Σ ak
f1 = 1
– Extra flow information ∀ bbi in loop, fi ≤ k (loop bound) fi + fj ≤ 1 (mutually exclusive paths – not in loop) fi ≤ 2 fj (relations between execution freqs.)
IPET: inside
aj∈In(bbi) ak∈Out(bbi)
T1
T2
T3
T4 T5
T6
T7
36
Analyses
• Low-‐level analysis: Timing informa>on per basic block
• High-‐level analysis: WCET es>ma>on – Implicit Path Enumera>on Technique (IPET) – No Tree based method anymore
• Extra analysis: sta7s7cs & some informa7ons
37
Address Analysis
Cache Analysis
Pipeline Analysis
Extra analysis: sta>s>cs (1/2)
• Cache sta>s>cs – Contextual analysis (calling context) – Input aTributes: CHMC of caches & WCET computa>on
38
Extra analysis: sta>s>cs (2/2)
• Codeline & htmlprint – Input aTributes: WCET computa>on
39
Extra analysis: some informa>ons (1/2) • Dotprint
40
Function: Multiply
loop [maxiter=20]
loop [maxiter=20]
loop [maxiter=20]
@0x400330 (BB)
@0x400224 (BB) @0x40033c (BB)
@0x40032c (BB)
@0x400320 (BB)
@0x40022c (BB)
@0x40031c (BB)
@0x400310 (BB)
@0x40025c (BB)
@0x40020c (BB)
Extra analysis: some informa>ons (2/2) • Simpleprint
41
For the aVernoon session
• Heptane u>liza>on – HeptaneExtract – HeptaneAnalysis
• Build your own analysis – Percentage of load/store instruc>ons in a program
1. Number of instruc>ons 2. Number of load/store 3. Contextual analysis (calling context)
42
Build your analysis
• Inheritance: Analysis.h – �CheckInputATributes, �PerformAnalysis, �RemovePrivateATributes
• Generic/config.cc – Parsing of the parameters – Instanciate the analysis
• Good news: DummyAnalysis ��Heptane/src/HeptaneAnalysis/src/Specific/DummyAnalysis/ <DUMMYANALYSIS/> in the configura>on file
43
Inside Heptane: Source
• Common – cfglib – ArchitectureDependent, GlobalATributes, Utl
• HeptaneExtract • HeptaneAnalysis
– Generic: context, AnalysisHelper, Analysis.h … – SharedATributes: name of Serialisable ATributes (SharedATributes.h)
– Specific: a directory for each analysis
44
CFG library (1/3)
• Hierarchical structure – Program
• CFG – Node
• Instruc>on – Edge – Loop
• Func>ons to manipulate the program representa>on – �/home/user/Desktop/Heptane/src/cfglib_install/doc/generated-‐doc/html/index.html
45
GetProgram GetAllNodes/GetAllLoops… GetPredecessors/GetSuccessors
CFG library (2/3) • Informa>on added with aTributes
– Program, CFG, Node, Loop, Edge, Instruc>on
• ATributes: Serialisable & non serialisable – �[Non]Serialisable[Type]ATribute
• Type: Integer, String, Float, UnsignedLong
• New aTributes – Inheritance: �NonSerialisableATribute / SerialisableATribute
• SerialisableATribute for Heptane – Func>ons: �WriteXml & ReadXml – �Declara>on of the aTribute in main.cc (func>on main of HeptaneAnalysis)
46
CFG library (3/3)
• Generic func>ons (ATributed.h) �bool HasATribute (std::string ATributeName); �void SetATribute (std::string ATributeName, ATribute &aTribute); �void RemoveATribute (std::string ATributeName) ; �ATribute &GetATribute (std::string ATributeName) ;
47
HeptaneAnalysis: useful func>ons (1/2)
• Generic func>ons �applyToAllNodesRecursive (Program * p, t_node_func>on * f, void *param);
48
HeptaneAnalysis: useful func>ons (2/2) • Context (aTached to cfgs)
�AnalysisHelper::computeContext (Program* p);
• Context manipula>on
GetContextualPredecessors/�GetContextualSuccessors Return: Vector<ContextualNode>
49