17
pages
English
Documents
Le téléchargement nécessite un accès à la bibliothèque YouScribe Tout savoir sur nos offres
17
pages
English
Documents
Le téléchargement nécessite un accès à la bibliothèque YouScribe Tout savoir sur nos offres
ECSE425Lecture20:
CacheBasics
H&PAppendixC
©2011Gross,Hayward,Arbel,Vu,Meyer
Textbookfigures©2007ElsevierScienceLastTime
• IntroducPontoMemoryHierarchy
• Whatarecaches?
• Whycache?
• FourQuesPons
– Q1:Blockplacement
©2011Gross,Hayward,Arbel,Vu,Meyer;
ECSE425,Fall2011,Lecture20 2©2007ElsevierScienceToday
• TwoQuesPons:
– Q1:Blockplacement
– Q2:BlockidenPfica on
©2011Gross,Hayward,Arbel,Vu,Meyer;
ECSE425,Fall2011,Lecture20 3©2007ElsevierScienceFourMemoryHierarchyQuesPons
MainmemoryisdividedintoblockseachconsisPng
ofseveraldataelements(e.g.bytes)
1. Blockplacement
– Wherecanablockbeplacedintheupperlevel?
2. BlockidenPfica on
– Howisablockfoundifitisintheupperlevel?
3. Blockreplacement
– Whichblockshouldbereplacedonamiss?
4. Writestrategy
– Whathappensonawrite?
©2011Gross,Haward,Arbel,Vu,Meyer;
ECSE425,Fall2011,Lecture19 4©2007ElsevierScienceQ1:BlockPlacement
• Fullyassocia ve
– Ablockcanappearanywhereinthecache
– Slowandcomplex,butthebesthitrate
• Directmappedcache
– Eachblockcanonlyappearinoneplaceinthecache
• Blockaddressmod#blocksincache
– Fastandsimple,butmoremisses
• Setassocia vecachesstrikeabalance
©2011Gross,Haward,Arbel,Vu,Meyer;
ECSE425,Fall2011,Lecture19 5©2007ElsevierScienceSetAssocia veCaches
• Ablockcanbeplacedinasetofplacesinthe
cache(calledways)
• First,mapablockontoaset
– Blockaddressmod#setsincache
• Theblockcanbeplacedanywhereinthatset
– nblocksinaset=>n-waysetassocia ve
©2011Gross,Haward,Arbel,Vu,Meyer;
ECSE425,Fall2011,Lecture19 6©2007ElsevierScienceBlockPlacement
C
f
M
©2011Gross,Haward,Arbel,Vu,Meyer;
ECSE425,Fall2011,Lecture19 7©2007ElsevierScienceGeneralizedAssocia vity
• Ingeneral,mblocksincache,nblocksinaset,s
setsincache
– m=s*n
• n-waysetassocia ve=> n>1ands>1
– fullyassocia ve=> n=mands=1(m-ways.a.)
– directmapped=>n=1ands=m(1-ways.a.)
• Mapping:setnumberiscalled“index”
• index=block#mods
©2011Gross,Haward,Arbel,Vu,Meyer;
ECSE425,Fall2011,Lecture19 8©2007ElsevierScienceRealCaches
• Mostprocessorcachestodayare
– Directmapped,orn-waysetassocia ve, n≤8
• Full-associa vity reservedforsmall,specialized
memories
– E.g.,Transla onLook-asideBuffer(TLB)
©2011Gross,Haward,Arbel,Vu,Meyer;
ECSE425,Fall2011,Lecture19 9©2007ElsevierScienceQ2:BlockIdenPfica on
• Cachesholdasubsetofblocksinmainmemory
– Manyblocksmaptooneorafewentriesincache
– Howisablockfoundifitisinthecache?
• Dividethememoryaddressintofields
• Blockaddress(higher-orderbits)
– Indicatestheblocknumberinmemorywewillaccess
• Blockoffset(lower-orderbits)
– Indicatesthedatawithinablockwewanttoretrieve
©2011Gross,Hayward,Arbel,Vu,Meyer;
ECSE425,Fall2011,Lecture20 10©2007ElsevierScience