Docsity

Improving Cache Performance - Lecture Slides | CS 4504, Study notes of Computer Architecture and Organization

Toggle sidebar
bg1
1
Improving Cache Performance
•Average memory-access time = Hit time + Miss rate x Miss penalty
•Improve performance by:
1. Reduce the miss rate,
2. Reduce the miss penalty, or
3. Reduce the time to hit in the cache.
4. Increase ILP
CPU Cache
A Closer Look at Misses
•Classifying Misses: 3 Cs
–Compulsory—The first access to a block is not in the cache, so the
block must be brought into the cache. These are also called cold start
misses or first reference misses.
(Misses in Infinite Cache)
–Capacity—If the cache 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 Size X Cache)
–Conflict—If the block-placement strategy is set associative or direct
mapped, conflict misses (in addition to compulsory and capacity misses)
will occur because a block can be discarded and later retrieved if too
many blocks map to its set. These are also called collision missesor
interference misses.
(Misses in N-way Associative, Size X Cache)
CPU Cache
3Cs Absolute Miss Rate
Cache Size (KB)
0
0.02
0.04
0.06
0.08
0.1
0.12
0.14
1
2
4
8
16
32
64
128
1-way
2-way
4-way
8-way
Capacity
Compulsory
Conflict
How Can Reduce the Miss Rate?
•Block Size?
•Cache Size?
•Associativity?
•Prediction?
•Compiler?
Block Size vs. Cache Measures
•Increasing Block Size generally increases Miss Penalty and decreases Miss Rate
Block Size Block Size
Block Size
Miss
Rate
Miss
Penalty Avg. Memory Access Time
X=
Block SizeBlock Size
Reduce Misses via Larger Block Size
Block Size (bytes)
Miss
Rate
0%
5%
10%
15%
20%
25%
16
32
64
128
256
1K
4K
16K
64K
256K
1. Reduced compulsory misses
-improved spatial locality
2. Increased miss penalty
Increased conflict/capacity
-for small cache sizes
pf3

Partial preview of the text

Download Improving Cache Performance - Lecture Slides | CS 4504 and more Study notes Computer Architecture and Organization in PDF only on Docsity!

Improving Cache Performance

  • Average memory-access time = Hit time + Miss rate x Miss penalty
  • Improve performance by:

1. Reduce the miss rate,

2. Reduce the miss penalty, or

3. Reduce the time to hit in the cache.

4. Increase ILP

CPU Cache

A Closer Look at Misses

  • Classifying Misses: 3 Cs
    • Compulsory —The first access to a block is not in the cache, so the block must be brought into the cache. These are also called cold start misses or first reference misses. (Misses in Infinite Cache)
    • Capacity —If the cache 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 Size X Cache)
    • Conflict —If the block-placement strategy is set associative or direct mapped, conflict misses (in addition to compulsory and capacity misses) will occur because a block can be discarded and later retrieved if too many blocks map to its set. These are also called collision misses or interference misses. (Misses in N-way Associative, Size X Cache)

CPU Cache

3Cs Absolute Miss Rate

Cache Size (KB)

1-way

2-way 4-way 8-way Capacity

Compulsory

Conflict

How Can Reduce the Miss Rate?

  • Block Size?
  • Cache Size?
  • Associativity?
  • Prediction?
  • Compiler?

Block Size vs. Cache Measures

  • Increasing Block Size generally increases Miss Penalty and decreases Miss Rate

Block Size Block Size Block Size

Miss Rate

Miss Penalty

X = Avg. Memory Access Time

Block Size Block Size

Reduce Misses via Larger Block Size

Block Size (bytes)

Miss Rate

1K

4K

16K

64K

256K

**1. Reduced compulsory misses -improved spatial locality

  1. Increased miss penalty Increased conflict/capacity -for small cache sizes**

Example: Optimal block size

  • Memory system: 40 cycles overhead, hit time = 1 cycle
  • 16 bytes / 2 clocks Ë 16 bytes in 42 cycles, 32 bytes in 44 cycles,
  • For chart below, which block size has the minimum average

memory access time for each cache size?

1K 4K 16K 64K 256K

Block size Miss rates by cache size (bytes)

Example: Optimal block size

  • Miss penalties: 40 cycles + 2 * (block size /16)
  • AMAT = hit time + miss rate x miss penalty
    • 16KB cache, 16 byte block: 1 + .0394*42 = 2.
    • 16KB cache, 32 byte block: 1 + .0287*44 = 2.
    • 16KB cache, 64 byte block: 1 + .0264*48 = 2.
    • 16KB cache, 128 byte block: 1 + .0277*56 = 2.
    • 16KB cache, 256 byte block: 1 + .0329*72 = 3.

Miss penalty

1K 4K 16K 64K 256K

Block AMAT by cache size size (bytes)

Reduce Misses via Larger Caches

• Take advantage of technology (memory gap)

• Decrease capacity misses

• Increase hit time and cost

General Rules of thumb

Cache Size (KB)

1-way

2-way 4-way

8-way Capacity

Compulsory

Conflict

2:1 Cache Rule: Miss rate of a direct mapped cache of size n is about the same as a two-way set associative cache of size n/2 (i.e. miss rates similar for half sized cache with small increase (to two-way) in associativity)

8-way set associative is practically as effective as fully associative

Reduce Misses via Higher Associativity

  • Remember tradeoff:
    • Increase block size Ë reduced miss rate, increase miss penalty
  • New tradeoff:
    • Higher associativity Ë reduced miss rate, increased hit time
  • Beware: Execution time is only final measure!
    • Will Clock Cycle time increase?
    • Hill [1988] suggested hit time external cache +10%, internal +

2% for 2 -way vs. 1-way

Example: AMAT vs. miss rate

  • Relative clock cycle hit time for different associativities
    • Cycle hit time for 2- way = 1.10 x 1- way cycle hit time
    • Cycle hit time for 4- way = 1.12 x 1- way cycle hit time
    • Cycle hit time for 8- way = 1.14 x 1- way cycle hit time
  • Direct mapped (1-way) cycle hit time = 1 cycle
  • Direct mapped (1-way) miss penalty = 50 cycles
  • Using data below, find cache sizes that make these statements true:
    • AMAT(8- way) < AMAT(4 -way)
    • AMAT(4- way) < AMAT(2 -way)
    • AMAT(2- way) < AMAT(1- way)

.

.

.

.

32K

.

.

.

.

64K

.

.

.

.

128K

8-way .087 .054 .039 .029.

4-way .095 .064 .049 .035.

2-way .105 .076 .057 .038.

1-way .133 .098 .072 .046.

1K 2K 4K 8K 16K

Degree Miss rates by cache size Associative