cache hierarchy
play

Cache Hierarchy J. Nelson Amaral University of Alberta - PowerPoint PPT Presentation

Cache Hierarchy J. Nelson Amaral University of Alberta Address Transla;on (flashback) valid bit = 0 implies a page fault (there is no frame in


  1. Cache ¡Hierarchy ¡ J. ¡Nelson ¡Amaral ¡ University ¡of ¡Alberta ¡

  2. Address ¡Transla;on ¡ (flashback) ¡ valid ¡bit ¡= ¡0 ¡implies ¡ a ¡page ¡fault ¡(there ¡is ¡ no ¡frame ¡in ¡memory ¡ ¡ for ¡this ¡page) ¡ Baer, ¡p. ¡62 ¡

  3. Should ¡the ¡Cache ¡be ¡Accessed ¡with ¡ Physical ¡or ¡Virtual ¡Addresses? ¡ Baer, ¡p. ¡209 ¡

  4. Instruc;on ¡Cache ¡ • Instruc;ons ¡are ¡fetched ¡either: ¡ – sequen;ally ¡(same ¡cache ¡line) ¡ – with ¡address ¡form ¡a ¡branch ¡target ¡buffer ¡(BTB) ¡ • BTB ¡contains ¡physical ¡addresses ¡ • When ¡needed, ¡transla;on ¡is: ¡ – done ¡in ¡parallel ¡with ¡delivery ¡of ¡previous ¡ instruc;on ¡ • Thus ¡Instruc;on ¡Cache ¡can ¡be ¡physical ¡ Baer, ¡p. ¡209 ¡

  5. For ¡a ¡2k ¡ page ¡size, ¡ Data ¡Cache ¡ the ¡last ¡ k ¡bits ¡are ¡ iden;cal ¡in ¡the ¡ virtual ¡and ¡physical ¡ addresses. ¡ Index ¡ Physical ¡ Virtual ¡ Tags ¡ Tags ¡ Physical ¡ Physical ¡ Virtual ¡ If ¡the ¡cache ¡index ¡fits ¡within ¡these ¡k ¡ bits, ¡ ¡ then ¡these ¡two ¡schemes ¡are ¡iden;cal. ¡ Baer, ¡p. ¡209 ¡

  6. Parallel ¡TLB ¡and ¡Cache ¡Access ¡ Page ¡size ¡= ¡2 k ¡ Only ¡works ¡if ¡index ¡+ ¡displ. ¡≤ ¡ k ¡ Baer, ¡p. ¡210 ¡

  7. Pipeline ¡Stages ¡ Saves ¡a ¡pipeline ¡stage ¡when ¡ there ¡is ¡a ¡hit ¡in ¡the ¡TLB ¡and ¡cache. ¡ Stage ¡2: ¡If ¡Tag ¡in ¡TLB ¡ ¡≠ ¡Tag ¡in ¡TLB: ¡ Stage ¡1: ¡Send ¡ ¡ -­‑ ¡Void ¡Data ¡in ¡Register ¡ Data ¡to ¡Register ¡ -­‑ ¡ ¡Start ¡Replay ¡ ¡ Baer, ¡p. ¡210 ¡

  8. Page ¡Sizes ¡are ¡typically ¡4KB ¡or ¡8KB. ¡ An ¡8KB ¡L1 ¡cache ¡is ¡too ¡small. ¡ Increase ¡cache ¡associa;vity. ¡ Two ¡solu;ons: ¡ Increase ¡the ¡number ¡of ¡bits ¡that ¡ are ¡not ¡translated. ¡ Baer, ¡p. ¡210 ¡

  9. Limits ¡on ¡Associa;vity ¡ Time ¡to ¡do ¡the ¡tag ¡comparisons ¡ Solu;on: ¡Do ¡comparisons ¡in ¡parallel ¡ S;ll ¡need ¡;me ¡for ¡latches/mul;plexors ¡ Solu;on: ¡Don’t ¡compare ¡with ¡all ¡tags. ¡How? ¡ Use ¡a ¡set ¡predictor. ¡ ¡ For ¡L1 ¡predictor ¡must ¡be ¡fast. ¡ ¡ Baer, ¡p. ¡210 ¡

  10. Page ¡Coloring ¡ • Goal : ¡increase ¡number ¡of ¡non-­‑translated ¡bits ¡ • Idea : ¡Restrict ¡mapping ¡of ¡pages ¡into ¡frames ¡ – Divide ¡both ¡pages ¡and ¡frames ¡into ¡colors. ¡ – A ¡page ¡must ¡map ¡to ¡a ¡frame ¡of ¡the ¡same ¡color. ¡ – For ¡ l ¡ addi;onal ¡non-­‑translated ¡bits ¡needs ¡ 2 l ¡colors. ¡ Restrict ¡mapping ¡between ¡virtual ¡and ¡physical ¡ addresses ¡ • Alterna,ve ¡to ¡coloring : ¡ – Use ¡a ¡predictor ¡for ¡the ¡ l ¡bits. ¡ Baer, ¡p. ¡211 ¡

  11. Virtual ¡Cache ¡ • Virtual ¡index ¡and ¡virtual ¡tags ¡allow ¡for ¡fast ¡access ¡ to ¡cache. ¡ • However… ¡ – Page ¡protec;on ¡and ¡recency-­‑of-­‑use ¡informa;on ¡(stored ¡ in ¡TLB) ¡must ¡be ¡accessed. ¡ • TLB ¡must ¡be ¡accessed ¡anyway ¡ • TLB ¡access ¡can ¡be ¡in ¡parallel ¡with ¡cache ¡access ¡ – Context ¡switches ¡ac;vate ¡new ¡virtual ¡address ¡space ¡ • En;re ¡cache ¡content ¡becomes ¡stale. ¡Either: ¡ – ¡flush ¡the ¡cache ¡ – append ¡a ¡PID ¡to ¡tag ¡in ¡cache ¡ » must ¡flush ¡part ¡of ¡cache ¡when ¡recycling ¡PIDs ¡ – Synonym ¡Problem ¡ Baer, ¡p. ¡211 ¡

  12. Synonym ¡Problem ¡ Virtual ¡Address ¡A ¡ Physical ¡Address ¡1 ¡ Virtual ¡Address ¡B ¡ Occurs ¡when ¡data ¡is ¡shared ¡among ¡processes ¡ What ¡happens ¡in ¡a ¡virtual ¡cache ¡if ¡two ¡ ¡ synonyms ¡are ¡cached ¡simultaneously, ¡ and ¡one ¡of ¡them ¡is ¡modified? ¡ The ¡other ¡becomes ¡inconsistent! ¡ Baer, ¡p. ¡211 ¡

  13. Avoiding ¡Stale ¡Synonyms ¡ • Varia,on ¡on ¡Page ¡Coloring : ¡Require ¡that ¡the ¡ bits ¡used ¡to ¡index ¡the ¡cache ¡be ¡the ¡same ¡for ¡ all ¡synonyms ¡ • Soiware ¡must ¡be ¡aware ¡about ¡poten;al ¡ synonyms ¡ – Easier ¡for ¡instruc;on ¡caches ¡ – Tricky ¡for ¡data ¡caches ¡ • Sun ¡UltraSPARC ¡has ¡virtual ¡instruc;on ¡cache. ¡ Baer, ¡p. ¡212 ¡

  14. Example ¡ • Page ¡size ¡is ¡4 ¡Kbytes ¡ – How ¡many ¡bits ¡for ¡page ¡number ¡and ¡page ¡offset? ¡ • 20 ¡bits ¡for ¡page ¡number ¡and ¡12 ¡bits ¡for ¡page ¡offset ¡ • Direct-­‑mapped ¡D-­‑Cache ¡has ¡16 ¡bytes ¡per ¡lines, ¡ 512 ¡lines: ¡ – How ¡many ¡bits ¡for ¡tag, ¡index, ¡and ¡displacement? ¡ • 16x512 ¡= ¡8192 ¡bytes ¡= ¡2 13 ¡bytes ¡ • displacement ¡= ¡4 ¡bits ¡ • index ¡= ¡13-­‑4 ¡= ¡9 ¡bits ¡ Lowest ¡bit ¡of ¡page ¡number ¡ is ¡part ¡of ¡the ¡index. ¡ • tag ¡= ¡32-­‑13 ¡= ¡19 ¡bits ¡ Baer, ¡p. ¡212 ¡

  15. Page ¡Number ¡ Page ¡Offset ¡ 28 ¡ 24 ¡ 20 ¡ 16 ¡ 12 ¡ 8 ¡ 4 ¡ 0 ¡ Cache ¡Tag ¡ Cache ¡Index ¡ Cache ¡ Displ. ¡ Process ¡A ¡ Page ¡ Physical ¡Pages ¡ 4 ¡ Page ¡ 14 ¡ Process ¡B ¡ Page ¡ 17 ¡ Baer, ¡p. ¡212 ¡

  16. Process ¡A ¡reads ¡line ¡8 ¡of ¡its ¡page ¡4 ¡(line ¡8 ¡physical ¡page ¡14): ¡ Page ¡Number ¡ Page ¡Offset ¡ 28 ¡ 24 ¡ 20 ¡ 16 ¡ 12 ¡ 8 ¡ 4 ¡ 0 ¡ 0 ¡ 0 ¡ 0 ¡ 0 ¡ 0 ¡ 0 ¡ 0 ¡ 0 ¡ 0 ¡ 0 ¡ 0 ¡ 0 ¡ 0 ¡ 0 ¡ 0 ¡ 0 ¡ 0 ¡ 1 ¡ 0 ¡ 0 ¡ 0 ¡ 0 ¡ 0 ¡ 0 ¡ 1 ¡ 0 ¡ 0 ¡ 0 ¡ 0 ¡ 0 ¡ 0 ¡ 0 ¡ Cache ¡ Cache ¡Tag ¡ Cache ¡Index ¡ Displac. ¡ Process ¡B ¡reads ¡line ¡8 ¡of ¡its ¡page ¡17 ¡(line ¡8 ¡of ¡physical ¡page ¡14): ¡ Page ¡Number ¡ Page ¡Offset ¡ 28 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 24 ¡ 20 ¡ 16 ¡ 12 ¡ 8 ¡ 4 ¡ 0 ¡ 0 ¡ 0 ¡ 0 ¡ 0 ¡ 0 ¡ 0 ¡ 0 ¡ 0 ¡ 0 ¡ 0 ¡ 0 ¡ 0 ¡ 0 ¡ 0 ¡ 0 ¡ 1 ¡ 0 ¡ 0 ¡ 0 ¡ 1 ¡ 0 ¡ 0 ¡ 0 ¡ 0 ¡ 1 ¡ 0 ¡ 0 ¡ 0 ¡ 0 ¡ 0 ¡ 0 ¡ 0 ¡ Cache ¡ Cache ¡Tag ¡ Cache ¡Index ¡ Displac. ¡ Index ¡ V ¡ d ¡ Tag ¡ Data ¡ … ¡ Now ¡processor ¡ 8 ¡ 1 ¡ 0 ¡ 0000 ¡0000 ¡0000 ¡0010 ¡ VMem[0x0000 ¡4080] ¡ B ¡writes ¡to ¡its ¡ … ¡ cache ¡line ¡8. ¡ 264 ¡ 1 ¡ 0 ¡ 0000 ¡0000 ¡0000 ¡1000 ¡ VMem[0x0001 ¡1080] ¡ .. ¡ Baer, ¡p. ¡212 ¡

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