pipeline computation parallel addition & parallel system ...gsyoung/cs370/14sp/pipeline... ·...

30
Pipeline Computations Pipelined Addition & System of Linear Equations CS370 Parallel Processing Spring 2014 1

Upload: others

Post on 28-Jul-2020

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Pipeline Computation Parallel Addition & Parallel System ...gsyoung/CS370/14Sp/pipeline... · •Pipelining to solve system of linear equation •Type 3 pipeline computation, if information

Pipeline Computations Pipelined Addition &

System of Linear Equations

CS370 Parallel Processing

Spring 2014

1

Page 2: Pipeline Computation Parallel Addition & Parallel System ...gsyoung/CS370/14Sp/pipeline... · •Pipelining to solve system of linear equation •Type 3 pipeline computation, if information

Pipelining

• Introduction to pipelining

• Instruction pipeline vs. software pipeline

– RISC pipeline (MISP Instruction Set)

– Learned in CS365 Computer Architecture

– Software pipeline is at a higher level and more general

2

Page 3: Pipeline Computation Parallel Addition & Parallel System ...gsyoung/CS370/14Sp/pipeline... · •Pipelining to solve system of linear equation •Type 3 pipeline computation, if information

Laundry analogy

3

Page 4: Pipeline Computation Parallel Addition & Parallel System ...gsyoung/CS370/14Sp/pipeline... · •Pipelining to solve system of linear equation •Type 3 pipeline computation, if information

Instruction Pipeline

4

Page 5: Pipeline Computation Parallel Addition & Parallel System ...gsyoung/CS370/14Sp/pipeline... · •Pipelining to solve system of linear equation •Type 3 pipeline computation, if information

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 process or processor

P0 P1 P2 P3 P4

P0 P1 P2 P3 P4

5

Page 6: Pipeline Computation Parallel Addition & Parallel System ...gsyoung/CS370/14Sp/pipeline... · •Pipelining to solve system of linear equation •Type 3 pipeline computation, if information

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

Page 7: Pipeline Computation Parallel Addition & Parallel System ...gsyoung/CS370/14Sp/pipeline... · •Pipelining to solve system of linear equation •Type 3 pipeline computation, if information

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

Page 8: Pipeline Computation Parallel Addition & Parallel System ...gsyoung/CS370/14Sp/pipeline... · •Pipelining to solve system of linear equation •Type 3 pipeline computation, if information

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

Page 9: Pipeline Computation Parallel Addition & Parallel System ...gsyoung/CS370/14Sp/pipeline... · •Pipelining to solve system of linear equation •Type 3 pipeline computation, if information

“Type 1” Pipeline

• Execution time = (p – 1) + m cycles,

for a p-stage pipeline with m instances

9

If more than 1 instance of the complete problem is to be executed

Page 10: Pipeline Computation Parallel Addition & Parallel System ...gsyoung/CS370/14Sp/pipeline... · •Pipelining to solve system of linear equation •Type 3 pipeline computation, if information

Laundry analogy

10

Also “type 1” pipeline, different diagram representation

Page 11: Pipeline Computation Parallel Addition & Parallel System ...gsyoung/CS370/14Sp/pipeline... · •Pipelining to solve system of linear equation •Type 3 pipeline computation, if information

“Type 1” Pipeline

• Alternative space-time diagram

11

Page 12: Pipeline Computation Parallel Addition & Parallel System ...gsyoung/CS370/14Sp/pipeline... · •Pipelining to solve system of linear equation •Type 3 pipeline computation, if information

“Type 2” Pipeline

12

If a series of data items must be processed, each requiring multiple operations

Page 13: Pipeline Computation Parallel Addition & Parallel System ...gsyoung/CS370/14Sp/pipeline... · •Pipelining to solve system of linear equation •Type 3 pipeline computation, if information

“Type 3” Pipeline

13

If information to start the next process can be passed forward before the process has completed all its internal operation

Page 14: Pipeline Computation Parallel Addition & Parallel System ...gsyoung/CS370/14Sp/pipeline... · •Pipelining to solve system of linear equation •Type 3 pipeline computation, if information

Computing Platform for Pipelining

Multiprocessor system with a line configuration

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

14

Page 15: Pipeline Computation Parallel Addition & Parallel System ...gsyoung/CS370/14Sp/pipeline... · •Pipelining to solve system of linear equation •Type 3 pipeline computation, if information

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

15

Page 16: Pipeline Computation Parallel Addition & Parallel System ...gsyoung/CS370/14Sp/pipeline... · •Pipelining to solve system of linear equation •Type 3 pipeline computation, if information

Pipelined Addition

• Adding numbers

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

16

Page 17: Pipeline Computation Parallel Addition & Parallel System ...gsyoung/CS370/14Sp/pipeline... · •Pipelining to solve system of linear equation •Type 3 pipeline computation, if information

Sample Code for Pipelined Addition

• P0, first process send(&number, P1);

• Pi

recv(&accumulation, Pi-1)

accumulation =+ number;

send(&accumulation, Pi+1);

• Pn-1, last process recv(&number, Pn-2);

accumulation =+ number;

17

Page 18: Pipeline Computation Parallel Addition & Parallel System ...gsyoung/CS370/14Sp/pipeline... · •Pipelining to solve system of linear equation •Type 3 pipeline computation, if information

• Pointless for adding 1 series of numbers

• Similar to having 1 load of laundry

• How about multiple series of numbers?

Why pipelining for addition?

18

A[]

B[]

C[]

Page 19: Pipeline Computation Parallel Addition & Parallel System ...gsyoung/CS370/14Sp/pipeline... · •Pipelining to solve system of linear equation •Type 3 pipeline computation, if information

Pipelined Arithmetic

• Instead of addition, other arithmetic operations can also be pipelined

• Similar steps, just need to replace addition by another operation

• The final result is in the last process

19

Page 20: Pipeline Computation Parallel Addition & Parallel System ...gsyoung/CS370/14Sp/pipeline... · •Pipelining to solve system of linear equation •Type 3 pipeline computation, if information

Example of Pipelined Addition

A[] = {1, 2, 3}

B[] = {4, 5, 6}

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

20

P0

P1

P2

1 4

1+2 4+5

3+3 9+6

Page 21: Pipeline Computation Parallel Addition & Parallel System ...gsyoung/CS370/14Sp/pipeline... · •Pipelining to solve system of linear equation •Type 3 pipeline computation, if information

“Type 1” Pipeline

• Execution time = (p – 1) + m cycles,

for a p-stage pipeline with m instances

21

If more than 1 instance of the complete problem is to be executed

Page 22: Pipeline Computation Parallel Addition & Parallel System ...gsyoung/CS370/14Sp/pipeline... · •Pipelining to solve system of linear equation •Type 3 pipeline computation, if information

“Type 1” Pipeline

• Alternative space-time diagram

22

Page 23: Pipeline Computation Parallel Addition & Parallel System ...gsyoung/CS370/14Sp/pipeline... · •Pipelining to solve system of linear equation •Type 3 pipeline computation, if information

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

23

Page 24: Pipeline Computation Parallel Addition & Parallel System ...gsyoung/CS370/14Sp/pipeline... · •Pipelining to solve system of linear equation •Type 3 pipeline computation, if information

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

24

Page 25: Pipeline Computation Parallel Addition & Parallel System ...gsyoung/CS370/14Sp/pipeline... · •Pipelining to solve system of linear equation •Type 3 pipeline computation, if information

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 − 𝑎1,0𝑥0

𝑎1,1

• And so on until all unknowns are found

25

Page 26: Pipeline Computation Parallel Addition & Parallel System ...gsyoung/CS370/14Sp/pipeline... · •Pipelining to solve system of linear equation •Type 3 pipeline computation, if information

Pipelining Back Substitution

• First stage computes x0, and pass it on

• 2nd stage computes receives x0, computes x1, and passes both x0 and x1 to the next stage

• So forth and so on,

26

Page 27: Pipeline Computation Parallel Addition & Parallel System ...gsyoung/CS370/14Sp/pipeline... · •Pipelining to solve system of linear equation •Type 3 pipeline computation, if information

Pipelining Back Substitution

27

Page 28: Pipeline Computation Parallel Addition & Parallel System ...gsyoung/CS370/14Sp/pipeline... · •Pipelining to solve system of linear equation •Type 3 pipeline computation, if information

Example for Pipelined System of Linear Equations

• 5 equations, 5 unknowns

5x0 + 2x1 + 10x2 + x3 + 2x4 = 65

x0 + 7x1 + 4x3 = 45

2x0 + 3x1 + 3x2 = 40

5x0 + x1 = 25

2x0 = 10

28

x0 = 5

x1 = 0

x2 = 10

x3 = 10

x4 = 15

Page 29: Pipeline Computation Parallel Addition & Parallel System ...gsyoung/CS370/14Sp/pipeline... · •Pipelining to solve system of linear equation •Type 3 pipeline computation, if information

“Type 3” Pipeline

29

If information to start the next process can be passed forward before the process has completed all its internal operation

Page 30: Pipeline Computation Parallel Addition & Parallel System ...gsyoung/CS370/14Sp/pipeline... · •Pipelining to solve system of linear equation •Type 3 pipeline computation, if information

Post-test

• Similar to the previous exercises that you’ve done last time

• This time you’re better prepared

• Try your best!

30