71
Principles of Linear Pipelining

Principles of Linear Pipelining

Embed Size (px)

DESCRIPTION

Principles of Linear Pipelining. Principles of Linear Pipelining. In pipelining, we divide a task into set of subtasks. The precedence relation of a set of subtasks {T 1 , T 2 ,…, T k } for a given task T implies that the same task T j cannot start until some earlier task T i finishes. - PowerPoint PPT Presentation

Citation preview

Page 1: Principles of Linear Pipelining

Principles of Linear Pipelining

Page 2: Principles of Linear Pipelining

Principles of Linear Pipelining

• In pipelining, we divide a task into set of subtasks.

• The precedence relation of a set of subtasks {T1, T2,…, Tk} for a given task T implies that the same task Tj cannot start until some earlier task Ti finishes.

• The interdependencies of all subtasks form the precedence graph.

Page 3: Principles of Linear Pipelining

Principles of Linear Pipelining

• With a linear precedence relation, task Tj cannot start until earlier subtasks { Ti} for all (i < j) finish.

• A linear pipeline can process subtasks with a linear precedence graph.

Page 4: Principles of Linear Pipelining

Principles of Linear Pipelining

• A pipeline can process successive subtasks if

• Subtasks have linear precedence order• Each subtasks take nearly same time to

complete

Page 5: Principles of Linear Pipelining

Basic Linear Pipeline

• L: latches, interface between different stages of pipeline

• S1, S2, etc. : pipeline stages

Page 6: Principles of Linear Pipelining

Basic Linear Pipeline • It consists of cascade of processing stages. • Stages : Pure combinational circuits

performing arithmetic or logic operations over the data flowing through the pipe.

• Stages are separated by high speed interface latches.

• Latches : Fast Registers holding intermediate results between stages

• Information Flow are under the control of common clock applied to all latches

Page 7: Principles of Linear Pipelining

Basic Linear Pipeline

• L: latches, interface between different stages of pipeline

• S1, S2, etc. : pipeline stages

Page 8: Principles of Linear Pipelining

Basic Linear Pipeline• The flow of data in a linear pipeline having four stages

for the evaluation of a function on five inputs is as shown below:

Page 9: Principles of Linear Pipelining

Basic Linear Pipeline

• The vertical axis represents four stages • The horizontal axis represents time in units of

clock period of the pipeline.

Page 10: Principles of Linear Pipelining

Clock Period (τ) for the pipeline

• Let τi be the time delay of the circuitry Si and t1

be time delay of latch. • Then the clock period of a linear pipeline is

defined by

• The reciprocal of clock period is called clock frequency (f = 1/τ) of a pipeline processor.

111

max ttt mi

k

i

Page 11: Principles of Linear Pipelining

Performance of a linear pipeline• Consider a linear pipeline with k stages. • Let T be the clock period and the pipeline is initially

empty. • Starting at any time, let us feed n inputs and wait till

the results come out of the pipeline.• First input takes k periods and the remaining (n-1)

inputs come one after the another in successive clock periods.

• Thus the computation time for the pipeline Tp is

Tp = kT+(n-1)T = [k+(n-1)]T

Page 12: Principles of Linear Pipelining

Performance of a linear pipeline• For example if the linear pipeline have four

stages with five inputs. • Tp = [k+(n-1)]T = [4+4]T = 8T

Page 13: Principles of Linear Pipelining

Example : Floating Point Adder Unit

Page 14: Principles of Linear Pipelining

Floating Point Adder Unit• This pipeline is linearly constructed with 4

functional stages.• The inputs to this pipeline are two normalized

floating point numbers of the formA = a x 2p

B = b x 2q

where a and b are two fractions and p and q are their exponents.

• For simplicity, base 2 is assumed

Page 15: Principles of Linear Pipelining

Floating Point Adder Unit

• Our purpose is to compute the sum C = A + B = c x 2r = d x 2s

where r = max(p,q) and 0.5 ≤ d < 1• For example:

A=0.9504 x 103

B=0.8200 x 102

a = 0.9504 b= 0.8200p=3 & q =2

Page 16: Principles of Linear Pipelining

Floating Point Adder Unit

• Operations performed in the four pipeline stages are :

1. Compare p and q and choose the largest exponent, r = max(p,q)and compute t = |p – q|Example: r = max(p , q) = 3t = |p-q| = |3-2|= 1

Page 17: Principles of Linear Pipelining

Floating Point Adder Unit

2. Shift right the fraction associated with the smaller exponent by t units to equalize the two exponents before fraction addition.

• Example: Smaller exponent, b= 0.8200 Shift right b by 1 unit is 0.082

Page 18: Principles of Linear Pipelining

Floating Point Adder Unit

3. Perform fixed-point addition of two fractions to produce the intermediate sum fraction c, where 0 ≤ c < 1

• Example : a = 0.9504 b= 0.082c = a + b = 0.9504 + 0.082 = 1.0324

Page 19: Principles of Linear Pipelining

Floating Point Adder Unit4. Count the number of leading zeros (u) in

fraction c and shift left c by u units to produce the normalized fraction sum d = c x 2u, with a leading bit 1. Update the large exponent s by subtracting s = r – u to produce the output exponent.

• Example:c = 1.0324 , u = -1 right shift d = 0.10324 , s= r – u = 3-(-1) = 4C = 0.10324 x 104

Page 20: Principles of Linear Pipelining

Floating Point Adder Unit

• The above 4 steps can all be implemented with combinational logic circuits and the 4 stages are:

1. Comparator / Subtractor2. Shifter3. Fixed Point Adder4. Normalizer (leading zero counter and shifter)

Page 21: Principles of Linear Pipelining

4-STAGE FLOATING POINT ADDERA = a x 2p B = b x 2q

a b AB

Exponentsubtractor

Fractionselector

Fraction with min(p,q)

Right shifter

Otherfraction

t = |p - q|r = max(p,q)

Fractionadder

Leading zerocounter

r c

Left shifterc

Exponentadder

r

s d

d

Stages:

S1

S2

S3

S4

C= X + Y = d x 2s

Page 22: Principles of Linear Pipelining

Example for floating-point adder Exponents

Segment 1:

Segment 2:

Segment 3:

Segment 4:

R R

R

R

R

R

R

R

Adjustexponent

Normalizeresult

Addmantissas

Align mantissas

Choose exponent

Compareexponents

by subtraction

Difference=3-2=1

Mantissasba A B

For example:X=0.9504*103

Y=0.8200*102

0.082

3

S=0.9504+0.082=1.0324

0.103244

Page 23: Principles of Linear Pipelining

Performance Parameters

• The various performance parameters of pipeline are :

1. Speed-up2. Throughput3. Efficiency

Page 24: Principles of Linear Pipelining

Speedup• Speedup is defined as

Speedup = Time taken for a given computation by a non-pipelined functional unit Time taken for the same computation by a pipelined version

• Assume a function of k stages of equal complexity which takes the same amount of time T.

• Non-pipelined function will take kT time for one input.

• Then Speedup = nkT/(k+n-1)T = nk/(k+n-1)

Page 25: Principles of Linear Pipelining

Speed-up

• For e.g., if a pipeline has 4 stages and 5 inputs, its speedup factor is

Speedup = ?

Page 26: Principles of Linear Pipelining

Efficiency• It is an indicator of how efficiently the

resources of the pipeline are used. • If a stage is available during a clock period,

then its availability becomes the unit of resource.

• Efficiency can be defined as

ncomputatio that during available units timestage ofnumber Total

n computatio during usedactually units timestage ofNumber = Efficiency

Page 27: Principles of Linear Pipelining

Efficiency

Page 28: Principles of Linear Pipelining

Efficiency

• No. of stage time units = nk– there are n inputs and each input uses k stages.

• Total no. of stage-time units available = k[ k + (n-1)] – It is the product of no. of stages in the pipeline (k)

and no. of clock periods taken for computation(k+(n-1)).

Page 29: Principles of Linear Pipelining

Throughput

• It is the average number of results computed per unit time.

• For n inputs, a k-staged pipeline takes [k+(n-1)]T time units

• Then,Throughput = n / [k+n-1] T = nf / [k+n-1] where f is the clock frequency

– Throughput = Efficiency x Frequency

Page 30: Principles of Linear Pipelining

Point no 2Classification of Pipelining

Page 31: Principles of Linear Pipelining

Handler’s Classification

• Based on the level of processing, the pipelined processors can be classified as:

1.Arithmetic Pipelining2.Instruction Pipelining3.Processor Pipelining

Page 32: Principles of Linear Pipelining

Arithmetic Pipelining

• The arithmetic logic units of a computer can be segmented for pipelined operations in various data formats.

• Example : Star 100

Page 33: Principles of Linear Pipelining

Arithmetic Pipelining

Page 34: Principles of Linear Pipelining

Instruction Pipelining• The execution of a stream of instructions can

be pipelined by overlapping the execution of current instruction with the fetch, decode and operand fetch of the subsequent instructions

• It is also called instruction look-ahead

Page 35: Principles of Linear Pipelining

Processor Pipelining

• This refers to the processing of same data stream by a cascade of processors each of which processes a specific task

• The data stream passes the first processor with results stored in a memory block which is also accessible by the second processor

• The second processor then passes the refined results to the third and so on.

Page 36: Principles of Linear Pipelining

Processor Pipelining

Page 37: Principles of Linear Pipelining

Li and Ramamurthy's Classification

• According to pipeline configurations and control strategies, Li and Ramamurthy classify pipelines under three schemes– Unifunction v/s Multi-function Pipelines– Static v/s Dynamic Pipelines– Scalar v/s Vector Pipelines

Page 38: Principles of Linear Pipelining

Uni-function v/s Multi-function Pipelines

Page 39: Principles of Linear Pipelining

Unifunctional Pipelines

• A pipeline unit with fixed and dedicated function is called unifunctional.

• Example: CRAY1 (Supercomputer - 1976)• It has 12 unifunctional pipelines described in

four groups:– Address Functional Units:• Address Add Unit• Address Multiply Unit

Page 40: Principles of Linear Pipelining

Unifunctional Pipelines

– Scalar Functional Units• Scalar Add Unit• Scalar Shift Unit• Scalar Logical Unit• Population/Leading Zero Count Unit

– Vector Functional Units• Vector Add Unit• Vector Shift Unit• Vector Logical Unit

Page 41: Principles of Linear Pipelining

Unifunctional Pipelines

– Floating Point Functional Units• Floating Point Add Unit • Floating Point Multiply Unit• Reciprocal Approximation Unit

Page 42: Principles of Linear Pipelining

Multifunctional

• A multifunction pipe may perform different functions either at different times or same time, by interconnecting different subset of stages in pipeline.

• Example 4X-TI-ASC (Supercomputer - 1973)

Page 43: Principles of Linear Pipelining

Static Vs Dynamic Pipeline

Page 44: Principles of Linear Pipelining

Static Pipeline• It may assume only one functional

configuration at a time• Static pipelines are preferred when

instructions of same type are to be executed continuously

• A unifunction pipe must be static.

Page 45: Principles of Linear Pipelining

Dynamic pipeline

• It permits several functional configurations to exist simultaneously

• A dynamic pipeline must be multi-functional• The dynamic configuration requires more

elaborate control and sequencing mechanisms than static pipelining

Page 46: Principles of Linear Pipelining

Scalar Vs Vector Pipeline

Page 47: Principles of Linear Pipelining

Scalar Pipeline

• It processes a sequence of scalar operands under the control of a DO loop

• Instructions in a small DO loop are often prefetched into the instruction buffer.

• The required scalar operands are moved into a data cache to continuously supply the pipeline with operands

• Example: IBM System/360 Model 91

Page 48: Principles of Linear Pipelining

Vector Pipelines

• They are specially designed to handle vector instructions over vector operands.

• Computers having vector instructions are called vector processors.

• The design of a vector pipeline is expanded from that of a scalar pipeline.

• The handling of vector operands in vector pipelines is under firmware and hardware control.

• Example : Cray 1

Page 49: Principles of Linear Pipelining

Point no 3Generalized Pipeline and

Reservation Table

Page 50: Principles of Linear Pipelining

3 stage non-linear pipeline

• It has 3 stages Sa, Sb and Sc and latches.• Multiplexers(cross circles) can take more than

one input and pass one of the inputs to output

• Output of stages has been tapped and used for feedback and feed-forward.

SaSa SbSb ScScInput Output B

Output A

Page 51: Principles of Linear Pipelining

3 stage non-linear pipeline

• The above pipeline can perform a variety of functions.

• Each functional evaluation can be represented by a particular sequence of usage of stages.

• Some examples are:1. Sa, Sb, Sc2. Sa, Sb, Sc, Sb, Sc, Sa3. Sa, Sc, Sb, Sa, Sb, Sc

Page 52: Principles of Linear Pipelining

Reservation Table

• Each functional evaluation can be represented using a diagram called Reservation Table(RT).

• It is the space-time diagram of a pipeline corresponding to one functional evaluation.

• X axis – time units • Y axis – stages

Page 53: Principles of Linear Pipelining

Reservation Table

• For first sequence Sa, Sb, Sc, Sb, Sc, Sa called function A , we have

  0 1 2 3 4 5

Sa A A

Sb A A

Sc A A

Page 54: Principles of Linear Pipelining

Reservation Table

• For second sequence Sa, Sc, Sb, Sa, Sb, Sc called function B, we have

0 1 2 3 4 5

Sa B B

Sb B B

Sc B B

Page 55: Principles of Linear Pipelining

3 stage non-linear pipelineOutput A

Output BSaSa SbSb ScSc

Input

Reservation TableTime

Stage

  0 1 2 3 4 5

Sa

Sb

Sc

Page 56: Principles of Linear Pipelining

Function A

Page 57: Principles of Linear Pipelining

3 stage pipeline : Sa, Sb, Sc, Sb, Sc, Sa

SaSa SbSb ScScInput Output B

Output A

Reservation TableTime

Stage

0 1 2 3 4 5

Sa A

Sb

Sc

Page 58: Principles of Linear Pipelining

3 stage pipeline : Sa, Sb, Sc, Sb, Sc, Sa

SaSa SbSb ScScInput Output B

Output A

Reservation TableTime

Stage

0 1 2 3 4 5

Sa A

Sb A

Sc

Page 59: Principles of Linear Pipelining

3 stage pipeline : Sa, Sb, Sc, Sb, Sc, Sa

SaSa SbSb ScScInput Output B

Output A

Reservation TableTime

Stage

0 1 2 3 4 5

Sa A

Sb A

Sc A

Page 60: Principles of Linear Pipelining

3 stage pipeline : Sa, Sb, Sc, Sb, Sc, Sa

SaSa SbSb ScScInput Output B

Output A

Reservation TableTime

Stage

0 1 2 3 4 5

Sa A

Sb A A

Sc A

Page 61: Principles of Linear Pipelining

3 stage pipeline : Sa, Sb, Sc, Sb, Sc, Sa

SaSa SbSb ScScInput Output B

Output A

Reservation TableTime

Stage

0 1 2 3 4 5

Sa A

Sb A A

Sc A A

Page 62: Principles of Linear Pipelining

3 stage pipeline : Sa, Sb, Sc, Sb, Sc, Sa

SaSa SbSb ScScInput Output B

Output A

Reservation TableTime

Stage

0 1 2 3 4 5

Sa A A

Sb A A

Sc A A

Page 63: Principles of Linear Pipelining

Function B

Page 64: Principles of Linear Pipelining

3 stage pipeline: Sa, Sc, Sb, Sa, Sb, Sc

SaSa SbSb ScScInput Output B

Output A

Reservation TableTime

Stage

  0 1 2 3 4 5

Sa B

Sb

Sc

Page 65: Principles of Linear Pipelining

3 stage pipeline: Sa, Sc, Sb, Sa, Sb, Sc

SaSa SbSb ScScInput Output B

Output A

Reservation TableTime

Stage

0 1 2 3 4 5

Sa B

Sb

Sc B

Page 66: Principles of Linear Pipelining

3 stage pipeline: Sa, Sc, Sb, Sa, Sb, Sc

SaSa SbSb ScScInput Output B

Output A

Reservation TableTime

Stage

0 1 2 3 4 5

Sa B

Sb B

Sc B

Page 67: Principles of Linear Pipelining

3 stage pipeline: Sa, Sc, Sb, Sa, Sb, Sc

SaSa SbSb ScScInput Output B

Output A

Reservation TableTime

Stage

0 1 2 3 4 5

Sa B B

Sb B

Sc B

Page 68: Principles of Linear Pipelining

3 stage pipeline: Sa, Sc, Sb, Sa, Sb, Sc

SaSa SbSb ScScInput Output B

Output A

Reservation TableTime

Stage

0 1 2 3 4 5

Sa B B

Sb B B

Sc B

Page 69: Principles of Linear Pipelining

3 stage pipeline: Sa, Sc, Sb, Sa, Sb, Sc

SaSa SbSb ScScInput Output B

Output A

Reservation TableTime

Stage

0 1 2 3 4 5

Sa B B

Sb B B

Sc B B

Page 70: Principles of Linear Pipelining

Reservation Table• After starting a function, the stages need to be

reserved in corresponding time units.• Each function supported by multifunction

pipeline is represented by different RTs• Time taken for function evaluation in units of

clock period is compute time.(For A & B, it is 6)

Page 71: Principles of Linear Pipelining

Reservation Table• Marking in same row => usage of stage more

than once• Marking in same column => more than one

stage at a time