






























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!































“quiz 5” recap
quiz 6 recap
advanced caching
Hand a bunch of stuff back.
Misses happen for different reasons
The three C’s (types of cache misses)
Compulsory: The program has never requested this data before. A miss is mostly unavoidable.
Conflict: The program has seen this data, but it was evicted by another piece of data that mapped to the same “set” (or cache line in a direct mapped cache)
Capacity: The program is actively using more data than the cache can hold.
Different techniques target different C’s
Compulsory misses are difficult to avoid
Caches are effectively a guess about what data the processor will need.
One technique: Prefetching (240A to learn more)
In this case, the processor could identify the pattern and proactively “prefetch” data program will ask for.
Current machines do this alot...
Keep track of delta= thisAddress - lastAddress, it’s consistent, start fetching thisAddress + delta. for(i = 0;i < 100; i++) { sum += data[i]; }
HW Prefetching
In this case, the processor could identify the pattern and proactively “prefetch” data program will ask for.
Current machines do this alot...
Keep track of delta= thisAddress - lastAddress, it’s consistent, start fetching thisAddress + delta. for(i = 0;i < 1000000; i++) { sum += data[i]; }
Conflict misses occur because too much data maps to the same “set”
Increase the number of sets (i.e., cache capacity)
Increase the size of the sets (i.e., the associativity)
The compiler and OS can help here too
Colliding Threads and Data
This means that thread stacks will end up occupying the same parts of the cache.
Large data structures (e.g., arrays) are also often aligned. Randomizing malloc() can help here. Stack Thread 0 0x Stack Thread 1 0x Stack Thread 2 0x Stack Thread 3 0x Stack Thread 0 0x Stack Thread 1 0x Stack Thread 2 0x Stack Thread 3 0x
Increase capacity!
More associativity or more associative “sets”
Costs area and makes the cache slower.
Cache hierarchies do this implicitly already:
if the working set “falls out” of the L1, you start using the L2.
Poof! you have a bigger, slower cache.
In practice, you make the L1 as big as you can within your cycle time and the L2 and/or L3 as big as you can while keeping it on chip.
Increasing Locality in the Compiler or Application
Live Demo... The return! Part Deux!
Consider a direct mapped cache with 16 blocks, a block size of 16 bytes, and the application repeat the following memory access sequence:
0x80000000, 0x80000008, 0x80000010, 0x80000018, 0x
a direct mapped cache with 16 blocks, a block size of 16 bytes
16 = 2^4 : 4 bits are used for the index
16 = 2^4 : 4 bits are used for the byte offset
The tag is 32 - (4 + 4) = 24 bits
For example: 0x 80000010 tag index offset