<<

Pipeline Computations Pipelined Addition & System of Linear Equations

CS370 Parallel Processing Spring 2014

1 Pipelining

• Introduction to pipelining • Instruction vs. software pipeline – RISC pipeline (MISP Instruction Set) – Learned in CS365 – Software pipeline is at a higher level and more general

2 Laundry analogy

3 Instruction Pipeline

4 Pipelined Computations

• Definition – Original problem is divided into series of tasks that can be completed one after the other – Each task executed by a separate or processor

P0 P1 P2 P3 P4

P0 P1 P2 P3 P4

5 When to use Pipelining

• Back to laundry, will pipelining be useful if: – Only have 1 load?

– Washing takes 30 mins – Drying takes 1 hour – Folding takes 20 mins – Storing takes 10 mins

6 When to use Pipelining

• If the problem can be divided into a series of sequential tasks • pipelining can increase execution speed under the following three types of computations

7 Different “types” of Pipelines

1. If more than 1 instance of the complete problem is to be executed 2. If a series of data items must be processed, each requiring multiple operations 3. If information to start the next process can be passed forward before the process has completed all its internal operation

8 If more than 1 instance of the “Type 1” Pipeline complete problem is to be executed

• Execution time = (p – 1) + m cycles, for a p-stage pipeline with m instances

9 If a series of data items must be processed, each requiring “Type 2” Pipeline multiple operations

10 If information to start the next process can be passed forward “Type 3” Pipeline before the process has completed all its internal operation

11 Platform for Pipelining

Multiprocessor system with a line configuration

Pipeline may not be the best structure for a cluster, why?

12 Computing Platform for Pipelining

• Do we need one processor per stage? – No, if # stages > # processors, a group of stages can be assigned to each processor

13 Pipelined Addition

• Adding numbers • Type 1 pipeline computation, if more than 1 instance of the complete problem is to be executed

14 Why pipelining for addition?

• Pointless for adding 1 series of numbers • Similar to having 1 load of laundry • How about multiple series of numbers?

A[]

B[]

C[] 15 Example of Pipelined Addition

A[] = {1, 2, 3} B[] = {4, 5, 6}

2 arrays, A[] & B[], 3 stages pipeline, P0 – P2

P 3+3 9+6 2

P1 1+2 4+5

P0 1 4

16 Pipelined Addition KLA

• A[] = {1,2,3,4,5,6,7,8,9,10,11,12,…} • Each person represents a processor • Perform the operation then pass the result to the next processor • 1st instance, only 1st processor has something to do

17 If more than 1 instance of the “Type 1” Pipeline complete problem is to be executed

• How to calculate the execution time?

18 KLA Steps

• Add the number on your candy to the accumulator, then pass the accumulator on • The orientation of the number is the same as the text on candy • 9 or 6

19 Execution Time Calculation

• 6 stages pipeline to calculate additions of 7 arrays of numbers – 6 stages, 7 instances – Execution time = ?

• 10 stages pipeline to calculate multiplication of 8 arrays of numbers – Execution time = ?

20 Pipelining System of Linear Equation

• Pipelining to solve system of linear equation • Type 3 pipeline computation, if information to start the next process can be passed forward before the process has completed all its internal operation

21 System of Linear Equations

• Upper-triangular form, • a’s b’s are constants, x’s are unknowns a(n-1,0)x0 + a(n-1,1)x1 + a(n-1,2)x2 … + a(n-1,n-1)xn-1 = bn-1 … … a(2,0)x0 + a(2,1)x1 + a(2,2)x2 = b2 a(1,0)x0 + a(1,1)x1 = b1 a(0,0)x0 = b0

22 Solution Through Back Substitution

• First, the unknown x0 is found from the last equation, a(0,0)x0 = b0 푏0 푥0 = 푎0,0

• Then x1 is found, substitute x0 into the next equation, a(1,0)x0 + a(1,1)x1 = b1

푏1 − 푎1,0푥0 푥1 = 푎1,1 • And so on until all unknowns are found

23 Pipelining Back Substitution

• First stage computes x0, and pass it on nd • 2 stage computes receives x0, computes x1, and passes both x0 and x1 to the next stage • So forth and so on,

24 Pipelining Back Substitution

25 Example for Pipelined System of Linear Equations • 5 equations, 5 unknowns

5x0 + 2x1 + 10x2 + x3 + 2x4 = 65 x0 = 5 x0 + 7x1 + 4x3 = 45 x1 = 0

2x0 + 3x1 + 3x2 = 40 x2 = 10 x = 10 5x0 + x1 = 25 3 x4 = 15 2x0 = 10

26 If information to start the next process can be passed forward “Type 3” Pipeline before the process has completed all its internal operation

27 Pipelined System of Linear Equations KLA • Each person represents 1 stage • Responsible for 1 equation

• Purpose is to find all unknowns, x0 – xi

28 Pipelined System of Linear Equations KLA • When you receive an unknown, do not hang on to it, write it down and pass it on immediately • Calculate the unknown in your equation and pass it on (it would be the last unknown in your equation)

29 How many processors?

• Given 4 unknowns and four linear equations, how many processors are required to solve the system using type 3 pipeline? • 4 equations = 4 stages => 4 processors • How many processors are active shortly after the first unknown has been solved and passed on? (diagram next slide)

30 Solution

X0 = 5 X8 = 8 X1 = 0 X9 = 1 X2 = 10 X10 = 7 X3 = 10 X11 = 3 X4 = 15 X12 = 2 X5 = 2 X13 = 3 X6 = 5 X14 = 5 X7 = 4

31 Pipelining Back Substitution

32 Post-test

• Similar to the previous exercises that you’ve done last time • This time you’re better prepared • Try your best!

33