Docsity

Improving Cache Performance: Measuring and Reducing Miss Rates and Penalties - Prof. Randy, Study notes of Computer Science

Partial preview of the text

Download Improving Cache Performance: Measuring and Reducing Miss Rates and Penalties - Prof. Randy and more Study notes Computer Science in PDF only on Docsity!

CS240 Computer Organization

Department of Computer Science

Wellesley College

Cold, hard cache

Measuring and improving cache

performance

Improving cache 21-

CPU time

CPU time = (CPU execution cycles + Memory-stall cycles)

x Clock cycle time

Memory-stall cycles = Read-stall cycles + Write-stall cycles

Read-stall cycles = x Read miss rate x Read miss penalty

Write-stall cycles = x Write miss rate x Write miss penalty

+ Write buffer stalls

Reads

Program

Writes

Program

Improving cache 21-

This simplifies to CPU time = (CPU execution cycles + Memory-stall cycles) x Clock cycle time Memory-stall cycles = x Read miss rate x Read miss penalty Memory-stall cycles = x x Read miss penalty Mem accesses Program Instructions Program Misses Instruction

Improving cache 21-

Nobody’s perfect CPU time = (CPU execution cycles + Memory-stall cycles) x Clock cycle time Memory-stall cycles = x x Read miss penalty For a given program we assume: o An instruction cache miss rate of 2%; o a data cache miss rate of 4%; o a CPI of 2 without memory stalls; o a miss penalty of 100 cycles; and o the the frequency of loads and stores is SPECint2000 of 36%. Determine how much faster the processor would run with a perfect cache. Instructions Program Misses Instruction

Improving cache 21-

Faster CPI & clock rate deliver a double whammy *The processor vs DRAM speed disparity continues to grow. **0.

1 10 100 1000 VAX/1980 PPro/1996 2010+ Processor DRAM** Clocks per instruction (CPI) Clocks per DRAM access

Improving cache 21-

We seek to decrease miss rate, while not increasing hit time o We may be able to reduce cache misses by more flexible placement of blocks. o In direct mapped cache, a block can go in exactly one place. o That makes it easy to find, but...

Improving cache 21-

Memory references 0 1 2 3 4 3 4 15

00 Mem(0) 00 Mem(0) 00 Mem(1) 00 Mem(0) (^00) Mem(0) 00 Mem(1) 00 Mem(2)

miss miss miss miss

miss hit hit miss

00 Mem(0) 00 Mem(1) 00 Mem(2) 00 Mem(3) 01 Mem(4) 00 Mem(1) 00 Mem(2) 00 Mem(3) 01 Mem(4) 00 Mem(1) 00 Mem(2) 00 Mem(3) 01 Mem(4) 00 Mem(1) 00 Mem(2) 00 Mem(3)

00 Mem(1) 00 Mem(2) 00 Mem(3) *Start with an empty cache - all blocks initially marked as not valid.

Improving cache 21-

Memory references 0 4 0 4 0 4 0 4 0 4 0 4 0 4 0 4 miss miss miss miss miss miss miss miss 00 Mem(0) 00 Mem(0) (^01 ) 01 Mem(4) (^000) 00 Mem(0) 01 4 00 Mem(0) (^01 ) 00 Mem(0) 01 4 01 Mem(4) (^000) 01 Mem(4) (^000) *Start with an empty cache - all blocks initially marked as not valid.

Improving cache 21-

Memory references 0 1 2 3 4 3 4 15 (^0 1 ) 3 4 3 4 15 00 Mem(1) Mem(0) miss 00 Mem(1) Mem(0) hit 00 Mem(3) Mem(2) 00 Mem(1) Mem(0) miss hit 00 Mem(3) Mem(2) 00 Mem(1) Mem(0) miss 00 Mem(3) Mem(2) 00 Mem(1) Mem(0) (^01 5 ) hit 00 Mem(3) Mem(2) 01 Mem(5) Mem(4) hit 00 Mem(3) Mem(2) 01 Mem(5) Mem(4) 00 Mem(3) Mem(2) 01 Mem(5) Mem(4) miss (^11 15 )

Improving cache 21-

Performance of set-associative caches Associativity 0 One-way Two-way 3 % 6 % 9 % 12 % 15 % Four-way Eight-way 1 KB 2 KB 4 KB 8 KB 16 KB 32 KB (^64) KB 128 KB

Improving cache 21-

Implementing a 4-way set-associative cache Address 22 8 Index V Tag 0 (^12) 253 (^225545) Data V Tag Data V Tag Data V Tag Data 22 32 4 - to- 1 multiplexor Hit Data

Improving cache 21-

Choosing which block to replace o When a miss occurs in a direct-mapped cache, the requested block can only go in one place. o In an associative cache we have a choice. o The most commonly scheme least recently used (LRU).

Improving cache 21-

If only things were that simple Radix sort Quicksort Size (K items to sort)

Radix sort Quicksort Size (K items to sort)

Theoretical behavior of Radix sort vs. Quicksort Observed behavior of Radix sort vs. Quicksort

Improving cache 21-

The real scoop o Memory system performance is often critical factor o Multilevel caches, pipelined processors, make it harder to predict outcomes Radix sort Quicksort Size (K items to sort)