Data Parallelism, by Example

Data Parallelism, by Example

Data Parallelism, By Example COMPUTE | STORE | ANALYZE Safe Harbor Statement This presentation may contain forward-looking statements that are based on our current expectations. Forward looking statements may include statements about our financial guidance and expected operating results, our opportunities and future potential, our product development and new product introduction plans, our ability to expand and penetrate our addressable markets and other statements that are not historical facts. These statements are only predictions and actual results may materially vary from those projected. Please refer to Cray's documents filed with the SEC from time to time concerning factors that could affect the Company and these forward-looking statements. COMPUTE | STORE | ANALYZE 2 Copyright 2014 Cray Inc. Data Parallel Features Domain Maps Data Parallelism Higher-level Chapel Task Parallelism Base Language Locality Control Target Machine COMPUTE | STORE | ANALYZE 3 Copyright 2014 Cray Inc. Data Parallel “Hello, world!” config const numIters = 1000; forall i in 1..numIters do writeln(“Hello, world! ”, “from iteration ”, i, “ of ”, numIters); Hello, world! from iteration 500 of 1000 Hello, world! from iteration 501 of 1000 Hello, world! from iteration 502 of 1000 Hello, world! from iteration 503 of 1000 Hello, world! from iteration 1 of 1000 Hello, world! from iteration 2 of 1000 Hello, world! from iteration 3 of 1000 Hello, world! from iteration 4 of 1000 … COMPUTE | STORE | ANALYZE 4 Copyright 2014 Cray Inc. Defining our Terms Data Parallelism: a style of parallel programming in which parallelism is driven by computations over collections of data elements or their indices COMPUTE | STORE | ANALYZE 5 Copyright 2014 Cray Inc. STREAM Triad: a trivial parallel computation Given: m-element vectors A, B, C Compute: ∀i ∈ 1..m, Ai = Bi + α⋅Ci In pictures, in parallel (distributed memory mulcore): A = = = = = = = = B + + + + + + + + C · · · · · · · · α COMPUTE | STORE | ANALYZE 6 Copyright 2014 Cray Inc. STREAM Triad in Chapel const ProblemSpace = {1..m}; var A, B, C: [ProblemSpace] real; = + α· A = B + alpha * C; COMPUTE | STORE | ANALYZE 7 Copyright 2014 Cray Inc. Domains Domain: ● A first-class index set ● The fundamental Chapel concept for data parallelism config const m = 4, n = 8; const D = {1..m, 1..n}; const Inner = {2..m-1, 2..n-1}; Inner D COMPUTE | STORE | ANALYZE 8 Copyright 2014 Cray Inc. Domains Domain: ● A first-class index set ● The fundamental Chapel concept for data parallelism ● Useful for declaring arrays and computing with them config const m = 4, n = 8; const D = {1..m, 1..n}; const Inner = {2..m-1, 2..n-1}; var A, B, C: [D] real; A B C COMPUTE | STORE | ANALYZE 9 Copyright 2014 Cray Inc. Data Parallelism by Example: Jacobi Iteration n A: repeat until max n change < ε 1.0 Σ ÷ 4 COMPUTE | STORE | ANALYZE 10 Copyright 2014 Cray Inc. Jacobi Iteration in Chapel config const n = 6, epsilon = 1.0e-5; const BigD = {0..n+1, 0..n+1}, D = BigD[1..n, 1..n], LastRow = D.exterior(1,0); var A, Temp : [BigD] real; A[LastRow] = 1.0; do { forall (i,j) in D do Temp[i,j] = (A[i-1,j] + A[i+1,j] + A[i,j-1] + A[i,j+1]) / 4; const delta = max reduce abs(A[D] - Temp[D]); A[D] = Temp[D]; } while (delta > epsilon); writeln(A); COMPUTE | STORE | ANALYZE 11 Copyright 2014 Cray Inc. Jacobi Iteration in Chapel config const n = 6, epsilon = 1.0e-5; const BigD = {0..n+1, 0..n+1}, D = BigD[1..n, 1..n], LastRow = D.exterior(1,0); var A, Temp : [BigD] real; A[LastRowDeclare] = program1.0; parameters do { const ⇒ can’t change values after initialization forall (i,j) in D do Temp[i,j] = (A[i-1,j] + A[i+1,j] + A[i,j-1] + A[i,j+1]) / 4; config ⇒ can be set on executable command-line prompt> jacobi --n=10000 --epsilon=0.0001 const delta = max reduce abs(A[D] - Temp[D]); A[D] = Temp[D]; } whilenote (delta that no types> epsilon); are given; they’re inferred from initializers n ⇒ default integer (64 bits) writeln(A); epsilon ⇒ default real floating-point (64 bits) COMPUTE | STORE | ANALYZE 12 Copyright 2014 Cray Inc. Jacobi Iteration in Chapel config const n = 6, epsilon = 1.0e-5; const BigD = {0..n+1, 0..n+1}, D = BigD[1..n, 1..n], LastRow = D.exterior(1,0); varDeclare A, Temp domains : [BigD (first] real; class index sets) A[LastRow] = 1.0; {lo..hi, lo2..hi2} 2D rectangular domain, with 2-tuple indices ⇒ do { forallDom1[Dom2] (i,j) ⇒ in computes D do the intersection of two domains Temp[i,j] = (A[i-1,j] + A[i+1,j] + A[i,j-1] + A[i,j+1]) / 4; 0 n+1 const delta0 = max reduce abs(A[D] - Temp[D]); A[D] = Temp[D]; } while (delta > epsilon); writeln (A);n+1 BigD D LastRow .exterior() ⇒ one of several built-in domain generators COMPUTE | STORE | ANALYZE 13 Copyright 2014 Cray Inc. Jacobi Iteration in Chapel config const n = 6, epsilon = 1.0e-5; const BigD = {0..n+1, 0..n+1}, D = BigD[1..n, 1..n], LastRow = D.exterior(1,0); var A, Temp : [BigD] real; A[LastRow] = 1.0; Declare arrays do { var forall ⇒ can be(i,j modified) in throughoutD do its lifetime : [Dom Temp[] T ⇒i,j array] = of (A[i-1,j] size Dom with + elementsA[i+1,j] of +type A[i,j-1] T + A[i,j+1]) / 4; (no initializer) ⇒ values initialized to default value (0.0 for reals) const delta = max reduce abs(A[D] - Temp[D]); A[D] = Temp[D]; } while (delta > epsilon); writeln(A); BigD A Temp COMPUTE | STORE | ANALYZE 14 Copyright 2014 Cray Inc. Jacobi Iteration in Chapel config const n = 6, epsilon = 1.0e-5; const BigD = {0..n+1, 0..n+1}, D = BigD[1..n, 1..n], LastRow = D.exterior(1,0); var A, Temp : [BigD] real; A[LastRow] = 1.0; do Set{ Explicit Boundary Condition forall (i,j) in D do Temp[i,j] = (A[i-1,j] + A[i+1,j] + A[i,j-1] + A[i,j+1]) / 4; Arr[Dom] ⇒ refer to array slice (“forall i in Dom do …Arr[i]…”) const delta = max reduce abs(A[D] - Temp[D]); A[D] = Temp[D]; } while (delta > epsilon); writeln(A); A COMPUTE | STORE | ANALYZE 15 Copyright 2014 Cray Inc. Jacobi Iteration in Chapel config const n = 6, epsilon = 1.0e-5; Compute 5-point stencil forallconst ind BigD in Dom = {0..n+1,⇒ parallel forall0..n+1}, expression over Dom’s indices, D = BigD binding[1..n, them 1..n], to ind LastRow = D.exterior (here, since(1,0); Dom is 2D, we can de-tuple the indices) var A, Temp : [BigD] real; 4 A[LastRow] = 1.0;Σ ÷ do { forall (i,j) in D do Temp[i,j] = (A[i-1,j] + A[i+1,j] + A[i,j-1] + A[i,j+1]) / 4; const delta = max reduce abs(A[D] - Temp[D]); A[D] = Temp[D]; } while (delta > epsilon); writeln(A); COMPUTE | STORE | ANALYZE 16 Copyright 2014 Cray Inc. Jacobi Iteration in Chapel config const n = 6, epsilon = 1.0e-5; Computeconst BigD maximum = {0..n+1, change 0..n+1}, D = BigD[1..n, 1..n], op reduce LastRow ⇒ collapse = D.exterior aggregate(1,0); expression to scalar using op Promotion:var A, Temp abs() : and[BigD – are] scalarreal; operators; providing array operands results in parallel evaluation equivalent to: A[ LastRow ] = forall 1.0; (a,t) in zip(A,Temp) do abs(a – t) do { forall (i,j) in D do Temp[i,j] = (A[i-1,j] + A[i+1,j] + A[i,j-1] + A[i,j+1]) / 4; const delta = max reduce abs(A[D] - Temp[D]); A[D] = Temp[D]; } while (delta > epsilon); writeln(A); COMPUTE | STORE | ANALYZE 17 Copyright 2014 Cray Inc. Jacobi Iteration in Chapel config const n = 6, epsilon = 1.0e-5; const BigD = {0..n+1, 0..n+1}, D = BigD[1..n, 1..n], LastRow = D.exterior(1,0); Copy data back & Repeat until done var A, Temp : [BigD] real; uses slicing and whole array assignment A[standardLastRow do]… =while 1.0; loop construct do { forall (i,j) in D do Temp[i,j] = (A[i-1,j] + A[i+1,j] + A[i,j-1] + A[i,j+1]) / 4; const delta = max reduce abs(A[D] - Temp[D]); A[D] = Temp[D]; } while (delta > epsilon); writeln(A); COMPUTE | STORE | ANALYZE 18 Copyright 2014 Cray Inc. Jacobi Iteration in Chapel config const n = 6, epsilon = 1.0e-5; const BigD = {0..n+1, 0..n+1}, D = BigD[1..n, 1..n], LastRow = D.exterior(1,0); var A, Temp : [BigD] real; A[LastRow] = 1.0; Write array to console do { forall (i,j) in D do Temp[i,j] = (A[i-1,j] + A[i+1,j] + A[i,j-1] + A[i,j+1]) / 4; const delta = max reduce abs(A[D] - Temp[D]); A[D] = Temp[D]; } while (delta > epsilon); writeln(A); COMPUTE | STORE | ANALYZE 19 Copyright 2014 Cray Inc. Jacobi Iteration in Chapel config const n = 6, epsilon = 1.0e-5; const BigD = {0..n+1, 0..n+1}, D = BigD[1..n, 1..n], LastRow = D.exterior(1,0); var A, Temp : [BigD] real; A[LastRow] = 1.0; do { forall (i,j) in D do Temp[i,j] = (A[i-1,j] + A[i+1,j] + A[i,j-1] + A[i,j+1]) / 4; const delta = max reduce abs(A[D] - Temp[D]); A[D] = Temp[D]; } while (delta > epsilon); writeln(A); COMPUTE | STORE | ANALYZE 20 Copyright 2014 Cray Inc.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    73 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us