Pipelining Flashcards

1
Q

What is pipelining

A

Pipelining is a technique used in computing and electronics to improve the efficiency and performance of a system by dividing a task into multiple smaller stages and processing those stages in parallel.

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

What can pipelining be related too

A

A factory, each stage of the pipeline performs a specific part of the task, and the stages are connected in a sequential manner, much like an assembly line in a factory.

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

What is instruction fetch IF

A

The processor retrieves the next instruction from memory and stores it in the instruction register (the location of the next task).

Key Components: Program Counter (PC), Memory Interface.

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

What is instruction decode ID

A

The instruction is decoded to determine the operation, source/destination operands, and immediate data.

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

What are the five common stages of a processor pipeline

A
  1. Instruction Fetch (IF)
  2. Instruction Decode (ID)
  3. Execute (EX)
  4. Memory Access (MEM)
  5. Write Back (WB)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What happens during the Execute (EX) stage

A

The actual operation (e.g., arithmetic, logic, branch) is performed using the ALU or branch units.

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

What happens during the Memory Access (MEM) stage

A

Data is fetched from or written to memory, as required by the instruction

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

What happens during the Write Back (WB) stage

A

The result of the instruction os written back to the destination (e.g., register of memory)

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

What is the role of the ALU in pipelining

A

The ALU performs the athletic and logical operations during the Execute (EX) stage

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

What is an example of an instruction broken into pipeline stages?

A

IF: Fetch the instruction.
ID: Decode the operation and operands.
EX: Add values in R2 and R3 using the ALU.
MEM: Not needed for this instruction.
WB: Write the result to R1.

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

What are pipelining hazards

A

Issues like data hazards, control hazards, and structural hazards that disrupt smooth pipeline execution.

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

What is a data hazard in pipelining

A

A situation where one instruction depends on the result of a previous instruction.

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

What is a control hazard in pipelining

A

A delay caused by changed in instruction flow, such as branches or jumps

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

What is a structural hazard in pipelining

A

When two or more stages compete for the same resource, causing a conflict.

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

What are some pipeline optimisation techniques

A

Branch prediction, hazard handling (e.g., forwarding, stalling), and pipeline registers/buffers.

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

What is branch prediction in pipelining

A

A technique to guess the outcome of a branch instruction to reduce control hazards.

17
Q

What is the main benefit of pipelining

A

It increases instruction throughput by processing multiple instructions simultaneously.

18
Q

What is a jump in a processor

A

A jump is an instruction that unconditionally changes the flow of execution to a different part of the program.

18
Q

What is a branch in a processor

A

a conditional instruction that changes the flow of execution based on a condition

19
Q

What is a conditional branch

A

A branch that changes the flow only if a specific condition is met (e.g., BEQ R1, R2, Label). E.g. in if or while statements

20
Q

What is an unconditional branch

A

A branch that always changes the flow of execution, similar to a jump (e.g., B Label).

21
Q

How are branches and jumps different

A

Branches can be conditional or unconditional.
Jumps are always unconditional.

22
Q

Why do branches and jumps cause control hazards in pipelining?

A

They disrupt the normal sequential instruction flow, making it difficult to predict the next instruction.

23
Q

What is branch prediction

A

A technique where the processor guesses the outcome of a branch to minimize delays caused by control hazards.

24
Q

What is branch prediction in a processor

A

A technique where the processor guesses the outcome of a branch instruction (e.g., conditional jumps or function calls) before it is fully resolved.

25
Q

Why is branch prediction important?

A

It allows the processor to decide whether to follow a branch (jump to another part of the code) or continue with the next sequential instruction, reducing pipeline stalls.

26
Q

What is a static branch predictor?

A

A branch predictor that makes fixed predictions based on a simple rule without considering runtime behavior.

27
Q

What are common techniques used in static branch prediction?

A

Always predict “taken.”
Always predict “not taken.”
Predict backward branches (loops) as taken.

28
Q

What is a hybrid branch predictor?

A

A predictor that combines multiple branch prediction techniques to improve accuracy.

29
Q

What is an example of a hybrid branch predictor?

A

The Tournament Predictor, which dynamically selects the best prediction strategy for each branch.

30
Q

What is speculative execution

A

A performance optimization technique where the processor guesses the outcome of conditional operations and begins executing instructions ahead of time.

31
Q

How does speculative execution avoid pipeline stalls?

A

By keeping the processor’s pipeline filled with instructions, minimizing idle time while waiting for branch or memory fetch decisions.

32
Q

What happens if speculation is correct?

A

The results are committed to the processor’s architectural state, making them visible to software.

33
Q

What happens if speculation is incorrect?

A

The pipeline is flushed, the speculative instructions are discarded, and the processor rolls back to the correct state before the branch.

34
Q

What is out-of-order execution?

A

A technique where the processor executes instructions based on a data flow graph rather than program order, bypassing stalled instructions.

35
Q

How does in-order execution differ from out-of-order execution?

A

In-order: Executes instructions in the exact sequence they appear. Delays in one instruction stall the entire pipeline.

Out-of-order: Executes instructions that are ready, bypassing stalled instructions.

36
Q

What is the purpose of committing instructions in out-of-order execution?

A

To ensure the program maintains its intended semantics by committing results in order, even if instructions execute out-of-order.

37
Q

What is the initial state of a 2-bit branch predictor?

A

The initial state is typically “10” (Weakly Taken).

38
Q

What happens in speculative execution when encountering a branch-heavy loop

A

The processor guesses the outcome of the branch and begins executing the appropriate set of instructions, improving efficiency.