B1b x uses 1 based indices falob lob

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: ]; } while (delta > epsilon); writeln(A); Jacobi Iteration in Chapel config const n = 6, epsilon = 1.0e-5; const BigD: domain(2) = {0..n+1, 0..n+1}, D: subdomain(BigD) = {1..n, 1..n}, LastRow: subdomain(BigD) = D.exterior(1,0); var A, Temp : [BigD] real; Declare program parameters A[LastRow] = 1.0; do { const ⇒ can’t change values after initialization [(i,j) in D] Temp(i,j) = (A(i-1,j) + A(i+1,j) config ⇒ can be set on executable command-line + A(i,j-1) + A(i,j+1)) / 4.0; prompt> jacobi --n=10000 --epsilon=0.0001 const delta = max reduce abs(A(D) - Temp(D)); A[D]noteTemp[D]; = that no types are given; inferred from initializer n ⇒ d > epsilon); } while (delta efault integer (32 bits) epsilon ⇒ default real floating-point (64 bits) writeln(A); Jacobi Iteration in Chapel config const n = 6, epsilon = 1.0e-5; const BigD: domain(2) = {0..n+1, 0..n+1}, D: subdomain(BigD) = {1..n, 1..n}, LastRow: subdomain(BigD) = D.exterior(1,0); var A, Temp : [BigD] real; Declare domains (first class index sets) A[LastRow] = 1.0; domain(2) ⇒ 2D arithmetic domain, indices are integer 2-tuples do { subdomain(n ) D⇒ Temp(i,j) the same type as + whose indices [(i,j) i P ] a domain of = (A(i-1,j) P A(i+1,j) are guaranteed to be a subset of P’s + A(i,j+1)) / 4; + A(i,j-1) 0 n+1 0 var delta = 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 Jacobi Iteration in Chapel config const n = 6, epsilon = 1.0e-5; const BigD: domain(2) = {0..n+1, 0..n+1}, D: subdomain(BigD) = {1..n, 1..n}, LastRow: subdomain(BigD) = D.exterior(1,0); var A, Temp : [BigD] real; A[LastRow] = 1.0; Declare arrays do { [(i,j) in D] Temp(i,j) = (A(i-1,j) + A(i+1,j) var ⇒ can be modified throughout its lifetime + A(i,j-1) + A(i,j+1)) / 4; : [BigD] T ⇒ array of size BigD with elements of type T (no initializer) ⇒ values initialized to default value (0.0 for reals) var delta = max reduce abs(A(D) - Temp(D)); A(D) = Temp(D); } while (delta > epsilon); writeln(A); BigD A Temp Jacobi Iteration in Chapel config const n = 6, epsilon = 1.0e-5; const BigD: domain(2) = {0..n+1, 0..n+1}, D: subdomain(BigD) = {1..n, 1..n}, LastRow: subdomain(BigD) = D.exterior(1,0); var A, Temp : [BigD] real; A[LastRow] = 1.0; do et Explicit Boundary Condition S{ [(i,j) in D] Temp(i,j) = (A(i-1,j) + A(i+1,j) + A(i,j-1) + A(i,j+1)) / 4; indexing by domain ⇒ slicing mechanism array expressions ⇒ parallel evaluation var delta = max reduce abs(A(D) - Temp(D)); A(D) = Temp(D); } while (delta > epsilon); writeln(A); A Jacobi Iteration in Chapel config const n = 6, config const epsilon = 1.0e-5; Compute 5-pointdstencil const BigD: omain(2) = [0..n+1, 0..n+1], D: subdomain(BigD) = [1..n, 1..n], [(i,j) in D] ⇒ parallel forall expression over D’s indices, binding them LastRow: subdomain(BigD) = D.exterior(1,0); to new variables i and j var A, Temp : [BigD] real; Σ A[LastRow] = 1.0; ÷4 do { [(i,j) in D] 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); Jacobi Iteration in Chapel config const n = 6, epsilon = 1.0e-5; const BigD: domain(2) = {0..n+1, 0..n+1}, D: subdomain( Compute maximum change BigD) = [1..n, 1..n], LastRow: subdomain(BigD) = D.exterior(1,0); op reduce ⇒ collapse aggregate expression to scalar using op var A, Temp : [BigD] real; Promo...
View Full Document

This document was uploaded on 04/04/2014.

Ask a homework question - tutors are online