2 task 1 03 task 2 07 03 04 task 3 05 task

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: global- view (“holisGc”) const total = + reduce A; CSEP 524: Parallel ComputaCon // sum A’s elements Winter 2013: Chamberlain 19 Reduc3ons on Arrays accumulate Task 0 Task 1 Task 2 Task 3 Task 4 Task 5 Task 6 Task 7 combine 0.3 1.0 0.7 1.1 1.5 2.6 3.6 totTime CSEP 524: Parallel ComputaCon Winter 2013: Chamberlain 20 Reduc3ons on Mul3dimensional Arrays 123 456 789 •  Full/Complete ReducCon: collapse array to scalar + reduce = 45 min reduce = 1 •  ParCal ReducCon: collapse a subset of array dims –  reduce along rows: + min 6 15 24 –  reduce along cols: 12 15 18 1 1 4 7 2 3 (higher- D arrays can be reduced to planes or vectors or …) CSEP 524: Parallel ComputaCon Winter 2013: Chamberlain 21 Reduc3on Operators in Chapel Built- in –  +, *, &&, ||, &, |, ^, min, max –  minloc, maxloc •  Takes a zipped pair of values and indices •  Generates a tuple of the min/max value and its index User- defined –  Defined via a class that implements a standard interface –  Compiler generates code that calls these methods 22 Defining Parallel Reduc3ons •  What’s required? •  More generally (result type != input type, or state is required) –  An idenCty element •  What should we iniCalize our state to? –  An accumulator funcCon •  Combines an input value and a state value, creaCng a state value –  A combiner funcCon •  Combines two state values, creates a state value –  A result funcCon •  Transforms a state value into an answer CSEP 524: Parallel ComputaCon Winter 2013: Chamberlain 23 Discuss Map- Reduce Paper Here? —༉  Syntax scan-expr: scan-op scan iterator-expr —༉  SemanCcs —༉  Computes parallel prefix over values using scan- op —༉  Like a reducCon, but leaves intermediate values behind —༉  Scan- op may be any reduce- op —༉  Examples var A, B, C: [1..5] int; A = 1; B = + scan A; B[3] = -B[3]; C = min scan B; // // // // A: B: B: C: 1 1 1 1 1111 2345 2 -3 4 5 1 -3 -3 -3 25 0.1 Task 0 Scans, Step 1: Compute Reduc3on 0.2 Task 1 0.3 1.0 0.3 Task 2 0.7 0.4 Task 3 0.5 Task 4 1.1 0.6 Task 5 0.7 0.8 Task 6 Task 7 1.5 2.6 3.6 CSEP 524: Parallel ComputaCon Winter 2013: Chamberlain 26 0.1 Task 0 Scans, Step 2: Propagate Back 0.2 Task 1 0.3 Task 2 0.4 Task 3 0.5 Task 4 0.7 0.8 Task 6 0.6 Task 5 Task 7 x y z 3.6 CSEP 524: Parallel ComputaCon x+y Winter 2013: C...
View Full Document

Ask a homework question - tutors are online