Operacons example trivial barrier supports one use

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: tion: abs() and – are scalar operators, automatically promoted to A[LastRow] = operands work with array 1.0; 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(BigD) = {1..n, 1..n}, LastRow: subdomain(BigD) = D.exterior(1,0); C Temp : back ] real; var A,opy data [BigD& Repeat until done uses slicing and A[LastRow] = 1.0;whole array assignment standard do…while loop construct 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(BigD) = {1..n, 1..n}, LastRow: subdomain(BigD) = D.exterior(1,0); var A, Temp : [BigD] real; A[LastRow] = 1.0; Write array to console 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(BigD) = {1..n, 1..n}, LastRow: subdomain(BigD) = D.exterior(1,0); var A, Temp : [BigD] real; A[LastRow] = 1.0; 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); forall a in A do writeln(“Here is an element of A: ”, a); •  How many tasks will be used? •  How are iteraCons mapped to the tasks? forall (a, i) in zip(A, 1..n) do a = i / 10.0; Forall- loops may be zippered, like for- loops •  Corresponding iteraCons must match up •  But how does this work? 72 —༉  Arrays can be indexed using variables of their domain’s index type (tuples) or lists of integers var i = 1, j = 2; var ij = (i,j); A[ij] = 1.0; A[i, j] = 2.0; —༉  Array indexing can use either par...
View Full Document

This document was uploaded on 04/04/2014.

Ask a homework question - tutors are online