Presentation is loading. Please wait.

Presentation is loading. Please wait.

Pipeline Pattern ITCS 4/5145 Parallel Computing, UNC-Charlotte, B. Wilkinson, 2012 slides5.ppt March 20, 2014.

Similar presentations


Presentation on theme: "Pipeline Pattern ITCS 4/5145 Parallel Computing, UNC-Charlotte, B. Wilkinson, 2012 slides5.ppt March 20, 2014."— Presentation transcript:

1 Pipeline Pattern ITCS 4/5145 Parallel Computing, UNC-Charlotte, B. Wilkinson, slides5.ppt March 20, 2014.

2 Pipeline pattern Computation divided into a series of tasks that have to be performed one after the other, with the result of one task passed on to the next task. Basis of sequential programming. Task 1 Task 3 Task 2 Result Pipeline pattern is rather specialized and applicable is certain problems and algorithms for good efficiency and speed up.

3 Effective Pipeline pattern
To use as a effective parallel pattern, each task executed by a separate process/processor and somehow processes/ processors have to operate at the same time to get increased speed Task 1 Task 3 Task 2 Slave processes Result Master One way is the approach seen in a automobile assembly line, where a series cars are constructed, in this case a series of identical computations but with different data.

4 Seeds Pipeline Pattern
See “Pipeline Template Tutorial.” by Jeremy Villalobos. Interface: public abstract class PipeLine extends BasicLayerInterface { public abstract Data Compute(int stage, Data input); public abstract Data DiffuseData(int segment); public abstract void GatherData(int segment, Data dat); public abstract int getDataCount(); public abstract int getStageCount(); }

5 Pipeline applications
Broadly speaking, we can divide pipeline applications into two types: 1. More than one instance of complete problem is executed. Partial results passes from one pipeline stage to the next – example is an automobile assembly line building cars. 2. A single problem instance is executed that has a series of data items to be processed sequentially, each requiring multiple operations. Numbers pass from one stage to the next Although a pipeline application may exhibit features of both types. Sometimes a single problem instance requires a series of data items to be processed

6 Pipeline Space-Time Diagram
1. More than one instance of the complete problem is to be executed Pipeline Space-Time Diagram p stages m instances of problem Execution time = p + m – 1 steps

7 Speedup factor So if we provide a constant stream of instances of the problem, get maximum speedup.

8 Pipeline Space-Time Diagram
2. Single problem with a series of data items to be processed Pipeline Space-Time Diagram n data items Execution time = p + n – 1 steps

9 Speedup factor So if we provide a constant stream of data items, get maximum speedup. Processors can use this form of pipeline for streams of data (video etc.)

10 Single problem with a series of data items to be processed
Examples

11 Sorting numbers with a pipeline pattern
Parallel version of Insertion sort Numbers to sort Insertion sort: Each number is inserted into the position such that all numbers before it are smaller, by comparing with all the numbers before it. 1 4, 3, 1, 2, 5 2 4, 3, 1, 2 5 5 3 4, 3, 1 2 2 4 4, 3 1 5 Time steps 3 5 5 1 2 4 4 3 6 1 2 5 4 5 7 1 2 3 4 8 1 2 3 5 5 9 1 2 3 4 10 1 2 3 4 5

12 Pipeline for sorting using insertion sort
Receive x from Pi-1 if (stored_number < x) { send stored_number to Pi x = stored_number; } else send x to Pi The basic algorithm for process Pi is: Larger numbers P0 P0 P0 Series of number to sort xn-1, … x1, x0 Compare Compare Compare xmin Next smallest number Smallest number

13 Prime Number Generation: Sieve of Eratosthenes
Series of all integers generated from 2. First number, 2, is prime and kept. All multiples of this number deleted as they cannot be prime. Process repeated with each remaining number. The algorithm removes non-primes, leaving only primes.

14 Other situations that a pipeline can be used effectively
If information to start next process can be passed forward before all its internal operations have been completed.

15 a’s and b’s are constants and x’s are unknowns to be found.
Example: Solving Upper-triangular System of Linear Equations using Back Substitution (created after Gaussian Elimination step for a general system of linear equations) a’s and b’s are constants and x’s are unknowns to be found.

16 Back Substitution First, unknown x0 is found from last equation; i.e.,
Value obtained for x0 substituted into next equation to obtain x1; i.e., Values obtained for x1 and x0 substituted into next equation to obtain x2: and so on until all the unknowns are found.

17 Pipeline Solution First pipeline stage computes x0 and passes x0 onto the second stage, which computes x1 from x0 and passes both x0 and x1 onto the next stage, which computes x2 from x0 and x1, and so on.

18 Pipeline processing using back substitution

19 More complex pipelines
Two dimensional Multifunction, multiple paths, feedback and feedforward paths, multiple outputs -- these types of pipelines are found in logic design courses

20 Matrix-Vector Multiplication
c = A x b A is a matrix, b and c are vectors. Matrix-vector multiplication follows directly from definition of matrix-matrix multiplication by making B an n x1 matrix (vector). Result an n x 1 matrix (vector).

21 Matrix-Vector Multiplication
. . . . . . delay a a a a B[3] B[2] B[1] B[0] sin sout sin sout sin sout P0 P1 P2 P3 C[0] C[1] C[2] C[3] C elements accumulate in pipeline stages B array elements pass through

22 Might be more easy to see drawn this way

23 Matrix Multiplication
Two-dimensional pipeline

24 Example pipeline with two paths
This is an application for a pattern operator

25 Structures that allow two-way movement between stages
Not truly a pipeline We will look into these structures separately.

26 Questions


Download ppt "Pipeline Pattern ITCS 4/5145 Parallel Computing, UNC-Charlotte, B. Wilkinson, 2012 slides5.ppt March 20, 2014."

Similar presentations


Ads by Google