Outline 0024 Spring 2010 2 :: 2 Programming problem 2 0024 - - PowerPoint PPT Presentation
Outline 0024 Spring 2010 2 :: 2 Programming problem 2 0024 - - PowerPoint PPT Presentation
Outline 0024 Spring 2010 2 :: 2 Programming problem 2 0024 Spring 2010 2 :: 3 Parallel solution Given a vector X of length N, N = 2 k for some k Given P = N processors (execution units)
– 2 :: 2 – 0024 Spring 2010
Outline
– 2 :: 3 – 0024 Spring 2010
Programming problem 2
– 2 :: 4 – 0024 Spring 2010
Parallel solution
Given a vector X of length N, N = 2k for some k Given P = N processors (execution units) Distribute X so that Xi is stored on processor Pi (for 0 <= i < N). Compute Tj = X2*j + X2*j+1 on Pj Rename T to X, renumber the processors so that Pnew
i = Pold 2*i and repeat until T0 contains the result.
Note: some processors idle after first step. Number of steps proportional to log N.
– 2 :: 5 – 0024 Spring 2010
Comments
– 2 :: 6 – 0024 Spring 2010
Programming problem 2a
– 2 :: 7 – 0024 Spring 2010
Parallel solution
Given a vector X of length N, N = 2k for some k Given P = N processors (execution units) Phase 1 (like for Problem 1) Distribute X so that Xi is stored on processor Pi (for 0 <= i < N). Compute Tj = X2*j + X2*j+1 on Pj Rename T to X, renumber the processors so that Pnew
i = Pold 2*i and repeat until T0 contains the result.
– 2 :: 8 – 0024 Spring 2010
Phase 2
Imagine the root of the tree (here P0) to receive a “0” from its “parent” (which does not exist). All non-leaf nodes receive a value from their parent. Each node relays to its left child the received value. Each node sends to its right child the sum of the (received) parent value and the value computed by the left child in Phase 1. Leaf nodes add the value received from the parent and add it to the saved input value.
– 2 :: 9 – 0024 Spring 2010
Example
4 3 7 11 9 1 12 8 7 18 10 20 25 30 55
– 2 :: 10 – 0024 Spring 2010
Example
4 3 7 11 9 1 12 8 7 18 10 20 25 30 55
– 2 :: 11 – 0024 Spring 2010
Example
4 3 7 11 9 1 12 8 7 18 10 20 25 30 55
25
– 2 :: 12 – 0024 Spring 2010
Example
4 3 7 11 9 1 12 8 7 18 10 20 25 30 55
25 35 7
– 2 :: 13 – 0024 Spring 2010
Example
4 3 7 11 9 1 12 8 7 18 10 20 25 30 55
35 47 4 7 14 2534
– 2 :: 14 – 0024 Spring 2010
Example
4 3 7 11 9 1 12 8 7 18 10 20 25 30 55
47 55 4 7 14 25 3435
– 2 :: 15 – 0024 Spring 2010