1 / 25

Lecture 8: Memory Hierarchy (2)

Lecture 8: Memory Hierarchy (2). Michael B. Greenwald Computer Architecture CIS 501 Fall 1999. Administration. SEAS Career Awareness Day: 10am-3pm Towne Links from Web Page: Problems? Tell us. Review. Cache is a subset of memory; higher performance, higher cost, lower capacity.

swansonj
Download Presentation

Lecture 8: Memory Hierarchy (2)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 8:Memory Hierarchy (2) Michael B. Greenwald Computer Architecture CIS 501 Fall 1999

  2. Administration • SEAS Career Awareness Day: 10am-3pm Towne • Links from Web Page: Problems? Tell us.

  3. Review • Cache is a subset of memory; higher performance, higher cost, lower capacity. • Total memory system should have average performance of top level, and average cost of bottom level. (capacity of bottom level, too). • Seek block in high level cache; on “hit” - return block, on “miss” - seek in lower level; recurse. • Average Memory Access Time = hit time + miss rate X miss penalty.

  4. Improving Cache Performance • Average memory-access time = Hit time + Miss rate x Miss penalty (ns or clocks) • Improve performance by: 1. Reduce the miss rate, 2. Reduce the miss penalty, or 3. Reduce the time to hit in the cache.

  5. Four Questions for Memory Hierarchy Designers • Q1: Where can a block be placed in the upper level? (Block placement) • Q2: How is a block found if it is in the upper level? (Block identification) • Q3: Which block should be replaced on a miss? (Block replacement) • Q4: What happens on a write? (Write strategy) • Q0: What is a block?

  6. 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 Q1: Where can a block be placed in the upper level? • Block 12 placed in 8 block cache: • Fully associative, direct mapped, 2-way set associative • Set Associative Mapping = Block Number Modulo Number Sets 2 way set-associative:block 12 -> 12 mod 4 = set 0 Fully associative:block can go anywhere Direct mapped:block 12 -> 12 mod 8 = 4 0 1 2 3 4 5 6 7 CACHE Set0 Set1 Set2 Set3 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 MEMORY

  7. Q2: How Is a Block Found If It Is in the Upper Level? • Tag on each block • No need to check index or block offset • Increasing associativity shrinks index, expands tag Block offset Block Address Tag Index (Within block, don’t check) (Selects set) (Includes valid bit) FA: No index, DM: Large index

  8. Q3: Which block should be replaced on a miss? • Easy for Direct Mapped • Set Associative or Fully Associative: • Random • LRU (Least Recently Used) Associativity: 2-way 4-way 8-way Size LRU Random LRU Random LRU Random 16 KB 5.2% 5.7% 4.7% 5.3% 4.4% 5.0% 64 KB 1.9% 2.0% 1.5% 1.7% 1.4% 1.5% 256 KB 1.15% 1.17% 1.13% 1.13% 1.12% 1.12%

  9. Q4: What Happens on a Write? • Write through: The information is written to both the block in the cache and to the block in the lower-level memory. • Write back: The information is written only to the block in the cache. The modified cache block is written to main memory only when it is replaced. • is block clean or dirty? • Pros and Cons of each: • WT: read misses cannot result in writes (because of replacements) • WB: no writes of repeated writes • WT always combined with write buffers so that don’t wait for lower level memory

  10. Write Buffer for Write Through Cache Processor DRAM • A Write Buffer is needed between the Cache and Memory • Processor: writes data into the cache and the write buffer • Memory controller: write contents of the buffer to memory • Write buffer is just a FIFO: • Typical number of entries: 4 (Might use write-merging) • Works fine if: Store frequency (w.r.t. time) << 1 / DRAM write cycle • Memory system designer’s nightmare: • Store frequency (w.r.t. time) -> 1 / DRAM write cycle • Write buffer saturation Write Buffer

  11. What do we do on a write miss? • Write allocate (fetch-on-write): Load into cache and treat as a write-hit • No-Write allocate (write-around): Only modify in lower level and don’t load into cache. • Typically: • Write-back <=> write-allocate • Write-through <=> no-Write Allocate

  12. Cache Organization • Split I/D caches? Or unified? • Advantage of split cache comes from 2 ports to memory, not reducing miss rate.

  13. Improving Cache Performance • Average memory-access time = Hit time + Miss rate x Miss penalty (ns or clocks) • Improve performance by: 1. Reduce the miss rate, 2. Reduce the miss penalty, or 3. Reduce the time to hit in the cache.

  14. Reducing Misses • Classifying Misses: 4 Cs (sometimes called 3 Cs) • Compulsory—The first access to a block is not in the cache, so the block must be brought into the cache. Also called cold start missesorfirst reference misses.(Misses in even an Infinite Cache) • Capacity—If the cache of size X cannot contain all the blocks needed during execution of a program, capacity misses will occur due to blocks being discarded and later retrieved.(Misses in Fully Associative Size X Cache) • Conflict—If block-placement strategy is set associative or direct mapped, conflict misses (in addition to compulsory & capacity misses) will occur because a block can be discarded and later retrieved if too many blocks map to its set. Also called collision missesor interference misses.(Misses in N-way Associative, Size X Cache) • Coherence —If same block resides in multiple caches must be flushed or invalidated on modification.(Misses in the presence of multiple caches)

  15. Reducing Misses • Classifying Misses: 3 Cs • Compulsory—(Misses in even an Infinite Cache)First reference to this block? (depends on block size) • Capacity—(Misses in Fully Associative Size X Cache)Were X different blocks accessed since last time this block was referenced? • Conflict—(Misses in N-way Associative, Size X Cache)Whatever is left must be conflict. • You can COUNT number of misses in each class, but it is hard to say this miss is capacity vs. conflict, because may depend upon cache organization.

  16. How Can Reduce Misses? • 4 Cs: Compulsory, Capacity, Conflict, Coherence • In all cases, assume total cache size not changed: • What happens if: 1) Change Block Size: Which of 4Cs is obviously affected? 2) Change Associativity: Which of 4Cs is obviously affected? 3) Change Compiler: Which of 4Cs is obviously affected?

  17. 3Cs Absolute Miss Rate (SPEC92) Compulsory vanishingly smallCoherence not relevant Conflict

  18. 3Cs Relative Miss Rate Conflict Flaws: for fixed block size Good: insight => invention

  19. 1. Reduce Misses via Larger Block Size Increase Conflicts, Capacity Reduce Compulsary

  20. 2. Reduce Misses via Higher Associativity • 2:1 Cache Rule: • Miss Rate DM cache size N ­ Miss Rate 2-way cache size N/2 (N/4 sets) • 8-way rule: • 8 way set-associative is almost indistinguishable from fully associative • Beware: Execution time is only final measure! • Will Clock Cycle time increase? Diminishing returns comes much earlier than 8 way • Hill [1988] suggested hit time for 2-way vs. 1-way external cache +10%, internal + 2%

  21. 2:1 Cache Rule miss rate 1-way associative cache size X = miss rate 2-way associative cache size X/2 Conflict Doesn’t tell us anything about rates for fixed size, changed associativity!

  22. Example: Avg. Memory Access Time vs. Miss Rate • Example: assume ClockCycleTime = 1.10 for 2-way, 1.12 for 4-way, 1.14 for 8-way vs. CCT direct mapped Cache Size Associativity (KB) 1-way 2-way 4-way 8-way 1 2.33 2.15 2.07 2.01 2 1.98 1.86 1.76 1.68 4 1.72 1.67 1.61 1.53 8 1.46 1.481.47 1.43 161.291.321.32 1.32 32 1.20 1.24 1.25 1.27 64 1.14 1.20 1.21 1.23 128 1.10 1.17 1.18 1.20 (Red means A.M.A.T. not improved by more associativity)

  23. 3. Reducing Misses via a“Victim Cache” • How to combine fast hit time of direct mapped yet still avoid conflict misses? • Add buffer to place data discarded from cache • Jouppi [1990]: 4-entry victim cache removed 20% to 95% of conflicts for a 4 KB direct mapped data cache • Used in Alpha, HP machines

  24. 3. Reducing Misses via a“Victim Cache” • Does it increase hit time? No, only relevant on miss. • Does it increase miss penalty? No, lookup in parallel with hit (limits size of victim cache to have cost less than hit-time). • Why not in parallel with miss? Don’t want to start memory transfer if hit in victim cache.

  25. 4. Reducing Misses via “Pseudo-Associativity” • How to combine fast hit time of Direct Mapped and have the lower conflict misses of 2-way SA cache? • Divide cache: on a miss, check other half of cache to see if there, if so have a pseudo-hit (slow hit) • Drawback: CPU pipeline is hard if hit takes 1 or 2 cycles • Better for caches not tied directly to processor (L2) • Used in MIPS R1000 L2 cache, similar in UltraSPARC Hit Time Miss Penalty Pseudo Hit Time Time

More Related