Você está na página 1de 8

Parallel Program Design:

Decomposition Techniques
Ned Nedialkov
McMaster University
Canada
CS/SE 4F03
February 2014

Data Decomposition

Partitioning intermediate results

Recursive decomposition

Exploratory decomposition

Outline

Data Decomposition
Partitioning intermediate results
Recursive decomposition
Exploratory decomposition

c 201314 Ned Nedialkov


2/8

Data Decomposition

Partitioning intermediate results

Recursive decomposition

Exploratory decomposition

Data Decomposition
1. Decompose the data
2. The decomposition is used to induce computational tasks
I

Partitioning output data: each part of the output can be


computed independently of the rest
I

Each task computes parts of the output

Partitioning input data: each tasks works on part of the


input data
I

may not be possible to partition based on the output; e.g


sorting a sequence, finding largest number

c 201314 Ned Nedialkov


3/8

Data Decomposition

Partitioning intermediate results

Recursive decomposition

Exploratory decomposition

Example: partitioning output data


Multiplying two matrices

 
 

C11 C12
B11 B12
A11 A12

=
C21 C22
B21 B22
A21 A22

I
I
I
I

C11 = A11 B11 + A12 B21

(1)

C12 = A11 B12 + A12 B22

(2)

C21 = A21 B11 + A22 B21

(3)

C22 = A21 B12 + A22 B22

(4)

The numbers on the right denote task numbers


We can compute the result with 4 tasks
Each tasks does two multiplications in
O(2n3 /8) = O(n3 /4) and one addition in O(n2 /4)
Total in parallel is O(n3 /4 + n2 /4) = O(n3 /4)
c 201314 Ned Nedialkov

4/8

Data Decomposition

Partitioning intermediate results

Recursive decomposition

Exploratory decomposition

Partitioning intermediate results


Consider

A11
A21

 
A12
B
11
A22
B21

 
B12
C11
=
B22
C21

We can compute

 
(1)
D11


A11
B11 B12 =
(1)
A21
D
21

 
A12 
B21
A22
and then

C11
C21

C12
C22

(2)
D11

B22 =
(2)
D21

(1)
D11
=
(1)
D21

C12
C22

(1)

(1)

(2)

(2)

D12

D22
D12

D22

(2)
D
+ 11
(2)
(1)
D22
D21
(1)

D12

c 201314 Ned Nedialkov


(2)

(2)

D12
D22

5/8

Data Decomposition

Recursive decomposition

Exploratory decomposition

8 tasks can run in parallel to multiply n/2 n/2 matrices


I

Partitioning intermediate results

Each tasks does O(n3 /8) work

4 tasks can add them in parallel


I

Each task does n2 /4 work

Total in parallel is O(n3 /8 + n2 /4) = O(n3 /8)

About 2 times faster than if partitioning the output

c 201314 Ned Nedialkov


6/8

Data Decomposition

Partitioning intermediate results

Recursive decomposition

Exploratory decomposition

Recursive decomposition

Recursively subdivide the problem

Solve subproblems in parallel

Combine the results

E.g. parallel quicksort

c 201314 Ned Nedialkov


7/8

Data Decomposition

Partitioning intermediate results

Recursive decomposition

Exploratory decomposition

Exploratory decomposition

Assume we have a large solution space, and we need to


search for a solution in it

Decompose this space into smaller parts

Search in parallel in these smaller parts to find a solution

E.g. solving the 15-puzzle problem

c 201314 Ned Nedialkov


8/8

Você também pode gostar