cachequery learning replacement policies from hardware
play

CacheQuery: Learning Replacement Policies from Hardware Caches - PowerPoint PPT Presentation

CacheQuery: Learning Replacement Policies from Hardware Caches Pepe Vila, Pierre Ganty, Marco Guarnieri, and Boris Kpf IMDEA Software Institute Microsoft Research PLDI 2020 Synthesis II Caches: those little although faster friends...


  1. CacheQuery: Learning Replacement Policies from Hardware Caches Pepe Vila, Pierre Ganty, Marco Guarnieri, and Boris Köpf IMDEA Software Institute Microsoft Research PLDI 2020 Synthesis II

  2. Caches: those little although faster friends... Memory block 0 CPU 1 256KBs Cache memory address 2 Tag Data 3 Associativity ... Set 0 Tag Set Offset 10 6 = Set 1 Memory partitioned in memory blocks (64 bytes = 2 6 ) ● Cache partitioned in equally sized cache sets (1024 = 2 10 = 256KB / (64 * 4) ● ● Cache sets have capacity for N cache lines (also known as ways or associativity ) 2

  3. Caches: those little although faster friends... Memory block 0 CPU 1 256KBs Cache memory address 2 Tag Data 3 Associativity ... Set 0 Tag Set Offset 10 6 = Set 1 Memory partitioned in memory blocks (64 bytes = 2 6 ) ● Cache partitioned in equally sized cache sets (1024 = 2 10 = 256KB / (64 * 4) ● ● Cache sets have capacity for N cache lines (also known as ways or associativity ) 3

  4. Caches: those little although faster friends... Memory block 0 CPU 1 256KBs Cache memory address 2 Tag Data 3 Associativity ... Set 0 Tag Set Offset 10 6 = Set 1 Memory partitioned in memory blocks (64 bytes = 2 6 ) ● Cache partitioned in equally sized cache sets (1024 = 2 10 = 256KB / (64 * 4) ● ● Cache sets have capacity for N cache lines (also known as ways or associativity ) 4

  5. Caches: those little although faster friends... Memory block 0 CPU 1 256KBs Cache memory address 2 Tag Data 3 Associativity ... Set 0 Tag Set Offset 10 6 = Set 1 HIT Memory partitioned in memory blocks (64 bytes = 2 6 ) ● Cache partitioned in equally sized cache sets (1024 = 2 10 = 256KB / (64 * 4) ● ● Cache sets have capacity for N cache lines (also known as ways or associativity ) 5

  6. Caches: those little although faster friends... Memory block 0 CPU 1 256KBs Cache memory address 2 Tag Data 3 Associativity ... Set 0 Tag Set Offset 64 bytes of data 10 6 = Set 1 HIT fast access time Memory partitioned in memory blocks (64 bytes = 2 6 ) ● Cache partitioned in equally sized cache sets (1024 = 2 10 = 256KB / (64 * 4) ● ● Cache sets have capacity for N cache lines (also known as ways or associativity ) 6

  7. Caches: those little although faster friends... Memory block 0 CPU 1 256KBs Cache memory address 2 Tag Data 3 Associativity ... Set 0 Tag Set Offset 10 6 = Set 1 Memory partitioned in memory blocks (64 bytes = 2 6 ) ● Cache partitioned in equally sized cache sets (1024 = 2 10 = 256KB / (64 * 4) ● ● Cache sets have capacity for N cache lines (also known as ways or associativity ) 7

  8. Caches: those little although faster friends... Memory block 0 CPU 1 256KBs Cache memory address 2 Tag Data 3 Associativity ... Set 0 Tag Set Offset 10 6 = Set 1 MISS Memory partitioned in memory blocks (64 bytes = 2 6 ) ● Cache partitioned in equally sized cache sets (1024 = 2 10 = 256KB / (64 * 4) ● ● Cache sets have capacity for N cache lines (also known as ways or associativity ) 8

  9. Caches: those little although faster friends... Memory block 0 CPU 1 256KBs Cache memory address 2 Tag Data 3 Associativity ... Set 0 Tag Set Offset 10 6 = Set 1 MISS replacement policy evicts one block Memory partitioned in memory blocks (64 bytes = 2 6 ) ● Cache partitioned in equally sized cache sets (1024 = 2 10 = 256KB / (64 * 4) ● ● Cache sets have capacity for N cache lines (also known as ways or associativity ) 9

  10. Caches: those little although faster friends... Memory block 0 CPU 1 256KBs Cache memory address 2 Tag Data slow access time 3 64 bytes of data Associativity ... Set 0 Tag Set Offset 10 6 = Set 1 MISS insert new block Memory partitioned in memory blocks (64 bytes = 2 6 ) ● Cache partitioned in equally sized cache sets (1024 = 2 10 = 256KB / (64 * 4) ● ● Cache sets have capacity for N cache lines (also known as ways or associativity ) 10

  11. Caches: their importance and impact 11 11

  12. Problem: cache as a black box MEMORY ADDRESSES TIME MEASUREMENTS f30 f40 f50 f30 15 16 14 4 BLACKBOX CACHE 12

  13. Our approach for learning replacement policies Template 4 3 2 1 Hardware interface Program synthesis Automata learning Policy abstraction A B C A f30 f40 f50 f30 h(0) h(1) m() A B C B f30 f40 f50 f40 H H M M 4c 4c 12c 12c _ _ 0 H H M H 4c 4c 12c 4c int missIdx (int[4] state) for(int i = 0; i < 4; i = i + 1) if(state[i] == 3) return i; Explanation 13

  14. CacheQuery: a hardware interface Template Program synthesis Automata learning Policy abstraction A B C A CacheQuery f30 f40 f50 f30 h(0) h(1) m() A B C B f30 f40 f50 f40 H H M M 4c 4c 12c 12c _ _ 0 H H M H 4c 4c 12c 4c int missIdx (int[4] state) for(int i = 0; i < 4; i = i + 1) if(state[i] == 3) return i; Explanation 14

  15. CacheQuery: a hardware interface 15 15

  16. Polca: a cache automaton abstraction Polca: a cache policy automaton abstraction Template Program synthesis Automata learning A B C A f30 f40 f50 f30 CacheQuery h(0) h(1) m() A B C B f30 f40 f50 f40 Polca H H M M 4c 4c 12c 12c _ _ 0 H H M H 4c 4c 12c 4c int missIdx (int[4] state) for(int i = 0; i < 4; i = i + 1) if(state[i] == 3) return i; Explanation 16

  17. Polca: a cache policy automaton abstraction keep track of content Polca = Mapper Abstract Concrete A B C A h(0) h(1) m() A B C B automaton automaton Replacement Cache policy management H H M M _ _ 0 H H M H Input: {A, B, C, … .} {h(0), h(1), ..., h(n-1), m()} Output: {_, 0, 1, … , n-1} {H, M} 17 17

  18. Caches: those little although faster friends... 18 18

  19. LearnLib: an automata learning framework Template Automata Learning Program synthesis A B C A f30 f40 f50 f30 CacheQuery h(0) h(1) m() A B C B f30 f40 f50 f40 Polca H H M M 4c 4c 12c 12c _ _ 0 H H M H 4c 4c 12c 4c int missIdx (int[4] state) for(int i = 0; i < 4; i = i + 1) if(state[i] == 3) return i; Explanation 19

  20. LearnLib: an automata learning framework LearnLib is an open source Java framework for automata learning developed at the TU Dortmund - ● https://learnlib.de/ Angluin’s L* algorithm has been extended to Mealy machines : ● Membership queries replaced by output queries ○ Equivalence queries approximated by test sequences for conformance testing ○ Reset sequence is bootstrapping problem, we solve it with Flush+Refill ○ WP-method: test sequence selection - given an upper bound on the number of states of the System Under Learning (SUL), guarantees equivalence 20 20

  21. Sketch: synthesizing programs as explanations Template Program synthesis Automata Learning A B C A f30 f40 f50 f30 CacheQuery h(0) h(1) m() A B C B f30 f40 f50 f40 Polca H H M M 4c 4c 12c 12c _ _ 0 H H M H 4c 4c 12c 4c int missIdx (int[4] state) for(int i = 0; i < 4; i = i + 1) if(state[i] == 3) return i; Explanation 21

  22. Sketch: synthesizing programs as explanations 22 22

  23. Sketch: synthesizing programs as explanations Domain knowledge or high-level view of a replacement policy: Each block has an associated age ● Promotion rule decides how the ages are updated upon a hit ● Replacement rule decides which block is evicted upon a miss ● Insertion rule decides the age of a new block ● We use it to “sketch” a template for replacement policies and encode the automaton’s output and transition functions as constraints! 23 23

  24. Sketch: synthesizing programs as explanations miss (state) :: States → States×Lines Lines idx = -1 hit (state, line) :: States×Lines → States state = normalize(state, idx) state = promote(state, line) idx = evict(state) state = normalize(state, line) state[idx] = insert(state, idx) return state state = normalize(state, idx) return ⟨ state, idx ⟩ 24 24

  25. Sketch: synthesizing programs as explanations miss (state) :: States → States×Lines Lines idx = -1 hit (state, line) :: States×Lines → States state = normalize(state, idx) state = promote(state, line) idx = evict(state) state = normalize(state, line) state[idx] = insert(state, idx) return state state = normalize(state, idx) return ⟨ state, idx ⟩ promote (state, pos) :: States×Lines → States States final = state if (??{boolExpr(state[pos])}) final[pos] = ??{natExpr(state[pos])} for(i in Lines) if(i != pos ∧ ??{boolExpr(state[pos], state[i])}) final[i] = ??{natExpr(state[i])} return final 25 25

  26. Results 26 26

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend