Ger Archie Di Memorie Cache
Ger Archie Di Memorie Cache
Ger Archie Di Memorie Cache
"#/)0'1)%
2#13'0+00*#)%&+45'%+5)6"#)0"#'
)7)7%898:;8988
!"#$%&'&&(")*+',-%*.-)/0")&0"%
121341211
!"#$#%&'"()'(*"*+#'$("(%$%&"
!"#$%&'()*+,-..+&/-"*)0)
-()*+,-..+%$-"*)0)120)3),%).
5'")"#$%'*+%*6'60"%)
! 5%$3$))&6 .- *%+7%&33& -+- &44$'$ & 0.00$ 2$ ).$ ()0%.,(+-( $ & 0.00( (
).+( '&0( 4+-0$3*+%&-$&3$-0$ 4+- 2& )0$))& *%+8&8(2(01
! 9+2.,(+-$6 .-& 7$%&%4:(& '( 3$3+%(&6 4+-)()0$ (- .- (-)($3$ '( 2(#$22( '(
3$3+%(&; 4(&)4.-+ 4&%&00$%(,,&0+ '& .-& '(#$%)& #$2+4(01 $ '(3$-)(+-$
! " *&%(01 '( 4&*&4(01; 2$ 3$3+%($ *(< #$2+4( :&--+ .- 4+)0+ *(< $2$#&0+
*$% )(-7+2+ 8(0 '( /.$22$ *(< 2$-0$
!"#$%&'&&(")*+',-%*'-)./")&/"%
Struttura fondamentale della gerarchia
5'")"#$%'*+%*6'60"%)
della memoria
Al4(&5"-*5-"-&6-((+&6)*.+07+&6+((+&8!9&
crescere della distanza dalla CPU
6)3)02)*5-&)(&5#*.#:&3+&+23-0.+&(+&
cresce anche il costo e la capacità di
5+;+5).<&6)&3-3#")77+7)#0-
memorizzazione.
La gerarchia può
consistere di più livelli, ma
in ogni istante di tempo i
dati sono copiati solamente
tra ciascuna coppia di
livelli adiacenti, per cui ci
si può concentrare su due
soli livelli.
!"#$%&'&&(")*+',-%*'-)./")&/"%
5'")"#$%'*+%*6'60"%)
! =&>3$3+%(&>4$-0%&2$>A 4&%&00$%(,,&0&>'&>'(3$-)(+-(>3+20+>3&77(+%(>
'$22&>3$3+%(&>(-0$%-&>&22&>?5@;>3&>4+->0$3*(>'(>&44$))+>*(<>$2$#&0(B>C
&44$))(8(2$>(->3+'+>'(%$00+>0%&3(0$>(-'(%(,,(B>
= >-)&*)*.-3)&+..2+()&20&()?-((#&6)&3-3#")-&5+5@-&A&*.+.#&)0*-").#&."+&8!9&-&
3-3#")-&5-0."+()&
! =$>3$3+%($>)$4+-'&%($>)+-+>&'>&20&>4&*&4(01;>8&))(>4+)0(>$>-+->#+2&0(2(>
!"#$%&'&&(")*+',-%*'-)./")&/"%
7"%8#%9%0*+%*-0#)-%&:
!"#$%&'&&(")*+',-%*'-)./")&/"%
!"#$#%&'$ )'(*"*+#'$ "(,#'-%','+()'(.+%$.'/0
! D2>*%(-4(*(+>'(>2+4&2(01>#($-$>)E%.00&0+>)0%.00.%&-'+>2&>3$3+%(&>(->3+'+>
7$%&%4:(4+>
! F$2+4(01
< ='>%?%@+5"1+A%B'>%?%@'1',)%)5%B#"1+$$"#+A%B'>%?%1"$0"$)
! G(3$-)(+-$
< ='>%?%4#),&+A%B'>%?%5",0),)%&)5%B#"1+$$"#+A%/+,"%1"$0"$)
! @->2(#$22+>'(>3$3+%(&>*(<>#(4(-+>&2>*%+4$))+%$>4+-0($-$>.->)+00+(-)($3$>
'(>'&0(>3$3+%(,,&0(>(->+7-(>2(#$22+>)+00+)0&-0$>$>0.00(>(>'&0(>)(>0%+#&-+>-$2>
2(#$22+>*(<>8&))+
!"#$%&'&&(")*+',-%*'-)./")&/"%
;'<%8%=%08% >?@
= I). "+.- J$"-F2-07+ 6) @).LD $"+7)#0- 6-H() +55-**) +((+ 3-3#")+ 0-) F2+()
(K)0$#"3+7)#0- ")5@)-*.+ A *.+.+ ."#?+.+ 0-( ()?-((# *2;-")#"- 6) 3-3#")+
= M)** "+.- J$"-F2-07+ 6) 3)**LD $"+7)#0- 6-H() +55-**) +((+ 3-3#")+ 0-) F2+()
(K)0$#"3+7)#0- ")5@)-*.+ >O> A *.+.+ ."#?+.+ 0-( ()?-((# *2;-")#"- 6) 3-3#")+ JP Q
I).R+.-L
!"#$%&'&&(")*+',-%*'-)./")&/"%
;'<%8%=%08% >??@
!"#$%&'&&(")*+',-%*'-)./")&/"%
;'<%8%=%08% >???@
!"#$%&'&&(")*+',-%*'-)./")&/"%
A)#$'
!"#$%&'&&(")*+',-%*'-)./")&/"%
A)#$'
! 7+%.-/?@($$.1
! :;30(/3,- <)&33& .#))( $#$&'0( 3&''0/%&-.# ,-(;/%#30103( )&3(60&-# -#))( 3(38#
! A,22B?C00&-+(/+4.
! =>-0 <)&33& %,? #//#'# 3&))&3(2& 0-;+,()/0(/0 )&3(60&-# .#))( 3(38#
! @#';'03#'3('# ,-;<)&33& -#))( 3(38#;5 -#3#//('0& 3#'3(')& 0-;2,22# )#;)0-## .#))(
3(38#
! A(;'03#'3( /#+,(-60()# 5 2'&%%& )#-2( BC;'03#'3( 0-;%('())#)& D/&),60&-# $&)2&;
3&/2&/(
! D./?C00&-+(/+4.
! 7&),60&-# 0-2#'$#.0(;2'( .0'#32;$(%%#.;#;1,))E;(//&30(209#
! F0(/3,- <)&33& .#))( $#$&'0( 8(;(;.0/%&/060&-# ,-;-,$#'& 10//& DCGHI;.0;
)&3(60&-0 0-;3(38#;
!"#$%&'&&(")*+',-%*'-)./")&/"%
;%"'#&*B)99%8,
!"#$%&'&&(")*+',-%*'-)./")&/"%
;%"'#&*B)99%8,
!"#$%&'&&(")*+',-%*'-)./")&/"%
C(--D )EE0#%)&%F'
!"#$%&'&&(")*+',-%*'-)./")&/"%
G'&*!EE0#%)&%F'*B)99%8,
!"#$%&'&&(")*+',-%*'-)./")&/"%
;%"'#&*B)99'+*A)#$'
! "))+4(& .-& )+2& 2+4&,(+-$ '$22& 4&4:$ & +7-( *&%+2& '$22& 3$3+%(&
'$E(-$-'+ .-& 4+%%()*+-'$-,& 0%& 2K(-'(%(,,+ (- 3$3+%(& '$22& *&%+2& $ 2&
2+4&,(+-$ -$22& 4&4:$
!"#$%&'&&(")*+',-%*'-)./")&/"%
;%"'#&*B)99'+*A)#$'
! 9$ (2 -.3$%+ '( 82+44:( -$22& 4&4:$ A .-& *+0$-,& '( L; 2& *+)(,(+-$
4+%%()*+-'$-0$ '$22& *&%+2& (- 4&4:$ A '&0& '&( 2+7LM-.3$%+ $2$3$-0(
-$22& 4&4:$N 8(0) 3$-+ )(7-(E(4&0(#( '$22K(-'(%(,,+ (- 3$3+%(& *%(-4(*&2$B
! O)$3*(+6
= >23-"# 6) -(-3-0.) 0-((+ 5+5@-D T
= B). ;-" )06)")77+"- 20+ (#5+7)#0- 6-((+ 5+5@-D (#HUJTLVW
= X06)")77# 6-((+ ;+"#(+ 6) 3-3#")+V YPPP YPYPY YYPY YPYY
= !#*)7)#0- )0 5+5@-D PYY JZL
!"#$%&'&&(")*+',-%*'-)./")&/"%
!"##$%&"'()'*+,-#+,$'($#$**$,$',.)."#$+,
),$',/+/0),
Corrispondenza tra indirizzi in
memoria e in cache
I blocchi di memoria con indirizzo
Problema: ad una posizione in
00001, 01001, 10001, 11001
cache hanno
sono gli
associate
ultimi logpiù
2 8=3 parole di
bit uguali
memoria.
→ mappati nello stesso blocco
Come è possibile sapere se il dato
presente nella cache corrisponde
effetivamente alla parola richiesta?
!"#$%&'&&(")*+',-%*'-)./")&/"%
A)69% +'--) #)#$'
!"#$%&'&&(")*+',-%*'-)./")&/"%
A)69% +'--) #)#$'
!"#$%&'&&(")*+',-%*'-)./")&/"%
A)69% +'--) #)#$'
! O)$3*(+6
!"#$%&'&&(")*+',-%*'-)./")&/"%
1*H I0"+*;%"'#&*B)99'+*A)#$'
!"#$%&'&&(")*+',-%*'-)./")&/"%
.E'69%0
H0 M?JH1 M?GH?K?JGHIJ#K)KHLL?K?OL
!"#$%&'&&(")*+',-%*'-)./")&/"%
B)99)&(")*+%*(8*%8+%"%==0
J)06)")77#&6-(&,(#55#L&3#62(#&J023-"#&6)&,(#55@)&0-((+&5+5@-L
1200 22
= 75 𝑚𝑜𝑑 64
16
!"#$%&'&&(")*+',-%*'-)./")&/"%
;%6'8E%08'*+'-*/-0##0*+%*#)#$'
! =&>'(3$-)(+-$>'$2>82+44+>'(>4&4:$>A>(->)0%$00&>%$2&,(+-$>4+->2&>
E%$/.$-,&>'(>3())B
!"#$%&'&&(")*+',-%*'-)./")&/"%
G#'-&)*+'--)*+%6'8E%08'*+'-*/-0##0*
! R'D)7<+),*+7$'2+3'$,<$#,+4,E43113,<$#7$..$,*+,2>#&..)#$,4),
431)4+.F,2<)(+)4$S,T09,
= ,(#55@)&6)&H"#**+&6)3-0*)#0-&5#3;#".+0#&3+HH)#")&3)**&;-0+(.[\D&
< ? ,+1+$$)#'"%B'>%0+/B"%B+#%0#)$.+#'#+%'5%65"11"%
= *-&(+&6)3-0*)#0-&6-(&,(#55#&A ."#;;#&H"#**+&")*;-..#&+((+&6)3-0*)#0-&6-((+&
5+5@-:&)(&3)**&"+.-&+23-0.+&
< -5%,*/+#"%&'%65"113'%,+55)%1)13+%? ',$*..'1'+,0+%
\&MX]]&!'>4^_`&V&6)$$-"-07+&."+&)(&.-3;#&6)&+55-**#&+(&()?-((#&)0$-")#"-&-&)(&.-3;#&6)&
+55-**#&+((+&5+5@-
!"#$%&'&&(")*+',-%*'-)./")&/"%
A)#$'*E'&4)EE0#%)&%F'
! H,E4311-+,)<<)#.$'$'.+,)44),1)1-$,23'3,#);;#&<<).+,+',2$.,
! +',&'),1)1-$,2$.,)2231+).+:$,)*,6 :+$,B6UV)M,2$.,)2231+).+:$C,
3;'+,2$.,#);;#&<<),6 E4311-+,
! 3;'+,+'*+#+((3,*+,7$73#+),13##+2<3'*$,)*,&',&'+13,2$.,*$44),
1)1-$,B)11$223,*+#$..3,.#)7+.$,+'*+1$C,$,<&3W,$22$#$,32<+.).3,+',
&',E43113,%&)4&'%&$,)<<)#.$'$'.$,),%&$4,2$.,
! 2.)E+4+.3,+4,2$.S,<$#,*$.$#7+')#$,2$,&',1$#.3,+'*+#+((3,X <#$2$'.$,
+',&',E43113,*$4,2$.,X '$1$22)#+3,13'>#3'.)#$,+',<)#)44$43,+,.); *+,
.&..+,+,E4311-+,
!"#$%&'&&(")*+',-%*'-)./")&/"%
A)#$'*J4K)D*G'&*!EE0#%)&%F'*
Cache set-associativa a 4 vie
L’implementazione richiede tag indice offset
– 4 comparatori 31 30 12 11 10 9 8 3210
– 1 multiplexer 4-to-1 22 8
viene selezionato 1
2
uno dei 256 set 253
254
I 4 tag nel set 255
22 32
sono confrontati in
parallelo
Il blocco viene
selezionato sulla
base del risultato
4-to-1 multiplexor
dei confronti
Hit Data
!"#$%&'&&(")*+',-%*'-)./")&/"%
GF)8&),,%*+'--)*#)#$'*E'&*)EE0#%)&%F'*
! 8)1-$,6UV)M,2$.,)2231+).+:$,),13'>#3'.3,13',1)1-$,)*,)11$223,
*+#$..39,
= > 5#3;+"+.#")&)0?-5-&6)&P&
= 2(.-")#"-&").+"6#&$#"0).#&6+(&32(.);(-a-"&
= )(&,(#55#&A 6)*;#0),)(-&6#;#&(+&6-5)*)#0-&I).CM)**&-&(+&*-(-7)#0-&6-(&*-.&
! H',&'),1)1-$,)*,)11$223,*+#$..3S,+4,E43113,X *+2<3'+E+4$,<#+7),
*$44),*$1+2+3'$,Y+.5T+22,
!"#$%&'&&(")*+',-%*'-)./")&/"%
A08<"08&0*&")*-'*&'#8%#$'*+%*%8+%"%==)6'8&0*
Confronto tra le tecniche di indirizzamento
Set associative:
Direct mapped: il blocco 12 può
Fully associative:
il blocco 12 può essere essere disposto
il blocco 12 può
disposto solo sul blocco ovunque nel set 0
essere disposto
4 (12 mod 8) (12 mod 4)
ovunque
Blocco 01234567 01234567
Blocco 0 1 2 3 4 5 6 7 Blocco
ricerca
Blocco 00000000001111111111222222222233
01234567890123456789012345678901
F. Tortorella © 2007
Calcolatori Elettronici II
Università degli Studi
Cache - 21 di Cassino
!"#$%&'&&(")*+',-%*'-)./")&/"%
;%6'8E%08'*+'-*&), '*)EE0#%)&%F%&:
Dimensione del tag e associatività
• Aumentando il grado di associatività
– Aumenta il numero dei comparatori ed il numero di bit per il tag
• Esempio
– Cache con 4K blocchi, blocco di 4 parole, indirizzo a 32 bit
– r = log2(4*4)=4 → n-r = (32-4) = 28 bit per tag e indice
– Cache ad indirizzamento diretto
• s = log2(4K) = 12
• Bit di tag totali = (28-12)*4K = 64K
– Cache set-associativa a 2 vie
• s = log2(4K/2) = 11
• Bit di tag totali = (28-11)*2*2K = 68K
– Cache set-associativa a 4 vie
• s = log2(4K/4) = 10
• Bit di tag totali = (28-10)*4*1K = 72K
– Cache completamente associativa
• s=0
• Bit di tag totali = 28*4K*1 = 112K
AAC - Valeria Cardellini, A.A. 2007/08 42
!"#$%&'&&(")*+',-%*'-)./")&/"%
?8#"'6'8&0*+'--L)EE0#%)&%F%&:
! =#+'1+<)4$,:)'.);;+3,
= b)3)027)#0-&6-(&3)**&"+.-&
! =#+'1+<)4+,2:)'.);;+
= M+HH)#"&5#*.#&)3;(-3-0.+.)?#
= X05"-3-0.#&6-((K@).&.)3-&
! A),21$4.),.#),1)1-$,)*,+'*+#+(()7$'.3,*+#$..3S,2$.U )2231+).+:),$,
137<4$.)7$'.$,)2231+).+:),*+<$'*$,*)4,132.3,*$44D)2231+).+:+.F,
#+2<$..3,)44),#+*&(+3'$,*$4,7+22,#).$,
!"#$%&'&&(")*+',-%*'-)./")&/"%
5'E&%08'*+'--)*#)#$'
4 decisioni da
prendere
CPU CACHE MEM
F. Tortorella © 2007
Calcolatori Elettronici II
Università degli Studi
Cache - 2
!"#$%&'&&(")*+',-%*'-)./")&/"% di Cassino
!-,0"%&6%*9'"*-)*E0E&%&(=%08'*+%*/-0##$%
! 6$44),1)1-$,)*,)11$223,*+#$..39,2$,+4,E43113,*+,7$73#+),X
7)<<).3,+',&'),4+'$),*+,1)1-$,;+)W,311&<).),B13'>4+1. 7+22CS,2+,
$4+7+'),+4,13'.$'&.3,<#$1$*$'.$,*$44),4+'$),$,2+,#+7<+)((),13',+4,
'&3:3,E43113,
! Z&)4$,E43113,232.+.&+#$,+',1)23,*+,B1)<)1+.MC,7+22,'$44$,1)1-$,
2$.U 3,>&44MU )2231+).+:$[
= X0&5+*#&6)&5+5@-&5#3;(-.+3-0.-&+**#5)+.)?+D&#H0)&,(#55#&A 20&;#.-07)+(-&
5+06)6+.#&;-"&(+&*#*.).27)#0-&
= X0&5+*#&6)&5+5@-&*-.c+**#5)+.)?+&+&> ?)-D&,)*#H0+&*5-H()-"-&."+&H()&> ,(#55@)&
6-(&*-.&
!"#$%&'&&(")*+',-%*'-)./")&/"%
!-,0"%&6%*9'"*-)*E0E&%&(=%08'*+%*/-0##$%
! =34+.+1),*+,232.+.&(+3'$,\)'*37 Q ]5-(.+&5+*2+(-&
! =34+.+1),*+,232.+.&(+3'$,"+#2.,H',"+#2.,]&.,B"H"]C,
= ])&+;;"#**)3+&(+&*."+.-H)+&^R9&*-(-7)#0+06#&)(&,(#55#&;)2N&?-55@)#&+07)5@-d&
F2-((#&0#0&2*+.#&6+&;)2N&.-3;#&
!"#$%&'&&(")*+',-%*'-)./")&/"%
5'E&%08'*+'--)*#)#$'
4 decisioni da
prendere
CPU CACHE MEM
F. Tortorella © 2007
Calcolatori Elettronici II
Università degli Studi
Cache - 2
!"#$%&'&&(")*+',-%*'-)./")&/"% di Cassino
5'E&%08'*+'%*6%EE*%8*-'&&(")*
! ^$,&',E43113,'3',X <#$2$'.$,'$44),1)1-$,E+23;'),7$..$#$,+',
2.)443,4D+'.$#),8=R
! H',;$'$#)4$,)4,:$#+>+1)#2+,*+,&',7+22,'$44),1)1-$,*$44$,+2.#&(+3'+,
23'3,'$1$22)#+,+,2$;&$'.+,<)22+9,
P% X0?)+"-&!8&Q Z&J2*5).+&6-((+&4^9L&+((+&3-3#")+&
U% ^-..2"+&6+((+&3-3#")+&
W% ]5")..2"+&0-((+&5+5@-&J6+.#:&.+H -&,).&6)&?+()6).<L&
Z% R)+??)+"-&(K-*-527)#0-&6-((K)*."27)#0-&5@-&@+&5+2*+.#&)(&3)**%&
!"#$%&'&&(")*+',-%*'-)./")&/"%
A)#$'*4 !##'EE0*%8*E#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&
!"#$%&'&&(")*+',-%*'-)./")&/"%
A)#$'M*K"%&'4&$"0(,$ #08*K"%&' /(<<'"*
! W%(0$>8.EE$% (-0$%*+)0+>0%&>2&>4&4:$>$>2&>3$3+%(&>'(>2(#$22+>(-E$%(+%$>
Saturazione del Write Buffer
= X(&;"#5-**#"-&*5")?-&)&6+.)&*)+&0-((+&5+5@-&-&0-(&f").- ,2$$-"&
Cache L2
Processor DRAM
Cache
Write Buffer
!"#$%&'&&(")*+',-%*'-)./")&/"%
I"%&'*6%EE
!"#$%&'&&(")*+',-%*'-)./")&/"%
OEE'"F)=%08'*>?@
! =& E%$/.$-,& '( 3()) 0+%-& & 4%$)4$%$ )$ 2& '(3$-)(+-$ '$( 82+44:(
'(#$-0& 0%+**+ 7%&-'$ %()*$00+ &22& '(3$-)(+-$ '$22& 4&4:$
! [.(-'( ( 82+44:( #$-7+-+ )4&%(4&0( '&22& 4&4:$ *%(3& &-4+%& 4:$ 3+20(
'&0( (- $))( 4+-0$-.0( )(&-+ )0&0( .0(2(,,&0(
!"#$%&'&&(")*+',-%*'-)./")&/"%
OEE'"F)=%08'*>??@
! D-+20%$;>4%$)4$>&-4:$>(2>4+)0+>'(>.-&>3())6>2&>*$-&2(01>'(>.-&>3())>A>
'$0$%3(-&0&>'&2>0$3*+>-$4$))&%(+>&>*%$2$#&%$>.->82+44+>'&2>2(#$22+>
)+00+)0&-0$>$>&>)4%(#$%2+>-$22&>4&4:$
! D2>0$3*+>*$%>*%$2$#&%$>.->82+44+>A>'&0+>'&22&>)+33&>0%&>2&>2&0$-,&>*$%>
+00$-$%$>2&>*%(3&>*&%+2&>'$2>82+44+>$>(2>0$3*+>'(>0%&)E$%(3$-0+>'$2>%$)0+>
'$2>82+44+
!"#$%&'&&(")*+',-%*'-)./")&/"%