Exam 2 Review - Pipelining Flashcards

1
Q

(T/F) Pipelining improves performance by making individual instructions execute faster

A

False: The instructions themselves do not execute faster but the throughput of the system increases

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

(T/F) A control hazard occurs when an instruction cannot execute because data that it is dependent on is not available yet

A

False: The description above is for a data hazard. A control hazard occurs when the proper instruction cannot execute in the right cycle because the instruction fetched was not the correct one. These occur with branch instructions, like cbnz.

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

(T/F) A structural hazard could occur if we only had one memory for both program instructions and data

A

False: With only one memory, we would not be able to fetch an instruction and load data into a register in the same cycle.

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

(T/F) A load-use hazard requires a stall before the load instruction, even with forwarding

A

False: The stall must be after the load because unlike other instructions where the result comes out of the ALU in the third stage, the result here comes out of data memory in the fourth stage.

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

What is the purpose of the forwarding unit in the hardware?

A

The forwarding unit helps prevent certain stalls from data hazards by sending the result of an operation immediately to a previous stage and avoiding having to wait until the write-back stage.

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

In the slides and book we used terms like IF/ID, ID/EX, MEM/WB, etc. What exactly is meant by those terms?

A

X/Y refers to the buffers in the current stage of the pipeline. The first value is the buffer we are reading from. the second value is the buffer we are writing to. For example, in ID/EX we are reading the data from the instruction decode buffer and writing it to the execution buffer.

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

Given our five-stage pipeline and n number of instructions, write a formula for calculating how many cycles it would take to finish all the instructions if there were no hazards.

A

The first instruction takes 5 cycles. Every instruction after adds an addition cycle if there were no hazards. A formula for n instructions then might be

5 + n – 1 cycles

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

(With forwarding) identify any potential hazards in the rightmost column. How many cycles do the instructions take to finish?

A

11 total cycles 5 cycles for the first instruction, 1 cycle for other 5 instructions, and 1 cycle for the load-use hazard.

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

List some of the strategies we can implement to deal with control hazards.

A

Static Prediction: Assume that the branch is always/never taken. Only take branches backward/forward

Dynamic Prediction: Use bits to try and predict whether we should branch or not (1-bit or 2-bit predictors). If the MSB is a 1, then we predict a branch, else we do not. We update the values of the bit(s) depending on if the prediction was correct or incorrect.

Branch Delay Slot: Re-order the instructions so that the instruction immediately following the branch is not dependent on the branch

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

List and describe the three hazards we are concerned with in Pipelining.

A

Structural - Multiple functions try to access the same memory in the same cycle

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

Let’s say we have a 2-bit predictor. Our 2-bit predictor starts out at 00 and we enter a for-loop that runs 12 times. What is the prediction accuracy for this branch?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q
A
17
Q
A