Memory Hierarchy Flashcards

1
Q

Draw a diagram of a machine’s memory hierarchy

A

.

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

Where is SRAM found? What are its characteristics?

A

On processor chip
Low latency, high bandwidth, size limited by chip area, read/write size can easily be byte level

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

Where is DRAM found? What are its characteristics?

A

Off chip
Higher latency
High bandwidth
Reads/writes are in small blocks, transferred as burts

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

What type of hardware does page-based virtual memory use? What are its characteristics?

A

Magnetic hard disk or SSD
High latency, lower bandwidth, reads/writes in larger blocks needed for extensive error detection and correction codes

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

Describe static multiple issue

A
  • Compiler groups instructions to be executed together into “issue slots”
  • Compiler detects and avoids hazards
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Describe dynamic multiple issue

A
  • CPU chooses instructions to issue each cycle
  • Compiler can help reorder instructions
  • CPU resolves hazards at runtime
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is speculation?

A

Guess what to do with an instruction, start operation asap, check whether guess was right and either complete the sequence or roll-back and do the right thing

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

Give an example of speculation

A

Speculate on branch outcome - roll back if different path is taken

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

What makes pipelining harder?

A

Poor ISA design:
1. Complex instruction sets
2. Complex addressing modes
3. Delayed branches

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

What is the principle of locality?

A

Programs access a small proportion of their address space at any time, giving rise to spatial and temporal locality

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

What is temporal locality?

A

Items accessed recently are likely to be accessed again soon

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

Give 2 examples of temporal locality

A
  1. Instructions in a loop
  2. Loop counters
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is spatial locality?

A

Items near those accessed recently are likely to be accessed soon

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

Give 2 examples of spatial locality

A
  1. Sequential instruction access
  2. Array data
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is cache?

A

Memory that holds recently used data so that it can be accessed with a lower latency next time to alleviate the von Neumann bottleneck

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

What is a cache hit? What happens?

A

Data is found in the cache, so read

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

What is a cache miss? What happens?

A

Data not in cache, so fetch from next level in memory hierarchy

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

Write the equation for miss rate

A

Miss rate = number of cache misses / number of memory accesses

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

Draw a diagram of a crude direct-mapped cache

A

.

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

In a crude direct-mapped cache, for a given address, how many places are there to look?

A

1

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

Give a real life example of a direct-mapped cache

A

Order all books by first two letters
Go to the right place and read the tag of the relevant book to check it is the correct one - there can only be one entry for each tag

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

Which property must each item in a crude direct-mapped cache have?

A

A unique hash function value ie. cache address/tag

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

What does the hash function do in a crude direct-mapped cache?

A

Takes the load address and converts it to the cache address, where the data is stored

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

Give a disadvantage of a crude direct-mapped cache

A

Storing the address as a tag for every data item is a big overhead

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
What is a simple direct-mapped cache?
Amortises the cost of crude direct-mapped cache by storing several data items per tag
25
What is a cache line?
Some number of contiguous words in memory. Links with spatial locality and links with DRAM bursts when filling cache lines from main memory
26
What is a fully associative cache?
There is no hash function ordering, must search through whole cache every time
27
Draw a diagram of a simple direct-mapped cache
.
28
What is the effect of larger cache lines in a variable sized cache? Why? What is a disadvantage that can override this benefit?
Reduce miss rate due to spatial locality. Larger miss penalty, can override the benefit of reduced miss rate
29
What is the effect of larger cache lines in a fixed size cache? Why?
Fewer cache lines so more competition so increased miss rate Pollution so more data read in that may never be read
30
How can we avoid the larger miss penalty that comes with larger cache lines?
Using early restart - give a word to the CPU as soon as we get it, don’t wait for the rest of the words
31
How does the CPU proceed on a cache hit?
Normally ie. carry on and fetch the next instruction
32
How does the CPU proceed on a cache miss? How does this differ between instruction and data cache misses?
1. Stall the CPU pipeline 2. Fetch block from next level of hierarchy 3. If it is an instruction cache miss, restart instruction fetch. If it is a data cache miss, complete data access
33
What are the two ways we can handle a data-write hit (ie. the block of data to update is in the cache)?
1. Write-back - just update the cache line 2. Write through - also update memory for consistency
34
What is a disadvantage of write-through?
It makes writes take longer
35
What is a solution to make write-through more efficient?
Use a write buffer
36
What is a write buffer?
Holds data waiting to be written to memory. CPU continues immediately and only stalls if write buffer is already full
37
What do we need to keep track of in write-back? Why?
Whether each cache-line is dirty ie. holds new data. When a dirty block is replaced, write it back to memory
38
How can a write buffer be used in write-back too?
Allow replacement cache line to be read first
39
List how we can handle write misses for write-through and write-back
For write-through: 1. Allocate on miss 2. Write around For write-back: 1. Allocate on miss
40
What is allocate on miss?
Fetch the cache line (with write-back: to avoid having a cache line where some words or bytes are invalid)
41
What is write around?
Don't fetch the cache line, instead write the data to the next level in the hierarchy
42
Draw a diagram of a fully associative cache
.
43
How much restriction is there on where data can be stored in a fully associative cache?
No restrictions
44
What happens to the upper address bits (tag) of a memory address in a fully associative cache?
They are broadcast to every cache location, each with its own comparator. Hardware is parallel, so all comparisons are done simultaneously when the CPU is trying to access a data block
45
How does FPGA circuit area compare between direct-mapped and fully-associative caches?
- Direct-mapped caches can be efficiently implemented using embedded block RAM - Fully-associative caches have to be made out of resisters and logic so are huge
46
How does efficiency compare between direct-mapped and fully-associative caches?
Fully-associative caches tend to have higher hit rate than a direct-mapped cache that stores the same amount of data - no cache location conflicts, every cache location can be checked at once on data access
47
What is the advantage of a set associative cache?
Combines the efficiency of a direct-mapped cache with the higher hit rate of a more associative cache
48
What is a set associative cache?
Has N direct-mapped caches, reads look in all N caches for data, so cache has N-way associativity
49
How many items can be stored with the same tag in a set-associative cache?
N
50
What is the replacement policy for a direct-mapped cache?
No choice
51
What is the replacement policy for a set-associative or fully-associative cache?
Replace a non-valid entry if there is one 1. Least recently used (LRU) - choose the one unused for the longest time 2. Not last used - approximates LRU and is simpler to implement 3. Random - simple to implement, gives approximately the same performance as LRU for high associativity
52
What is a victim cache? How is it used?
Augment a direct-mapped cache with a tiny full-associative cache, then give evicted cache lines a second chance in the victim cache. Eliminates some pathological missed of a direct-mapped cache but not as effective as set-associative
53
List the 3 sources of cache misses
1. Compulsory misses 2. Capacity misses 3. Conflict misses
54
What is a compulsory miss?
First access to a block
55
What is a capacity miss?
Due to finite cache size A replaced block is accessed again
56
What is a conflict miss?
In a non-fully associative cache due to competition for entries in a set
57
What prevents the construction of a large, low-latency memory requiring us to use a hierarchy of memories to approximate this?
Physical constraints
58
There is no hash function in a simple direct-mapped cache. Where does the cache address come from?
The index bits. The upper address bits are used to tag the data
59
What is the tag in a crude direct-mapped cache?
Data load address