




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
TheMemoryHierarchy
TodayStoragetechnologiesandtrendsLocalityofreferenceCachinginthememoryhierarchyRandom-AccessMemory(RAM)Random-AccessMemory(RAM)KeyfeaturesRAMistraditionallypackagedasachip.Basicstorageunitisnormallyacell(onebitpercell).MultipleRAMchipsformamemory.StaticRAM(SRAM)Eachcellstoresabitwithasix-transistorcircuit.Retainsvalueindefinitely,aslongasitiskeptpowered.Relativelyinsensitivetoelectricalnoise(EMI),radiation,etc.FasterandmoreexpensivethanDRAM.DynamicRAM(DRAM)Eachcellstoresbitwithacapacitor.Onetransistorisusedforaccess.Valuemustberefreshedevery10-100ms.Moresensitivetodisturbances(EMI,radiation,…)thanSRAM.SlowerandcheaperthanSRAM.SRAMvsDRAMSummaryConventionalDRAMOrganizationdxwDRAM:dwtotalbitsorganizedasdsupercellsofsizewbitscolsrows01230123Internalrowbuffer16x8DRAMchipaddrdatasupercell(2,1)2bits/8bits/Memorycontroller(to/fromCPU)ReadingDRAMSupercell(2,1)Step1(a):Rowaccessstrobe(RAS)selectsrow2.Step1(b):Row2copiedfromDRAMarraytorowbuffer.ColsRowsRAS=20123012Internalrowbuffer16x8DRAMchip3addrdata2/8/MemorycontrollerReadingDRAMSupercell(2,1)Step2(a):Columnaccessstrobe(CAS)selectscolumn1.Step2(b):Supercell(2,1)copiedfrombuffertodatalines,andeventuallybacktotheCPU.ColsRows01230123Internalrowbuffer16x8DRAMchipCAS=1addrdata2/8/Memorycontrollersupercell(2,1)supercell(2,1)ToCPUMemoryModules:supercell(i,j)64MBmemorymoduleconsistingofeight8Mx8DRAMsaddr(row=i,col=j)MemorycontrollerDRAM7DRAM00317815162324326339404748555664-bitdoublewordatmainmemoryaddressAbits0-7bits8-15bits16-23bits24-31bits32-39bits40-47bits48-55bits56-6364-bitdoubleword03178151623243263394047485556EnhancedDRAMsBasicDRAMcellhasnotchangedsinceitsinventionin1966.CommercializedbyIntelin1970.DRAMcoreswithbetterinterfacelogicandfasterI/O:SynchronousDRAM(SDRAM)UsesaconventionalclocksignalinsteadofasynchronouscontrolAllowsreuseoftherowaddresses(e.g.,RAS,CAS,CAS,CAS)Doubledata-ratesynchronousDRAM(DDRSDRAM)DoubleedgeclockingsendstwobitspercycleperpinDifferenttypesdistinguishedbysizeofsmallprefetchbuffer:DDR(2bits),DDR2(4bits),DDR3(8bits)By2010,standardformostserveranddesktopsystemsIntelCorei7supportsonlyDDR3SDRAMDDRDDR2vsDDR3NonvolatileMemoriesDRAMandSRAMarevolatilememoriesLoseinformationifpoweredoff.NonvolatilememoriesretainvalueevenifpoweredoffRead-onlymemory(ROM):programmedduringproductionProgrammableROM(PROM):canbeprogrammedonceEraseablePROM(EPROM):canbebulkerased(UV,X-Ray)ElectricallyeraseablePROM(EEPROM):electronicerasecapabilityFlashmemory:EEPROMswithpartial(sector)erasecapabilityWearsoutafterabout100,000erasings.UsesforNonvolatileMemoriesFirmwareprogramsstoredinaROM(BIOS,controllersfordisks,networkcards,graphicsaccelerators,securitysubsystems,…)Solidstatedisks(replacerotatingdisksinthumbdrives,smartphones,mp3players,tablets,laptops,…)DiskcachesTraditionalBusStructureConnecting
CPUandMemoryAbusisacollectionofparallelwiresthatcarryaddress,data,andcontrolsignals.Busesaretypicallysharedbymultipledevices.MainmemoryI/ObridgeBusinterfaceALURegisterfileCPUchipSystembusMemorybusMemoryReadTransaction(1)CPUplacesaddressAonthememorybus.
ALURegisterfileBusinterfaceA0AxMainmemoryI/Obridge%eaxLoadoperation:
movlA,%eaxMemoryReadTransaction(2)MainmemoryreadsAfromthememorybus,retrieveswordx,andplacesitonthebus.ALURegisterfileBusinterfacex0AxMainmemory%eaxI/ObridgeLoadoperation:
movlA,%eaxMemoryReadTransaction(3)CPUreadwordxfromthebusandcopiesitintoregister%eax.xALURegisterfileBusinterfacexMainmemory0A%eaxI/ObridgeLoadoperation:
movlA,%eaxMemoryWriteTransaction(1)CPUplacesaddressAonbus.Mainmemoryreadsitandwaitsforthecorrespondingdatawordtoarrive.yALURegisterfileBusinterfaceAMainmemory0A%eaxI/ObridgeStoreoperation:
movl%eax,AMemoryWriteTransaction(2)CPUplacesdatawordyonthebus.yALURegisterfileBusinterfaceyMainmemory0A%eaxI/ObridgeStoreoperation:
movl%eax,AMemoryWriteTransaction(3)MainmemoryreadsdatawordyfromthebusandstoresitataddressA.yALUregisterfilebusinterfaceymainmemory0A%eaxI/ObridgeStoreoperation:
movl%eax,AWhat’sInsideADiskDrive?SpindleArmActuatorPlattersElectronics(includingaprocessorandmemory!)SCSIconnectorImagecourtesyofSeagateTechnologyDiskGeometry(Muliple-PlatterView)Alignedtracksformacylinder.Surface0Surface1Surface2Surface3Surface4Surface5CylinderkSpindlePlatter0Platter1Platter2DiskGeometryDisksconsistofplatters,eachwithtwosurfaces.Eachsurfaceconsistsofconcentricringscalledtracks.Eachtrackconsistsofsectorsseparatedbygaps.SpindleSurfaceTracksTrackkSectorsGapsDiskOperation(Single-PlatterView)ThedisksurfacespinsatafixedrotationalrateBymovingradially,thearmcanpositiontheread/writeheadoveranytrack.Theread/writeheadisattachedtotheendofthearmandfliesoverthedisksurfaceonathincushionofair.spindlespindlespindlespindlespindleDiskOperation(Multi-PlatterView)ArmRead/writeheadsmoveinunisonfromcylindertocylinderSpindleTracksdividedintosectorsDiskStructure-topviewofsingleplatterSurfaceorganizedintotracksDiskAccessHeadinpositionaboveatrackDiskAccessRotationiscounter-clockwiseDiskAccess–ReadAbouttoreadbluesectorDiskAccess–ReadAfterBLUE
readAfterreadingbluesectorDiskAccess–ReadAfterBLUE
readRedrequestschedulednextDiskAccess–SeekAfterBLUE
readSeekforREDSeektored’strackDiskAccess–RotationalLatencyAfterBLUE
readSeekforREDRotationallatencyWaitforredsectortorotatearoundDiskAccess–ReadAfterBLUE
readSeekforREDRotationallatencyAfterREDreadCompletereadofredDiskAccess–ServiceTimeComponentsAfterBLUE
readSeekforREDRotationallatencyAfterREDreadDatatransferSeekRotationallatencyDatatransferI/OBusMainmemoryI/ObridgeBusinterfaceALURegisterfileCPUchipSystembusMemorybusDiskcontrollerGraphicsadapterUSBcontrollerMouseKeyboardMonitorDiskI/ObusExpansionslotsforotherdevicessuchasnetworkadapters.ReadingaDiskSector(1)MainmemoryALURegisterfileCPUchipDiskcontrollerGraphicsadapterUSBcontrollermousekeyboardMonitorDiskI/ObusBusinterfaceCPUinitiatesadiskreadbywritingacommand,logicalblocknumber,anddestinationmemoryaddresstoaport(address)associatedwithdiskcontroller.ReadingaDiskSector(2)MainmemoryALURegisterfileCPUchipDiskcontrollerGraphicsadapterUSBcontrollerMouseKeyboardMonitorDiskI/ObusBusinterfaceDiskcontrollerreadsthesectorandperformsadirectmemoryaccess(DMA)transferintomainmemory.ReadingaDiskSector(3)MainmemoryALURegisterfileCPUchipDiskcontrollerGraphicsadapterUSBcontrollerMouseKeyboardMonitorDiskI/ObusBusinterfaceWhentheDMAtransfercompletes,thediskcontrollernotifiestheCPUwithaninterrupt(i.e.,assertsaspecial“interrupt”pinontheCPU)SolidStateDisks(SSDs)Pages:512B~4KB,Blocks:32~128pages/16~512KBDataread/writteninunitsofpages.PagecanbewrittenonlyafteritsblockhasbeenerasedAblockwearsoutafter100,000repeatedwrites.FlashtranslationlayerI/ObusPage0Page1PageP-1…Block0…Page0Page1PageP-1…BlockB-1FlashmemorySolidStateDisk(SSD)RequeststoreadandwritelogicaldiskblocksSSDTradeoffs vsRotatingDisksAdvantagesNomovingpartsfaster,lesspower,moreruggedDisadvantagesHavethepotentialtowearoutMitigatedby“wearlevelinglogic”inflashtranslationlayerE.g.IntelX25guarantees1petabyte(1015bytes)ofrandomwritesbeforetheywearoutIn2010,about100timesmoreexpensiveperbyteIn2013,about20times;In2016,about7timesApplicationsMP3players,smartphones,laptopsDesktopsandserversMetric 1980 1985 1990 1995 2000 2005 2010 2010:1980$/MB 8,000 880 100 30 1 0.1 0.06 130,000access(ns) 375 200 100 70 60 50 40 9typicalsize(MB) 0.064 0.256 4 16 64 2,000 8,000 125,000
StorageTrendsDRAMSRAMMetric 1980 1985 1990 1995 2000 2005 2010 2010:1980$/MB 500 100 8 0.30 0.01 0.005 0.0003 1,600,000access(ms) 87 75 28 10 8 4 3 29typicalsize(MB) 1 10 160 1,000 20,000 160,000 1,500,000 1,500,000DiskMetric 1980 1985 1990 1995 2000 2005 2010 2010:1980$/MB 19,200 2,900 320 256 100 75 60 320access(ns) 300 150 35 15 3 2 1.5 200CPUClockRates
1980 1990 1995 2000 2003 2005 2010 2010:1980CPU 8080 386 Pentium P-III P-4 Core2 Corei7 Clockrate(MHz)1 20 150 600 3300 2000 2500 2500Cycletime(ns) 1000 50 6 1.6 0.3 0.50 0.4 2500Cores 1 1 1 1 1 2 4 4Effectivecycle 1000 50 6 1.6 0.3 0.25 0.1 10,000time(ns)Inflectionpointincomputerhistorywhendesignershitthe“PowerWall”TheCPU-MemoryGapThegapwidensbetweenDRAM,disk,andCPUspeeds.DiskDRAMCPUSSDSRAMLocality ThekeytobridgingthisCPU-MemorygapisafundamentalpropertyofcomputerprogramsknownaslocalityTodayStoragetechnologiesandtrendsLocalityofreferenceCachinginthememoryhierarchyLocalityPrincipleofLocality:
ProgramstendtousedataandinstructionswithaddressesnearorequaltothosetheyhaveusedrecentlyTemporallocality:Recentlyreferenceditemsarelikely
tobereferencedagaininthenearfutureSpatiallocality:Itemswithnearbyaddressestend
tobereferencedclosetogetherintimeLocalityExampleDatareferencesReferencearrayelementsinsuccession(stride-1referencepattern).Referencevariablesumeachiteration.InstructionreferencesReferenceinstructionsinsequence.Cyclethroughlooprepeatedly.sum=0;for(i=0;i<n;i++) sum+=a[i];returnsum;SpatiallocalityTemporallocalitySpatiallocalityTemporallocalityQualitativeEstimatesofLocalityClaim:Beingabletolookatcodeandgetaqualitativesenseofitslocalityisakeyskillforaprofessionalprogrammer.Question:Doesthisfunctionhavegoodlocalitywithrespecttoarraya?intsum_array_rows(inta[M][N]){inti,j,sum=0;for(i=0;i<M;i++)for(j=0;j<N;j++)sum+=a[i][j];returnsum;}Yes:
stride-1referencepatternM=2,N=3LocalityExampleQuestion:Doesthisfunctionhavegoodlocalitywithrespecttoarraya?intsum_array_cols(inta[M][N]){inti,j,sum=0;for(j=0;j<N;j++)for(i=0;i<M;i++)sum+=a[i][j];returnsum;}No:
stride-3referencepatternM=2,N=3LocalityExampleQuestion:Canyoupermutetheloopssothatthefunctionscansthe3-darraya
withastride-1referencepattern(andthushasgoodspatiallocality)?intsum_array_3d(inta[M][N][N]){inti,j,k,sum=0;for(i=0;i<M;i++)for(j=0;j<N;j++)for(k=0;k<N;k++)sum+=a[k][i][j];returnsum;}MemoryHierarchiesSomefundamentalandenduringpropertiesofhardwareandsoftware:Faststoragetechnologiescostmoreperbyte,havelesscapacity,andrequiremorepower(heat!).ThegapbetweenCPUandmainmemoryspeediswidening.Well-writtenprogramstendtoexhibitgoodlocality.Theysuggestanapproachfororganizingmemoryandstoragesystemsknownasamemoryhierarchy.TodayStoragetechnologiesandtrendsLocalityofreferenceCachinginthememoryhierarchyAnExampleMemoryHierarchyLatency:011030100100000001000000000CacheCache:
Asmaller,fasterstoragedevicethatactsasastagingareaforasubsetofthedatainalarger,slowerdevice.Fundamentalideaofamemoryhierarchy:Foreachk,thefaster,smallerdeviceatlevelkservesasacacheforthelarger,slowerdeviceatlevelk+1.Whydomemoryhierarchieswork?Becauseoflocality,programstendtoaccessthedataatlevelkmoreoftenthantheyaccessthedataatlevelk+1.Thus,thestorageatlevelk+1canbeslower,andthuslargerandcheaperperbit.GeneralCacheConcepts012345678910111213141589143CacheMemoryLarger,slower,cheapermemoryviewedaspartitionedinto“blocks”Dataiscopiedinblock-sizedtransferunitsSmaller,faster,moreexpensivememorycachesasubsetoftheblocks444101010GeneralCacheConcepts:Hit012345678910111213141549143CacheMemoryDatainblockbisneededRequest:1414Blockbisincache:Hit!GeneralCacheConcepts:Miss01234567891011121314159143CacheMemoryDatainblockbisneededRequest:12Blockbisnotincache:Miss!BlockbisfetchedfrommemoryRequest:1212124GeneralCacheConcepts:Miss01234567891011121314159143CacheMemoryDatainblockbisneededRequest:12Blockbisnotincache:Miss!BlockbisfetchedfrommemoryRequest:121212BlockbisstoredincacheReplacingorevicting:
Processofoverwriting
anexistingblockReplacementpolicy:
Determines
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 兼职搭建合同范本
- 车站租房合同范本
- 销售台布合同范本
- 预付押金合同范本
- Nor-6α-Oxycodol-生命科学试剂-MCE
- 科技公司如何通过网络直播提高用户参与度?-策略分析与探讨
- 科技改变生活基于AI的办公楼智能安全管理
- 生命教育与心理健康的相互促进
- 社交电商行业教育市场的发展策略研究
- 社区文化对物业服务的创新推动
- XF-T 3004-2020 汽车加油加气站消防安全管理
- 认识办公室(办公室管理课件)
- 子宫内膜癌保留生育治疗
- (正式版)JBT 14660-2024 额定电压6kV到30kV地下掘进设备用橡皮绝缘软电缆
- 本科院校-基础医学-医学细胞生物学-第二章 细胞的概念与分子基础
- iso37001-2016反贿赂管理手册程序文件表单一整套
- 2.2算法的概念及其描述课件人教中图版高中信息技术必修1
- 新苏教版科学六年级下册全册教案(含反思)
- 高速公路桥头跳车判别和处治
- 勃利县大四站镇侵蚀沟治理工程施工组织设计
- 汽车电子技术专业人才培养方案样本
评论
0/150
提交评论