CPU Optimization Cache Mapping Associative Mapping Cache item

  • Slides: 14
Download presentation
CPU Optimization Cache Mapping

CPU Optimization Cache Mapping

Associative Mapping �Cache item stores in any empty slot �Most efficient use of cache

Associative Mapping �Cache item stores in any empty slot �Most efficient use of cache space �Not practical – too slow

Memory Fragmentation Prevents Associative Mapping from being practical

Memory Fragmentation Prevents Associative Mapping from being practical

Direct Mapping �Cache Location = MOD (Address, Cache Size) �Simplest and fastest �Low cache

Direct Mapping �Cache Location = MOD (Address, Cache Size) �Simplest and fastest �Low cache space utilization

N-way Set-Associative Mapping �Cache Set Location = MOD (Address, Cache Size) �Each location can

N-way Set-Associative Mapping �Cache Set Location = MOD (Address, Cache Size) �Each location can have “n ways” or slots �Most practical

Cache: L 1 (data) L 1 (instruction) L 2 L 3 Size: 32 KB

Cache: L 1 (data) L 1 (instruction) L 2 L 3 Size: 32 KB 256 KB 8 MB Associativity 8 -way set associative 4 -way set associative 8 -way set associative 16 -way set associative Source: CPU World

Cache Considerations Factors that impact its performance

Cache Considerations Factors that impact its performance

Cache Levels Access Time Typical Size Registers 1 -3 ns 1 KB Level 1

Cache Levels Access Time Typical Size Registers 1 -3 ns 1 KB Level 1 Cache 2 -8 ns 8 KB-128 KB Level 2 Cache 5 -12 ns 0. 5 MB - 8 MB Main Memory 10 -60 ns 64 MB - 1 GB Hard Disk 3, 000 10, 000 ns 20 - 100 GB

Locality Which program do you think works better with cache? Photoshop MP 3 Player

Locality Which program do you think works better with cache? Photoshop MP 3 Player Software

Spatial Map of the Memory Use Total Memory use Instruction used. Used repeatedly during

Spatial Map of the Memory Use Total Memory use Instruction used. Used repeatedly during execution Data used (the image) Used repeatedly

Cache Pollution: When cache stores data that is not resued Instruction used. Used repeatedly

Cache Pollution: When cache stores data that is not resued Instruction used. Used repeatedly during execution Data used (the song) Used only once - Good instruction locality - Bad data locality

Some Cache Systems Separate Instruction Cache and Data Cache: L 1 (data) L 1

Some Cache Systems Separate Instruction Cache and Data Cache: L 1 (data) L 1 (instruction) L 2 L 3 Size: 32 KB 256 KB 8 MB Associativity 8 -way set associative 4 -way set associative 8 -way set associative 16 -way set associative Source: CPU World

Why larger cache size is better? Cache performance depends on locality and the size

Why larger cache size is better? Cache performance depends on locality and the size of that locality Instruction Cache size (OK) Instruction Cache size (Too small)

Nested Locality A program typically has many levels of locality Example: - Smallest locality

Nested Locality A program typically has many levels of locality Example: - Smallest locality = 20 units - Medium locality = 200 units - Largest locality = 1000 units What should be the size of the cache? What if you have many cache levels?