Docsity

Advanced Caching in Computer Architecture, Lecture notes of Computer Architecture and Organization

Partial preview of the text

Download Advanced Caching in Computer Architecture and more Lecture notes Computer Architecture and Organization in PDF only on Docsity!

Computer Architecture

Lecture 12: Advanced Caching

Prof. Onur MutluCarnegie Mellon University

Announcements „^ Chuck Thacker (Microsoft Research) Seminar Tomorrow^ ‰^ RARE: Rethinking Architectural Research and Education^ ‰^ October 7, 4:30-5:30pm, GHC Rashid Auditorium „^ Ben Zorn (Microsoft Research) Seminar Friday^ ‰^ Performance is Dead, Long Live Performance!^ ‰^ October 8, 11am-noon, GHC 6115 „^ Guest lecture Friday^ ‰^ Dr. Ben Zorn, Microsoft Research^ ‰^ Fault Tolerant, Efficient, and Secure Runtimes

Last Time …

„^ Dual-core Execution, Slipstream Idea „^ Store-Load Dependency Handling „^ Speculative Execution and Data Coherence „^ Open Research Issues in OoO Execution „^ Asymmetric vs. Symmetric Cores „^ ACMP „^ Accelerated Critical Sections using ACMP „^ Advanced Caching^ ‰^ Inclusion vs. Exclusion^ ‰^ Multi-level caches in Pipelined Designs

Topics in (Advanced) Caching „^ Inclusion vs. exclusion, revisited „^ Handling writes „^ Instruction vs. data „^ Cache replacement policies „^ Cache performance „^ Enhancements to improve cache performance „^ Enabling multiple concurrent accesses „^ Enabling high bandwidth caches

Handling Writes (Stores) „^ When do we write the modified data in a cache to the next level?^ „^ Write through: At the time the write happens^ „^ Write back: When the block is evicted ‰^ Write-back-- Need a bit in the tag store indicating the block is “modified”+ Can consolidate multiple writes to the same block before eviction^ ‰

Potentially saves bandwidth between cache levels + saves energy

‰^ Write-through+ Simpler+ All levels are up to date. Consistency: Simpler cache coherencebecause no need to check lower-level caches-- More bandwidth intensive

Handling Writes (Stores) „^ Do we allocate a cache block on a write miss?^ ‰^ Allocate on write miss: Yes^ ‰^ No-allocate on write miss: No „^ Allocate on write miss+ Can consolidate writes instead of writing each of themindividually to next level+ Simpler because write misses can be treated the same way asread misses-- Requires (?) transfer of the whole cache block „^ No-allocate+ Conserves cache space if locality of writes is low

Set-Associative Caches (I) „^ Diminishing returns in hit rate from higher associativity „^ Longer access time with higher associativity „^ Which block in the set to replace on a cache miss?^ ‰^ Any invalid block first^ ‰^ If all are valid, consult the replacement policy^ „

Random „ FIFO „ Least recently used (how to implement?) „ Not most recently used „ Least frequently used? „ Least costly to re-fetch?^ ‰^ Why would memory accesses have different cost? „ Hybrid replacement policies „ Optimal replacement policy?

Set-Associative Caches (II) „^ Belady’s OPT^ ‰^ Replace the block that is going to be referenced furthest in thefuture by the program^ ‰^ Belady, “A study of replacement algorithms for a virtual-storage computer,” IBM Systems Journal, 1966.^ ‰^ How do we implement this? Simulate?^ „^ Is this optimal for minimizing miss rate? „^ Is this optimal for minimizing execution time?^ ‰^ No. Cache miss latency/cost varies from block to block!^ ‰^ Two reasons: Remote vs. local caches and miss overlapping^ ‰^ Qureshi et al. “A Case for MLP-Aware Cache Replacement,“ISCA 2006.

Traditional Cache Replacement Policies ‰^ Traditional cache replacement policies try to reduce misscount ‰^ Implicit assumption: Reducing miss count reduces memory-related stall time ‰^ Misses with varying cost/MLP breaks this assumption! ‰^ Eliminating an isolated miss helps performance more thaneliminating a parallel miss ‰^ Eliminating a higher-latency miss could help performancemore than eliminating a lower-latency miss

14

Misses to blocks P1, P2, P3, P4 can be parallelMisses to blocks S1, S2, and S3 are isolatedTwo replacement algorithms:1.^

Minimizes miss count (Belady’s OPT)2. Reduces isolated miss (MLP-Aware) For a fully associative cache containing 4 blocks

S

P4 P3 P2 P

P1 P2 P3 P

S^

S

An Example

Cache Performance

Improving Cache “Performance” „^ Reducing miss rate^ ‰^ Caveat: reducing miss rate can reduce performance if morecostly-to-refetch blocks are evicted „^ Reducing miss latency „^ Reducing hit latency

Cache Parameters vs. Miss Rate „^ Cache size „^ Block size „^ Associativity „^ Replacement policy „^ Insertion/Placement policy

Cache Size „^ Cache size in the total data (not including tag) capacity^ ‰^

bigger can exploit temporal locality better ‰ not ALWAYS better

„^ Too large a cache adversely affects hit and miss latency^ ‰^

smaller is faster => bigger is slower ‰ access time may degrade critical path

„^ Too small a cache^ ‰^

doesn’t exploit temporal locality well ‰ useful data replaced often

„^ Working set: the whole set of datathe executing application references^ ‰^ Within a time interval

hit rate

“working set”size cache size