3 Pipelining Pipeline:: "Folder" Takes 20 Minutes
3 Pipelining Pipeline:: "Folder" Takes 20 Minutes
Pipeline:
Pipelining is a technique where multiple instructions are overlapped during
execution. It is a way of speeding up the execution of instructions.
Pipelining is the process of accumulating instruction from the processor
through a pipeline. It allows storing and executing instructions in an orderly
process. It is also known as pipeline processing. Pipeline is divided into
stages and these stages are connected with one another to form a pipe like
structure. Instructions enter from one end and exit from another end.
Traditional Pipeline Concept
Laundry Example
• Any, Bran, Charles, David each have one load of clothes to wash, dry,
and fold.
• Washer takes 30 minutes
• Dryer takes 40 minutes
• “Folder” takes 20 minutes
Sequential Laundry
Pipelined Laundry
Observations:
A task has a series of stages;
Stage dependency:
e.g wash before dry;
Multi tasks with overlapping stages;
Simultaneously to speed up;
Slowest stage determines the finish time;
TYPES OF PIPELINE:
ARITHMETIC PIPELINE
INSTRUCTION PIPELINE
ARITHMETIC PIPELINE:
Arithmetic pipelines are usually found in most of the computers. They are
used for floating point operations, multiplication of fixed point numbers
etc. For example: The input to the Floating Point Adder pipeline is:
X = A*2^a
Y = B*2^b
Here A and B are mantissas (significant digit of floating point numbers),
while a and b are exponents.
Registers are used for storing the intermediate results between the above
operations.
Example:
X= 0.952 x 10^3
Y= 0.82 x 10^2
Instruction Pipeline:
Instruction Fetch:
➢ IF stage is responsible for obtaining the requested instruction from
memory.
➢ The instruction and the program counter are stored in the register as
temporary storage.
Decode Instruction:
➢ DI stage is responsible for decoding the instruction and sending out
the various control lines to the other parts of the processor.
Calculate Operands:
➢ CO stage is where any calculations are performed. The main
component in this stage is ALU. The ALU is made up of arithmetic,
logic and capabilities.
Fetch Operands & Execute Instructions:
➢ FO and EI stages are responsible for storing and loading values to and
from memory. They also responsible for input and output from the
processor respectively.
Write Operands:
➢ WO stage is responsible for writing the result of calculation, memory
access or input into register file.
Stages/time 1 2 3 4 5 6 7 8 9 10
S1 I1 I2 I3 I4 I5
S2 I1 I2 I3 I4 I5
S3 I1 I2 I3 I4 I5
S4 I1 I2 I3 I4 I5
S5 I1 I2 I3 I4 I5
S6 I1 I2 I3 I4 I5
Here we will assume a segment pipeline as 'k' and the clock cycle time 'Tp'.
Suppose the pipeline processor needs to complete the 'n' number of tasks. Now
the first instruction will come out from the pipeline by taking the 'k' cycle. On the
other hand, 'n-1' instructions will take only '1' cycle each. That means the 'n-1'
instruction will take the total 'n-1' cycle. In a pipeline processor, when we try to
execute the 'n' instructions, then the time taken to do this is described as follows:
ET pipeline = k + n -1 cycle
= (k + n -1) Tp
In a non-pipeline processor, when we take the same case and try to execute the
'n' instructions, then the time taken to do this is described as follows:
ET non-pipeline = n * k * Tp
So, when we perform 'n' tasks on the same processor, the speedup (S) of pipeline
processor over non-pipelined processor is described as follows:
S = ET non-pipeline / ET pipeline
S = [n * k] / [k + n - 1]
The following relation will contain if the n number of tasks is larger than 'k' that
means n >>k.
S=n*k/n
S=k
Here S is used to show the max speed up, and Smax is used to indicate the
Maximum speed up.
So, Efficiency = S / k
Now throughput can be described like this:
So throughput = n / (k + n + 1) * Tp
Pipeline Hazards:
1. Timing Variations: All stages cannot take same amount of time. This problem
generally occurs in instruction processing where different instructions have
different operand requirements and thus different processing time.
2. Data Hazards: When several instructions are in partial execution, and if they
reference same data then the problem arises. We must ensure that next
instruction does not attempt to access data before the current instruction,
because this will lead to incorrect results.
3. Branching: In order to fetch and execute the next instruction, we must know
what that instruction is. If the present instruction is a conditional branch, and its
result will lead us to the next instruction, then the next instruction may not be
known until the current one is processed.