140 likes | 292 Views
CPU Optimization. Cache Mapping. 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. Direct Mapping. Cache Location = MOD (Address, Cache Size)
E N D
CPU Optimization Cache Mapping
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
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 have “n ways” or slots • Most practical
Cache Considerations Factors that impact its performance
LocalityWhich program do you think works better with cache? Photoshop MP3 Player Software
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 during execution Data used (the song) Used only once - Good instruction locality- Bad data locality
Some Cache Systems Separate Instruction Cache and Data Cache Source: CPU World
Why larger cache size is better? Cache performance depends on locality and the size of that locality Instruction Cache size (Too small) Instruction Cache size (OK)
Nested LocalityA 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?