Professional Documents
Culture Documents
Set-Associative Caches
Pitfalls and Solutions
saarland
university
computer science
saarland
university
Context computer science
Preemptive scheduling
Cache related preemption delay (CRPD):
I Impact of preemption on the cache content
I Overall cost of additional reloads due to preemption
T1
T2
= CRPD
= Task Activation
Burguière, Reineke, Altmeyer CRPD for set-associative caches WCET, Dublin 2009 2 / 13
saarland
university
CRPD computation for set-associative caches computer science
CRPD computation:
I Useful Cache Blocks (UCB)
I Evicting Cache Blocks (ECB)
CRPD for set-associative caches:
⇒ Pitfalls:
I LRU: CRPD not bounded by the number of ECBs
I FIFO and PLRU: CRPD not bounded
Burguière, Reineke, Altmeyer CRPD for set-associative caches WCET, Dublin 2009 3 / 13
saarland
university
Useful Cache Block - [Lee et al., 1996] computer science
= hit
= miss
P
A B D C B A C
Cache Content:
[A, B, C, D]
Burguière, Reineke, Altmeyer CRPD for set-associative caches WCET, Dublin 2009 4 / 13
saarland
university
Useful Cache Block - [Lee et al., 1996] computer science
= hit
= miss
P
A B D C B A C
Cache Content:
[A, B, C, D]
Burguière, Reineke, Altmeyer CRPD for set-associative caches WCET, Dublin 2009 4 / 13
saarland
university
Useful Cache Block - [Lee et al., 1996] computer science
= hit
= miss
P
A B D C B A C
Cache Content:
[A, B, C, D]
c
X
CRPDLRU = CRPDLRU (s)
s=1
LRU n = associativity
CRPDUCB (s) = BRT · min(|UCB(s)|, n) BRT = Block Reload Time
Burguière, Reineke, Altmeyer CRPD for set-associative caches WCET, Dublin 2009 4 / 13
saarland
university
Evicting Cache Blocks computer science
A B C B A C
Burguière, Reineke, Altmeyer CRPD for set-associative caches WCET, Dublin 2009 5 / 13
saarland
university
Evicting Cache Blocks computer science
A B C B A C
LRU ?
CRPDECB (s) = BRT · min(|ECB(s)|, n)
Burguière, Reineke, Altmeyer CRPD for set-associative caches WCET, Dublin 2009 5 / 13
saarland
university
CRPD computation for LRU using ECB: Pitfall computer science
0x08
0x09
0x0a
0x0b
8 9 a b
[b, a, 9, 8] [8, b, a, 9] [9, 8, b, a] [a, 9, 8, b] [b, a, 9, 8] 0 misses
Burguière, Reineke, Altmeyer CRPD for set-associative caches WCET, Dublin 2009 6 / 13
saarland
university
CRPD computation for LRU using ECB: Pitfall computer science
0x08
0x09
0x0a
0x0b
8 9 a b
[b, a, 9, 8] [8, b, a, 9] [9, 8, b, a] [a, 9, 8, b] [b, a, 9, 8] 0 misses
ECBs
= {e}
8∗ 9∗ a∗ b∗
[e, b, a, 9] [8, e, b, a] [9, 8, e, b] [a, 9, 8, e] [b, a, 9, 8] 4 misses
|UCB(s)| = 4
|ECB(s)| = 1
n=4
number of additional misses= 4
Burguière, Reineke, Altmeyer CRPD for set-associative caches WCET, Dublin 2009 6 / 13
saarland
university
LRU: new computation of CRPD using ECB computer science
Burguière, Reineke, Altmeyer CRPD for set-associative caches WCET, Dublin 2009 7 / 13
saarland
university
CRPD for FIFO: Pitfalls computer science
a e∗ b c∗ e
[b, a] [b, a] [e, b] [e, b] [c, e] [c, e] 2 misses
Burguière, Reineke, Altmeyer CRPD for set-associative caches WCET, Dublin 2009 8 / 13
saarland
university
CRPD for FIFO: Pitfalls computer science
a e∗ b c∗ e
[b, a] [b, a] [e, b] [e, b] [c, e] [c, e] 2 misses
ECBs
= {x} a∗ e∗ b∗ c∗ e∗
[x, b] [a, x] [e, a] [b, e] [c, b] [e, c] 5 misses
|UCB(s)| = 2
|ECB(s)| = 1
n=2
But: number of additional misses= 3
Burguière, Reineke, Altmeyer CRPD for set-associative caches WCET, Dublin 2009 8 / 13
saarland
university
Definition – Relative Miss-Competitiveness computer science
Notation
mP (p, s) = number of misses that policy P incurs on
access sequence s ∈ M ∗ starting in state p
mP (p, s) ≤ k · mQ (q, s) + c
Burguière, Reineke, Altmeyer CRPD for set-associative caches WCET, Dublin 2009 9 / 13
saarland
university
Definition – Relative Miss-Competitiveness computer science
Notation
mP (p, s) = number of misses that policy P incurs on
access sequence s ∈ M ∗ starting in state p
mP (p, s) ≤ k · mQ (q, s) + c
Burguière, Reineke, Altmeyer CRPD for set-associative caches WCET, Dublin 2009 9 / 13
saarland
university
A sequence of memory accesses computer science
Notation:
I m = number of misses
I m = number of misses in the case of preemption
mpre = 4 mpost = 2
Burguière, Reineke, Altmeyer CRPD for set-associative caches WCET, Dublin 2009 10 / 13
saarland
university
A sequence of memory accesses computer science
Notation:
I m = number of misses
I m = number of misses in the case of preemption
mpre = 4 mpost = 2
Burguière, Reineke, Altmeyer CRPD for set-associative caches WCET, Dublin 2009 10 / 13
saarland
university
A sequence of memory accesses computer science
Notation:
I m = number of misses
I m = number of misses in the case of preemption
mpre = 4 mpost = 2
Burguière, Reineke, Altmeyer CRPD for set-associative caches WCET, Dublin 2009 10 / 13
saarland
university
A sequence of memory accesses computer science
Notation:
I m = number of misses
I m = number of misses in the case of preemption
mpre = 4 mpost = 2
Burguière, Reineke, Altmeyer CRPD for set-associative caches WCET, Dublin 2009 10 / 13
saarland
university
A sequence of memory accesses computer science
Notation:
I m = number of misses
I m = number of misses in the case of preemption
mpre = 4 mpost = 2
Burguière, Reineke, Altmeyer CRPD for set-associative caches WCET, Dublin 2009 10 / 13
saarland
university
Relative Competitiveness – Application computer science
Burguière, Reineke, Altmeyer CRPD for set-associative caches WCET, Dublin 2009 11 / 13
saarland
university
Conclusions computer science
Pitfalls Solutions
LRU: LRU:
|ECBs| is not an |ECBs| = 0
upper-bound ⇒ the set is not used
FIFO and PLRU: FIFO and PLRU:
|UCBs|, |ECBs| and n using relative
do not bound the number competitiveness
of additional misses and LRU bounds
Burguière, Reineke, Altmeyer CRPD for set-associative caches WCET, Dublin 2009 12 / 13
saarland
university
Further reading computer science
Altmeyer, S. and Burguière, C. (2009).
A New Notion of Useful Cache Block to Improve the Bounds of Cache-Related Preemption
Delay.
In ECRTS ’09 pp. 109–118, IEEE Computer Society.
Lee, C.-G., Hahn, J., Min, S. L., Ha, R., Hong, S., Park, C. Y., Lee, M. and Kim, C. S.
(1996).
Analysis of cache-related preemption delay in fixed-priority preemptive scheduling.
In RTSS’96 p. 264, IEEE Computer Society.
Negi, H. S., Mitra, T. and Roychoudhury, A. (2003).
Accurate estimation of cache-related preemption delay.
In CODES+ISSS’03 ACM.
Reineke, J. (2008).
Caches in WCET Analysis.
PhD thesis, Universität des Saarlandes, Saarbrücken.
Staschulat, J. and Ernst, R. (2007).
Scalable precision cache analysis for real-time software.
ACM TECS 6, 25.
Tan, Y. and Mooney, V. (2004).
Integrated intra- and inter-task cache analysis for preemptive multi-tasking real-time
systems.
In SCOPES’04 pp. 182–199,.
Tomiyama, H. and Dutt, N. D. (2000).
Program
Burgui pathAltmeyer
ère, Reineke, analysis
to bound cache-related
CRPD preemption
for set-associative caches delay in preemptive
WCET, Dublinreal-time
2009 13 / 13
saarland
university
Upper-bound on the CRPD - direct-mapped caches computer science
using UCB and ECB [Negi et al., 2003, Tan and Mooney, 2004]:
Burguière, Reineke, Altmeyer CRPD for set-associative caches WCET, Dublin 2009 13 / 13
saarland
university
Relative Competitiveness – Example computer science
mpre = 4 mpost = 2
(t)
m(t) = m(t)
pre + mpost
LRU(s) LRU(s) LRU(s)
≤ k · mpre + c + k · (mpost + mCRPD ) + c
LRU(s) LRU(s) LRU(s)
= (k · (mpre + mpost ) + c) + (k · mCRPD + c)
LRU(s)
= (k · m LRU(s) + c) + (k · mCRPD + c).
Burguière, Reineke, Altmeyer CRPD for set-associative caches WCET, Dublin 2009 13 / 13
saarland
university
Relative Competitiveness – Application computer science
I Example (n=8):
LRU(4)
m PLRU(8) ≤ m LRU(4) + mCRPD
n n LRU(r )
m FIFO(n) ≤ ( · m LRU(r ) + r ) + ( · mCRPD + r )
n−r +1 n−r +1
I Example (n=8,r=5):
LRU(5)
m FIFO(8) ≤ (2 · m LRU(5) + 5) + (2 · mCRPD + 5)
Burguière, Reineke, Altmeyer CRPD for set-associative caches WCET, Dublin 2009 13 / 13
saarland
university
CRPD for PLRU: Pitfalls computer science
1 d 0 b 1 c 0 b 1 a 1 d 0
1 1 1 0 0 0 0 1 0 1 1 1 1 0 0 misses
a b c d a b c d a b c d a b c d a b c d a b c d a b c d
ECBs
= {x, y} 1 d* 0 b* 1 c* 0 b 1 a* 0 d* 1
0 0 0 1 1 1 1 0 1 0 1 1 0 1 5 misses
a y c x a y d x b y d x b y d c b y d c b y a c b d a c
|UCB(s)| = 4
|ECB(s)| = 2
n=4
But: number of additional misses= 5
Burguière, Reineke, Altmeyer CRPD for set-associative caches WCET, Dublin 2009 13 / 13