Scope-based Method Cache Analysis Benedikt Huber 1 , Stefan Hepp 1 , Martin Schoeberl 2 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 Confmict detection Evaluation 2
Motivation: The T-CREST Project T-CREST: The quest for a time-predictable multicore platform .c Compiler WCET Analysis RTOS ALU LM M$ ALU LM M$ ALU LM M$ D$ S$ D$ S$ D$ S$ Patmos Patmos Patmos NOC Memory controller FPGA Memory 3
Motivation: The T-CREST Project T-CREST: The quest for a time-predictable multicore platform .c Compiler WCET Analysis Method Split Cache Caches RTOS ALU LM M$ ALU LM M$ ALU LM M$ D$ S$ D$ S$ D$ S$ Patmos Patmos Patmos NOC Memory controller Time-composable memory FPGA hierarchy Memory 4
Motivation: The Method Cache Instruction cache that holds blocks of code of variable size Functions or parts of functions (compiler defjned) 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 T ag memory main: 2 g: 10 f: 14 - main() g() f() Cache 5
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 T ag memory main: 2 g: 10 f: 14 - main() g() f() Cache 6
Cache Analysis T echniques Always-miss/always-hit classifjcation [Grund10]: Shown to work for FIFO [Reineke08]: bound FIFO caches based on smaller LRU cache performance Persistence Analyses ( [Cullmann13], [Huynh11]) Deal with LRU caches (fjrst-miss) Use functions and loops as scopes Scope-based Cache Analysis Find at-most-one-miss scopes Find fjne-grained persistence scopes 7
Scope-based cache analysis 1) Build scope graph Scope graph: Functions, loops, callsites Access graph (per scope graph node): control fmow, 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 confmict-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 g() { for (;;) { access(X); } } f() { for (;;) { access(Y); } c3: g(); } main() { access(Y); c2: if (?) f(); access(Z); c1: g(); Scope graph access(Y); } 9
Example: Building the Scope Graph g() { for (;;) { access(X); } } f() { for (;;) { access(Y); } c3: g(); } main() { access(Y); c2: if (?) f(); access(Z); c1: g(); Access graph Scope graph access(Y); for main() } 10
Example: Finding confmict-free scopes Assuming a 2-way set-associative cache: OK OK Scope graph 11
Example: Finding confmict-free scopes Assuming a 2-way set-associative cache: OK OK OK OK Scope graph 12
Example: Finding confmict-free scopes Assuming a 2-way set-associative cache: OK OK OK OK OK OK Scope graph 13
Example: Finding confmict-free scopes Assuming a 2-way set-associative cache: Confmict! OK OK OK OK OK OK Scope graph 14
Example: Finding confmict-free scopes Assuming a 2-way set-associative cache: Confmict! OK OK OK OK OK OK Access graph Scope graph for main() 15
Example: Finding confmict-free scopes Assuming a 2-way set-associative cache: Confmict! OK OK OK OK OK OK Access graph Scope graph for main() 16
Example: Finding confmict-free scopes Assuming a 2-way set-associative cache: Confmict! OK OK OK OK OK OK Access graph Scope graph for main() 17
Example: Finding confmict-free scopes Assuming a 2-way set-associative cache: Confmict! OK OK OK Confmict! OK OK OK Access graph Scope graph for main() 18
Example: Finding confmict-free scopes Assuming a 2-way set-associative cache: Confmict! OK OK OK OK OK OK Access graph Scope graph for main() 19
Example: Finding confmict-free scopes Assuming a 2-way set-associative cache: Confmict! OK OK OK OK OK OK Access graph Scope graph for main() 20
Example: Finding confmict-free scopes Assuming a 2-way set-associative cache: Confmict! OK OK OK OK OK OK Access graph Scope graph for main() 21
Example: Finding confmict-free scopes Assuming a 2-way set-associative cache: Confmict! S1: {Y,X} OK OK OK S2: OK {Z,X} OK S3: OK {Y} Cache misses of X ≤ f(S1) + f(S2) Cache misses of Y ≤ f(S1) + f(S3) Cache misses of Z ≤ f(S2) 22
Example: Finding confmict-free scopes Assuming a 2-way set-associative cache: Confmict! S1: {Y,X} OK OK OK S2: OK {Z,X} OK S3: OK {Y} Cache misses of X ≤ f(S1) + f(S2) Cache misses of Y ≤ f(S1) + f(S3) => T otal cache misses ≤ 5 f(main) Cache misses of Z ≤ f(S2) 23
Confmict Detection For FIFO and LRU n-way set-associative caches: confmict-free if at most n distinct cache lines are accessed path-insensitive , one analysis per cache set For method cache : confmict-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: confmict-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 fjne- 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 fjne-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: http://patmos.compute.dtu.dk/ http://github.com/t-crest/ Thanks! Questions? 28
Recommend
More recommend