scope-based method cache analysis - ulm...scope-based method cache analysis benedikt huber1, stefan...

28
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

Upload: others

Post on 03-Sep-2020

9 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Scope-based Method Cache Analysis - Ulm...Scope-based Method Cache Analysis Benedikt Huber1, Stefan Hepp1, Martin Schoeberl2 1 Vienna University of Technology 2 Technical University

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

Page 2: Scope-based Method Cache Analysis - Ulm...Scope-based Method Cache Analysis Benedikt Huber1, Stefan Hepp1, Martin Schoeberl2 1 Vienna University of Technology 2 Technical University

Outline

Motivation The method cache

Scope-based Cache Analysis Basic principle Conflict detection

Evaluation

2

Page 3: Scope-based Method Cache Analysis - Ulm...Scope-based Method Cache Analysis Benedikt Huber1, Stefan Hepp1, Martin Schoeberl2 1 Vienna University of Technology 2 Technical University

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

Page 4: Scope-based Method Cache Analysis - Ulm...Scope-based Method Cache Analysis Benedikt Huber1, Stefan Hepp1, Martin Schoeberl2 1 Vienna University of Technology 2 Technical University

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

Page 5: Scope-based Method Cache Analysis - Ulm...Scope-based Method Cache Analysis Benedikt Huber1, Stefan Hepp1, Martin Schoeberl2 1 Vienna University of Technology 2 Technical University

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

Page 6: Scope-based Method Cache Analysis - Ulm...Scope-based Method Cache Analysis Benedikt Huber1, Stefan Hepp1, Martin Schoeberl2 1 Vienna University of Technology 2 Technical University

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

Page 7: Scope-based Method Cache Analysis - Ulm...Scope-based Method Cache Analysis Benedikt Huber1, Stefan Hepp1, Martin Schoeberl2 1 Vienna University of Technology 2 Technical University

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

Page 8: Scope-based Method Cache Analysis - Ulm...Scope-based Method Cache Analysis Benedikt Huber1, Stefan Hepp1, Martin Schoeberl2 1 Vienna University of Technology 2 Technical University

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

Page 9: Scope-based Method Cache Analysis - Ulm...Scope-based Method Cache Analysis Benedikt Huber1, Stefan Hepp1, Martin Schoeberl2 1 Vienna University of Technology 2 Technical University

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

Page 10: Scope-based Method Cache Analysis - Ulm...Scope-based Method Cache Analysis Benedikt Huber1, Stefan Hepp1, Martin Schoeberl2 1 Vienna University of Technology 2 Technical University

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()

Page 11: Scope-based Method Cache Analysis - Ulm...Scope-based Method Cache Analysis Benedikt Huber1, Stefan Hepp1, Martin Schoeberl2 1 Vienna University of Technology 2 Technical University

Example: Finding conflict-free scopes

11

Scope graph

Assuming a 2-way set-associative cache:

OK

OK

Page 12: Scope-based Method Cache Analysis - Ulm...Scope-based Method Cache Analysis Benedikt Huber1, Stefan Hepp1, Martin Schoeberl2 1 Vienna University of Technology 2 Technical University

Example: Finding conflict-free scopes

12

Scope graph

Assuming a 2-way set-associative cache:

OK

OK

OK

OK

Page 13: Scope-based Method Cache Analysis - Ulm...Scope-based Method Cache Analysis Benedikt Huber1, Stefan Hepp1, Martin Schoeberl2 1 Vienna University of Technology 2 Technical University

Example: Finding conflict-free scopes

13

Scope graph

Assuming a 2-way set-associative cache:

OK

OK

OK

OK

OK OK

Page 14: Scope-based Method Cache Analysis - Ulm...Scope-based Method Cache Analysis Benedikt Huber1, Stefan Hepp1, Martin Schoeberl2 1 Vienna University of Technology 2 Technical University

Example: Finding conflict-free scopes

14

Scope graph

Assuming a 2-way set-associative cache:

OK

OK

OK

OK

OK OK

Conflict!

Page 15: Scope-based Method Cache Analysis - Ulm...Scope-based Method Cache Analysis Benedikt Huber1, Stefan Hepp1, Martin Schoeberl2 1 Vienna University of Technology 2 Technical University

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()

Page 16: Scope-based Method Cache Analysis - Ulm...Scope-based Method Cache Analysis Benedikt Huber1, Stefan Hepp1, Martin Schoeberl2 1 Vienna University of Technology 2 Technical University

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()

Page 17: Scope-based Method Cache Analysis - Ulm...Scope-based Method Cache Analysis Benedikt Huber1, Stefan Hepp1, Martin Schoeberl2 1 Vienna University of Technology 2 Technical University

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()

Page 18: Scope-based Method Cache Analysis - Ulm...Scope-based Method Cache Analysis Benedikt Huber1, Stefan Hepp1, Martin Schoeberl2 1 Vienna University of Technology 2 Technical University

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!

Page 19: Scope-based Method Cache Analysis - Ulm...Scope-based Method Cache Analysis Benedikt Huber1, Stefan Hepp1, Martin Schoeberl2 1 Vienna University of Technology 2 Technical University

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()

Page 20: Scope-based Method Cache Analysis - Ulm...Scope-based Method Cache Analysis Benedikt Huber1, Stefan Hepp1, Martin Schoeberl2 1 Vienna University of Technology 2 Technical University

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()

Page 21: Scope-based Method Cache Analysis - Ulm...Scope-based Method Cache Analysis Benedikt Huber1, Stefan Hepp1, Martin Schoeberl2 1 Vienna University of Technology 2 Technical University

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()

Page 22: Scope-based Method Cache Analysis - Ulm...Scope-based Method Cache Analysis Benedikt Huber1, Stefan Hepp1, Martin Schoeberl2 1 Vienna University of Technology 2 Technical University

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)

Page 23: Scope-based Method Cache Analysis - Ulm...Scope-based Method Cache Analysis Benedikt Huber1, Stefan Hepp1, Martin Schoeberl2 1 Vienna University of Technology 2 Technical University

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)

Page 24: Scope-based Method Cache Analysis - Ulm...Scope-based Method Cache Analysis Benedikt Huber1, Stefan Hepp1, Martin Schoeberl2 1 Vienna University of Technology 2 Technical University

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

Page 25: Scope-based Method Cache Analysis - Ulm...Scope-based Method Cache Analysis Benedikt Huber1, Stefan Hepp1, Martin Schoeberl2 1 Vienna University of Technology 2 Technical University

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

Page 26: Scope-based Method Cache Analysis - Ulm...Scope-based Method Cache Analysis Benedikt Huber1, Stefan Hepp1, Martin Schoeberl2 1 Vienna University of Technology 2 Technical University

Evaluation

Results for a 1 kB 8-way LRU set-associative cache

Page 27: Scope-based Method Cache Analysis - Ulm...Scope-based Method Cache Analysis Benedikt Huber1, Stefan Hepp1, Martin Schoeberl2 1 Vienna University of Technology 2 Technical University

Evaluation

Results for a 1 kB method cache

Page 28: Scope-based Method Cache Analysis - Ulm...Scope-based Method Cache Analysis Benedikt Huber1, Stefan Hepp1, Martin Schoeberl2 1 Vienna University of Technology 2 Technical University

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/