Caching Flashcards

1
Q

What are two kinds of cache locality?

A

spatial locality
temporal locality

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is fully associative mapping in caches?What are the advantages and disadvantages?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is direct-mapped in caches? What are the advantages and disadvantages?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do you find the number of offset bits in the address?

A

no. of offset bits = log2(block size)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do you find the number of index bits in an address?

A

For direct-mapped
no. of index bits = log2(no. of lines)

For set-associative:
no. of index bits = log2(no. of sets)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What 3 components is an address broken down into when searching caches?

A
  1. tag
  2. index
  3. offset
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the correlation between the no. of pages and the size of the page table (in rows/no. of entries)?

A

The no. of pages = no. of rows in page table

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is common among blocks in a set?

A

(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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Explain the pseudo LRU replacement method.

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

LRU is the best cache replacement policy for _______________

A

small caches

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

LRU and random replacement are similar for __________________

A

large caches

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

List the replacement policies from best to worst for small caches? Large caches?

A

Small: LRU, FIFO, Random
Large: LRU and Random, FIFO

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are the two types of write policies? Define each one

A
  1. Write-through: Everytime the cache is modified, send it to the lower level.
  2. 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)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the advantage of write-through cache policy?

A

Simplifies coherency

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

List one way of measuring memory performance

A

Count the number of stalls at commit

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is a “compulsory” miss?

A

The first time a block is accessed, it won’t be in the cache. It will need to be added and will always be a miss

17
Q

What is a “capacity” miss?

A

The whole program can’t be fit into the cache so blocks are replaced and retrieved again

18
Q

What is a “conflict” miss?

A

When there is a miss because there is a finite number of blocks in a set. Otherwise wouldn’t occur in a fully associative cache

(When blocks share a set)

19
Q

What is a “coherence” miss?

A

When blocks get invalidated because another core is writing/has written to it

20
Q

What stages can a cache lookup be broken into in order to make a pipelined cache?

A

set select, tag search, data read, return data

21
Q

How can increasing block size lead to cache misses?

A

Large blocks can lead to conflict misses (due to lower associativity) or capacity misses (due to unused blocks in the cache).

22
Q

How does critical word first work?

A

If an address is requested, and it indexes the middle of a block, the memory burst starts from the requested word and provides the block, wrapping around to the front of the block. The result burst order could look something like 4, 5, 6, 7, 0, 1, 2, 3
The cache then reassembles the block in order

23
Q

What is early restart?

A

The requested data is passed to the processor as soon as it arrives (while the block is still filling)

24
Q

What is the most common virtual memory and cache combo?

A

VI/PT (Virtually Indexed, Physically Tagged)

25
Q

What is a problem with VI/PT virtual memory and cache?

A

Synonym Problem: Block shared with multiple processes assigned different virtual addresses

26
Q

What is the Homonym problem

A

Problem from VI/VT. Some virtual tag can reference multiple memory blocks.

27
Q

What is Content Addressable Memory used for? How does it work?

A

CAM is used for parallel tag checking in high associativity caches.
It uses matchlines that are precharged high. A search term (and its complement) is broadcast on the searchlines. If there is a mismatch, the cell discharges the matchline to ground

28
Q

What is the benefit to physically tagged, physically indexed? Drawback?

A

Benefit: Simple
Drawback: Slow due to translation

29
Q

What is the benefit to virtually indexed, physically tagged? Drawback?

A

Benefit: Faster since we can do cache lookup while translating
Drawback: Synonym problem

30
Q

What is the synonym problem w.r.t. virtual address translation?

A

Different processes using same block leads to duplicated blocks because they have different virtual addresses

31
Q

How is the synonym problem solved?

A

Page coloring. The OS assigns virtual page numbers s.t. the lower order bits used for the index are the same

32
Q

What is the homonym problem?

A

The same virtual tag can reference multiple memory blocks

33
Q

How is the homonym problem solved?

A

Adding an address space id (asid) or pid to the tags in order differentiate