Outline 0024 Spring 2010 2 :: 2 Programming problem 2 0024 - - PowerPoint PPT Presentation

outline
SMART_READER_LITE
LIVE PREVIEW

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)


slide-1
SLIDE 1
slide-2
SLIDE 2

– 2 :: 2 – 0024 Spring 2010

Outline

slide-3
SLIDE 3

– 2 :: 3 – 0024 Spring 2010

Programming problem 2

slide-4
SLIDE 4

– 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.

slide-5
SLIDE 5

– 2 :: 5 – 0024 Spring 2010

Comments

slide-6
SLIDE 6

– 2 :: 6 – 0024 Spring 2010

Programming problem 2a

slide-7
SLIDE 7

– 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.

slide-8
SLIDE 8

– 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.

slide-9
SLIDE 9

– 2 :: 9 – 0024 Spring 2010

Example

4 3 7 11 9 1 12 8 7 18 10 20 25 30 55

slide-10
SLIDE 10

– 2 :: 10 – 0024 Spring 2010

Example

4 3 7 11 9 1 12 8 7 18 10 20 25 30 55

slide-11
SLIDE 11

– 2 :: 11 – 0024 Spring 2010

Example

4 3 7 11 9 1 12 8 7 18 10 20 25 30 55

25

slide-12
SLIDE 12

– 2 :: 12 – 0024 Spring 2010

Example

4 3 7 11 9 1 12 8 7 18 10 20 25 30 55

25 35 7

slide-13
SLIDE 13

– 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

slide-14
SLIDE 14

– 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

slide-15
SLIDE 15

– 2 :: 15 – 0024 Spring 2010

Programming problem 3