Caching Flashcards
What are two kinds of cache locality?
spatial locality
temporal locality
What is fully associative mapping in caches?What are the advantages and disadvantages?
Full associative is when any block of memory can be loaded in any line in the cache.
Advantage: Most flexible, high hit rate
Disadvantage: Most expensive since all the tags need to be checked in parallel
What is direct-mapped in caches? What are the advantages and disadvantages?
A block in memory can only be placed in 1 particular line given by (block number % no. of lines)
Disadvantage: Least flexible
Advantage: Least expensive (need to only check 1 tag per access)
How do you find the number of offset bits in the address?
no. of offset bits = log2(block size)
How do you find the number of index bits in an address?
For direct-mapped
no. of index bits = log2(no. of lines)
For set-associative:
no. of index bits = log2(no. of sets)
What 3 components is an address broken down into when searching caches?
- tag
- index
- offset
What is the correlation between the no. of pages and the size of the page table (in rows/no. of entries)?
The no. of pages = no. of rows in page table
What is common among blocks in a set?
(Block number % no. of sets) is the same. As a result, the occupy the same set and we only need to search each way within a set
Edit: The block index is the same
Explain the pseudo LRU replacement method.
There is 1 bit reserved for each way in a set. When each way is accessed, set its bit.
If all bits are in a set are 1, reset all but the last accessed
Replace a block with an unset bit
LRU is the best cache replacement policy for _______________
small caches
LRU and random replacement are similar for __________________
large caches
List the replacement policies from best to worst for small caches? Large caches?
Small: LRU, FIFO, Random
Large: LRU and Random, FIFO
What are the two types of write policies? Define each one
- Write-through: Everytime the cache is modified, send it to the lower level.
- Write-back: Only modify the cache and set the dirty bit. The block is written back to the lower level when replaced (only if dirty bit is set)
What is the advantage of write-through cache policy?
Simplifies coherency
List one way of measuring memory performance
Count the number of stalls at commit