30
Pipelining Ahmad Adnan

Pipeliningqecuaf.com/.../teacher/lms_notes/47146_Pipelining.pdf · •Pipelining increases the overall instruction throughput. •In pipeline system, each segment consists of an input

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Pipeliningqecuaf.com/.../teacher/lms_notes/47146_Pipelining.pdf · •Pipelining increases the overall instruction throughput. •In pipeline system, each segment consists of an input

Pipelining

Ahmad Adnan

Page 2: Pipeliningqecuaf.com/.../teacher/lms_notes/47146_Pipelining.pdf · •Pipelining increases the overall instruction throughput. •In pipeline system, each segment consists of an input

• Pipelining organizes the execution of the multiple instructions simultaneously.

• Pipelining improves the throughput of the system.

• In pipelining the instruction is divided into the subtasks.

• Each subtask performs the dedicated task.

Page 3: Pipeliningqecuaf.com/.../teacher/lms_notes/47146_Pipelining.pdf · •Pipelining increases the overall instruction throughput. •In pipeline system, each segment consists of an input

• Pipelining is a process of arrangement of hardware elements of the CPU such that its overall performance is increased.

• Simultaneous execution of more than one instruction takes place in a pipelined processor.

• Please keep in mind the example of bottle filling plant. It will help to understand the topic.

Page 4: Pipeliningqecuaf.com/.../teacher/lms_notes/47146_Pipelining.pdf · •Pipelining increases the overall instruction throughput. •In pipeline system, each segment consists of an input

• Pipelining increases the overall instruction throughput.

• In pipeline system, each segment consists of an input register followed by a combinational circuit.

• The register is used to hold data and combinational circuit performs operations on it.

• The output of combinational circuit is applied to the input register of the next segment.

Page 5: Pipeliningqecuaf.com/.../teacher/lms_notes/47146_Pipelining.pdf · •Pipelining increases the overall instruction throughput. •In pipeline system, each segment consists of an input
Page 6: Pipeliningqecuaf.com/.../teacher/lms_notes/47146_Pipelining.pdf · •Pipelining increases the overall instruction throughput. •In pipeline system, each segment consists of an input

• The instruction is divided into 5 subtasks:

– instruction fetch,

– instruction decode,

– operand fetch,

– instruction execution and

– operand store.

Page 7: Pipeliningqecuaf.com/.../teacher/lms_notes/47146_Pipelining.pdf · •Pipelining increases the overall instruction throughput. •In pipeline system, each segment consists of an input

• The output of the first pipeline becomes the input for the next pipeline. It is like a set of data processing unit connected in series to utilize processor up to its maximum.

• An instruction in a process is divided into 5 subtasks likely,

Page 8: Pipeliningqecuaf.com/.../teacher/lms_notes/47146_Pipelining.pdf · •Pipelining increases the overall instruction throughput. •In pipeline system, each segment consists of an input

• 1 In the first subtask, the instruction is fetched.

• 2 The fetched instruction is decoded in the second stage.

• 3 In the third stage, the operands of the instruction are fetched.

• 4 In the fourth, arithmetic and logical operation are performed on the operands to execute the instruction.

• 5 In the fifth stage, the result is stored in memory.

Page 9: Pipeliningqecuaf.com/.../teacher/lms_notes/47146_Pipelining.pdf · •Pipelining increases the overall instruction throughput. •In pipeline system, each segment consists of an input

• understanding the division of the instruction into subtasks.

• how the n number of instructions in a process, are pipelined.

Page 10: Pipeliningqecuaf.com/.../teacher/lms_notes/47146_Pipelining.pdf · •Pipelining increases the overall instruction throughput. •In pipeline system, each segment consists of an input
Page 11: Pipeliningqecuaf.com/.../teacher/lms_notes/47146_Pipelining.pdf · •Pipelining increases the overall instruction throughput. •In pipeline system, each segment consists of an input

• Observe that when the Instruction fetch operation of the first instruction is completed in the next clock cycle the instruction fetch of second instruction gets started.

• This way the hardware never sits idle it is always busy in performing some or other operation.

• But, no two instructions can execute their same stage at the same clock cycle.

Page 12: Pipeliningqecuaf.com/.../teacher/lms_notes/47146_Pipelining.pdf · •Pipelining increases the overall instruction throughput. •In pipeline system, each segment consists of an input

Types of Pipelining

• 1. Arithmetic Pipelining

• It is designed to perform high-speed floating-point addition, multiplication and division. Here, the multiple arithmetic logic units are built in the system to perform the parallel arithmetic computation in various data format.

Page 13: Pipeliningqecuaf.com/.../teacher/lms_notes/47146_Pipelining.pdf · •Pipelining increases the overall instruction throughput. •In pipeline system, each segment consists of an input

2. Instruction Pipelining

• the number of instruction are pipelined and the execution of current instruction is overlapped by the execution of the subsequent instruction. It is also called instruction look ahead.

Page 14: Pipeliningqecuaf.com/.../teacher/lms_notes/47146_Pipelining.pdf · •Pipelining increases the overall instruction throughput. •In pipeline system, each segment consists of an input

3. Processor Pipelining

• the processors are pipelined to process the same data stream.

• The data stream is processed by the first processor and the result is stored in the memory block.

• The result in the memory block is accessed by the second processor.

• The second processor reprocesses the result obtained by the first processor and the passes the refined result to the third processor and so on.

Page 15: Pipeliningqecuaf.com/.../teacher/lms_notes/47146_Pipelining.pdf · •Pipelining increases the overall instruction throughput. •In pipeline system, each segment consists of an input

4. Uni-function Vs. Multifunction Pipelining

• The pipeline performing the precise function every time is uni functional pipeline.

• On the other hand, the pipeline performing multiple functions at a different time or multiple functions at the same time is multifunction pipeline.

Page 16: Pipeliningqecuaf.com/.../teacher/lms_notes/47146_Pipelining.pdf · •Pipelining increases the overall instruction throughput. •In pipeline system, each segment consists of an input

5. Static vs Dynamic Pipelining

• The static pipeline performs a fixed-function each time.

• The static pipeline is unifunctional.

• The static pipeline executes the same type of instructions continuously.

• Frequent change in the type of instruction may vary the performance of the pipelining.

• Dynamic pipeline performs several functions simultaneously. It is a multifunction pipelining.

Page 17: Pipeliningqecuaf.com/.../teacher/lms_notes/47146_Pipelining.pdf · •Pipelining increases the overall instruction throughput. •In pipeline system, each segment consists of an input

6. Scalar vs Vector Pipelining

• Scalar pipelining processes the instructions with scalar operands.

• The vector pipeline processes the instruction with vector operands.

Page 18: Pipeliningqecuaf.com/.../teacher/lms_notes/47146_Pipelining.pdf · •Pipelining increases the overall instruction throughput. •In pipeline system, each segment consists of an input

Pipelining Hazards

• Whenever a pipeline has to stall due to some reason it is called pipeline hazards.

• Four pipelining hazards

Page 19: Pipeliningqecuaf.com/.../teacher/lms_notes/47146_Pipelining.pdf · •Pipelining increases the overall instruction throughput. •In pipeline system, each segment consists of an input

1. Data Dependency

• Consider the following two instructions and their pipeline execution:

Page 20: Pipeliningqecuaf.com/.../teacher/lms_notes/47146_Pipelining.pdf · •Pipelining increases the overall instruction throughput. •In pipeline system, each segment consists of an input

• In the figure above, you can see that result of the Add instruction is stored in the register R2and we know that the final result is stored at the end of the execution of the instruction which will happen at the clock cycle t4.

• But the Sub instruction need the value of the register R2 at the cycle t3. So the Sub instruction has to stall two clock cycles. If it doesn’t stall it will generate an incorrect result. Thus depending of one instruction on other instruction for data is data dependency.

Page 21: Pipeliningqecuaf.com/.../teacher/lms_notes/47146_Pipelining.pdf · •Pipelining increases the overall instruction throughput. •In pipeline system, each segment consists of an input

2. Memory Delay

• When an instruction or data is required, it is first searched in the cache memory if not found then it is a cache miss.

• The data is further searched in the memory which may take ten or more cycles.

• So, for that number of cycle the pipeline has to stall and this is a memory delay hazard.

• The cache miss, also results in the delay of all the subsequent instructions

Page 22: Pipeliningqecuaf.com/.../teacher/lms_notes/47146_Pipelining.pdf · •Pipelining increases the overall instruction throughput. •In pipeline system, each segment consists of an input

3. Branch Delay

• Suppose the four instructions are pipelined I1, I2, I3, I4 in a sequence. The instruction I1 is a branch instruction and its target instruction is Ik.

• Now, processing starts and instruction I1 is fetched, decoded and the target address is computed at the 4th stage in cycle t3.

Page 23: Pipeliningqecuaf.com/.../teacher/lms_notes/47146_Pipelining.pdf · •Pipelining increases the overall instruction throughput. •In pipeline system, each segment consists of an input

• But till then the instructions I2, I3, I4 are fetched in cycle 1, 2 & 3 before the target branch address is computed.

• As I1 is found to be a branch instruction, the instructions I2, I3, I4 has to be discarded because the instruction Ik has to be processed next to I1. So, this delay of three cycles 1, 2, 3 is a branch delay.

Page 24: Pipeliningqecuaf.com/.../teacher/lms_notes/47146_Pipelining.pdf · •Pipelining increases the overall instruction throughput. •In pipeline system, each segment consists of an input
Page 25: Pipeliningqecuaf.com/.../teacher/lms_notes/47146_Pipelining.pdf · •Pipelining increases the overall instruction throughput. •In pipeline system, each segment consists of an input

• Pre fetching the target branch address will reduce the branch delay. Like if the target branch is identified at the decode stage then the branch delay will reduce to 1 clock cycle.

Page 26: Pipeliningqecuaf.com/.../teacher/lms_notes/47146_Pipelining.pdf · •Pipelining increases the overall instruction throughput. •In pipeline system, each segment consists of an input
Page 27: Pipeliningqecuaf.com/.../teacher/lms_notes/47146_Pipelining.pdf · •Pipelining increases the overall instruction throughput. •In pipeline system, each segment consists of an input

4. Resource Limitation

• If the two instructions request for accessing the same resource in the same clock cycle, then one of the instruction has to stall and let the other instruction to use the resource. This stalling is due to resource limitation.

• However, it can be prevented by adding more hardware.

Page 28: Pipeliningqecuaf.com/.../teacher/lms_notes/47146_Pipelining.pdf · •Pipelining increases the overall instruction throughput. •In pipeline system, each segment consists of an input

Advantages

• 1 Pipelining improves the throughput of the system.

• 2 In every clock cycle, a new instruction finishes its execution.

• 3 Allow multiple instructions to be executed concurrently.

Page 29: Pipeliningqecuaf.com/.../teacher/lms_notes/47146_Pipelining.pdf · •Pipelining increases the overall instruction throughput. •In pipeline system, each segment consists of an input

Disadvantages of Pipelining

• The design of pipelined processor is complex and costly to manufacture.

• The instruction latency is more.

Page 30: Pipeliningqecuaf.com/.../teacher/lms_notes/47146_Pipelining.pdf · •Pipelining increases the overall instruction throughput. •In pipeline system, each segment consists of an input

Assignment

• What is scalar and vector pipeline?

• Pipelining regarding RISC and SISC?

• “The design of pipelined processor is complex and costly to manufacture”. Justify the statement in your own words.

• Submit before next week 7th of March 2020.