scope-based method cache analysis - ulm...scope-based method cache analysis benedikt huber1, stefan...
TRANSCRIPT
Scope-based Method Cache Analysis
Benedikt Huber1, Stefan Hepp1, Martin Schoeberl2
1 Vienna University of Technology 2 Technical University of Denmark
14th International Workshop on Worst-Case Execution Time Analysis (WCET 2014)July 8, 2014
Outline
Motivation The method cache
Scope-based Cache Analysis Basic principle Conflict detection
Evaluation
2
Motivation: The T-CREST Project
3
.c
Compiler WCET Analysis
RTOS
MemoryFPGA
Memory controller
M$
S$D$
LM
Patmos
ALU M$
S$D$
LM
Patmos
ALU M$
S$D$
LM
Patmos
ALU
NOC
T-CREST: The quest for a time-predictable multicore platform
Motivation: The T-CREST Project
4
.c
Compiler WCET Analysis
RTOS
MemoryFPGA
Memory controller
M$
S$D$
LM
Patmos
ALU M$
S$D$
LM
Patmos
ALU M$
S$D$
LM
Patmos
ALU
NOC
MethodCacheSplit
Caches
Time-composablememoryhierarchy
T-CREST: The quest for a time-predictable multicore platform
Motivation: The Method Cache Instruction cache that holds blocks of code of variable size
Functions or parts of functions (compiler defined) Cache updates only at call, return and special branches Fully associative tag memory
More dynamic than I-SPM Address translation, replacement done in hardware
Less hardware costs than n-way LRU instruction cache Instructions only stall in memory stage Smaller tag memory
5
main: 2
main() g() f()
Tag memory g: 10 f: 14 -
Cache
Motivation: Analysis of the M$
But: Only FIFO replacement (fragmentation)
But: Variable sized cache blocks
Path-sensitive analysis techniques based on abstract interpretation do not work well for the method cache
Instead: Generalized persistence analysis
6
main: 2
main() g() f()
Tag memory g: 10 f: 14 -
Cache
Cache Analysis Techniques
Always-miss/always-hit classification [Grund10]: Shown to work for FIFO [Reineke08]: bound FIFO caches based on smaller LRU
cache performance
Persistence Analyses ([Cullmann13], [Huynh11])
Deal with LRU caches (first-miss) Use functions and loops as scopes
Scope-based Cache Analysis Find at-most-one-miss scopes Find fine-grained persistence scopes
7
Scope-based cache analysis
1) Build scope graph Scope graph: Functions, loops, callsites
Access graph (per scope graph node): control flow, memory accesses, subscopes and backedge nodes
2) For each memory block B: Find set of single-entry scopes S(B) (regions) on the access
graphs s.t.:• every access to B is within a scope• B is conflict-free / missed at most once within each scope
3) Maximum number of misses of B ≤ sum of maximum number of executions of all scopes S(B)
Extend IPET by cache miss frequency variables and bound sum of variables by ∑ f(S(B))
8
Example: Building the Scope Graph
9
g() { for (;;) { access(X); } }
f() { for (;;) { access(Y); }c3: g(); }
main() { access(Y);c2: if (?) f(); access(Z);c1: g(); access(Y); }
Scope graph
Example: Building the Scope Graph
10
g() { for (;;) { access(X); } }
f() { for (;;) { access(Y); }c3: g(); }
main() { access(Y);c2: if (?) f(); access(Z);c1: g(); access(Y); }
Scope graphAccess graph
for main()
Example: Finding conflict-free scopes
11
Scope graph
Assuming a 2-way set-associative cache:
OK
OK
Example: Finding conflict-free scopes
12
Scope graph
Assuming a 2-way set-associative cache:
OK
OK
OK
OK
Example: Finding conflict-free scopes
13
Scope graph
Assuming a 2-way set-associative cache:
OK
OK
OK
OK
OK OK
Example: Finding conflict-free scopes
14
Scope graph
Assuming a 2-way set-associative cache:
OK
OK
OK
OK
OK OK
Conflict!
Example: Finding conflict-free scopes
15
Scope graph
Assuming a 2-way set-associative cache:
OK
OK
OK
OK
OK OK
Conflict!
Access graphfor main()
Example: Finding conflict-free scopes
16
Scope graph
Assuming a 2-way set-associative cache:
OK
OK
OK
OK
OK OK
Conflict!
Access graphfor main()
Example: Finding conflict-free scopes
17
Scope graph
Assuming a 2-way set-associative cache:
OK
OK
OK
OK
OK OK
Conflict!
Access graphfor main()
Example: Finding conflict-free scopes
18
Scope graph
Assuming a 2-way set-associative cache:
OK
OK
OK
OK
OK OK
Conflict!
Access graphfor main()
Conflict!
Example: Finding conflict-free scopes
19
Scope graph
Assuming a 2-way set-associative cache:
OK
OK
OK
OK
OK OK
Conflict!
Access graphfor main()
Example: Finding conflict-free scopes
20
Scope graph
Assuming a 2-way set-associative cache:
OK
OK
OK
OK
OK OK
Conflict!
Access graphfor main()
Example: Finding conflict-free scopes
21
Scope graph
Assuming a 2-way set-associative cache:
OK
OK
OK
OK
OK OK
Conflict!
Access graphfor main()
Example: Finding conflict-free scopes
22
Assuming a 2-way set-associative cache:
OK
OK
OK
OK
OK OK
Conflict!
S1:{Y,X}
S2:{Z,X}
S3:{Y}
Cache misses of X ≤ f(S1) + f(S2)Cache misses of Y ≤ f(S1) + f(S3) Cache misses of Z ≤ f(S2)
Example: Finding conflict-free scopes
23
Assuming a 2-way set-associative cache:
OK
OK
OK
OK
OK OK
Conflict!
S1:{Y,X}
S2:{Z,X}
S3:{Y}
Cache misses of X ≤ f(S1) + f(S2)Cache misses of Y ≤ f(S1) + f(S3) => Total cache misses ≤ 5 f(main)Cache misses of Z ≤ f(S2)
Conflict Detection For FIFO and LRU n-way set-associative caches:
conflict-free if at most n distinct cache lines are accessed path-insensitive, one analysis per cache set
For method cache: conflict-free if size and number of accessed functions does
not exceed capacity of cache path-insensitive, one single analysis
For LRU n-way set-associative caches:
conflict-free if at most n-1 distinct cache lines accessed between two accesses of a block B
path sensitive, per block, abstract interpretation
• similar to [Cullmann13] or [Huynh11], but more fine-grained scopes
24
Implementation
Implemented in the platin analysis tool Persistence analysis based on [Huynh11] Scope-based analysis for set-associative FIFO/LRU
caches Scope-based analysis for method cache 'Simple' scope-based analysis: only functions and
loops as scopes, no construction of fine-grained scopes
Evaluated on Mälardalen and PapaBench benchmarks
25
Evaluation
Results for a 1 kB 8-way LRU set-associative cache
Evaluation
Results for a 1 kB method cache
Conclusion
Scope-based cache analysis framework M$ or set-associative caches, FIFO or LRU Generalization of Persistence Analysis Improved concept of scopes Evaluation promises good analysis precision
Implemented in platin, available at:
28
http://github.com/t-crest/
Thanks! Questions?
http://patmos.compute.dtu.dk/