Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
chapel
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jussi Enkovaara
chapel
Commits
1d8e3963
Commit
1d8e3963
authored
Apr 12, 2016
by
Mads R. B. Kristensen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Now using the --size argument in the Heat Equation example
parent
d87e74ee
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
78 additions
and
17 deletions
+78
-17
heat_equation/src/multiple_machines.chpl
heat_equation/src/multiple_machines.chpl
+28
-7
heat_equation/src/sequential.chpl
heat_equation/src/sequential.chpl
+25
-5
heat_equation/src/single_machine.chpl
heat_equation/src/single_machine.chpl
+25
-5
No files found.
heat_equation/src/multiple_machines.chpl
View file @
1d8e3963
use BlockDist;
config const n = 8;//Size of the domain squired
//The format of 'size' is two integers separated with a '*'.
//The first integer is the domain size squired and the second integer is
//the number of iterations.
config const size = "100*10";//Default, 100 by 100 domain and 10 iterations
config const epsilon = 1.0e-10;//Stop condition in amount of change
config var iterations = 1000;//Stop condition in number of iterations
//Parse the --size argument into 'n' and 'iterations'
use Regexp;
const arg = size.matches(compile("(\\d+)*(\\d+)"));
const n = size.substring(arg[1][1]) : int;
const iterations = size.substring(arg[2][1]) : int;
//Initiate a Timer object
use Time;
var timer : Timer;
//Now, let's implement the heat equation!
//We will use the Block distribution
use BlockDist;
//A n+2 by n+2 domain.
const Grid = {0..n+1, 0..n+1} dmapped Block({1..n, 1..n});
...
...
@@ -17,8 +32,9 @@ A[..,n+1] = -273.15; //Right column
A[n+1,..] = -273.15; //Bottom row
A[0,..] = 40.0; //Top row
timer.start();
var iter_count = 0;
do{
//Since all iterations are independent, we can use 'forall', which allows
//the Chapel runtime system to calculate the iterations in parallel
forall (i,j) in Interior do//Iterate over all non-border cells
...
...
@@ -34,7 +50,12 @@ do{
A[Interior] = T[Interior];
//When 'delta' is smaller than 'epsilon' the calculation has converged
iterations -= 1;
} while (delta > epsilon && iterations > 0);
iter_count += 1;
} while (delta > epsilon && iter_count >= iterations);
timer.stop();
writeln("Heat Equation (multiple machines) - n: ",n,
", iterations: ", iterations,
", elapsed: ", timer.elapsed(), " seconds");
heat_equation/src/sequential.chpl
View file @
1d8e3963
config const n = 8;//Size of the domain squired
//The format of 'size' is two integers separated with a '*'.
//The first integer is the domain size squired and the second integer is
//the number of iterations.
config const size = "100*10";//Default, 100 by 100 domain and 10 iterations
config const epsilon = 1.0e-10;//Stop condition in amount of change
config var iterations = 1000;//Stop condition in number of iterations
//Parse the --size argument into 'n' and 'iterations'
use Regexp;
const arg = size.matches(compile("(\\d+)*(\\d+)"));
const n = size.substring(arg[1][1]) : int;
const iterations = size.substring(arg[2][1]) : int;
//Initiate a Timer object
use Time;
var timer : Timer;
//Now, let's implement the heat equation!
//A n+2 by n+2 domain.
const Grid = {0..n+1, 0..n+1};
...
...
@@ -15,8 +29,9 @@ A[..,n+1] = -273.15; //Right column
A[n+1,..] = -273.15; //Bottom row
A[0,..] = 40.0; //Top row
timer.start();
var iter_count = 0;
do{
//Since all iterations are independent, we can use 'forall', which allows
//the Chapel runtime system to calculate the iterations in parallel
for (i,j) in Interior do//Iterate over all non-border cells
...
...
@@ -32,7 +47,12 @@ do{
A[Interior] = T[Interior];
//When 'delta' is smaller than 'epsilon' the calculation has converged
iterations -= 1;
} while (delta > epsilon && iterations > 0);
iter_count += 1;
} while (delta > epsilon && iter_count >= iterations);
timer.stop();
writeln("Heat Equation (sequential) - n: ",n,
", iterations: ", iterations,
", elapsed: ", timer.elapsed(), " seconds");
heat_equation/src/single_machine.chpl
View file @
1d8e3963
config const n = 8;//Size of the domain squired
//The format of 'size' is two integers separated with a '*'.
//The first integer is the domain size squired and the second integer is
//the number of iterations.
config const size = "100*10";//Default, 100 by 100 domain and 10 iterations
config const epsilon = 1.0e-10;//Stop condition in amount of change
config var iterations = 1000;//Stop condition in number of iterations
//Parse the --size argument into 'n' and 'iterations'
use Regexp;
const arg = size.matches(compile("(\\d+)*(\\d+)"));
const n = size.substring(arg[1][1]) : int;
const iterations = size.substring(arg[2][1]) : int;
//Initiate a Timer object
use Time;
var timer : Timer;
//Now, let's implement the heat equation!
//A n+2 by n+2 domain.
const Grid = {0..n+1, 0..n+1};
...
...
@@ -15,8 +29,9 @@ A[..,n+1] = -273.15; //Right column
A[n+1,..] = -273.15; //Bottom row
A[0,..] = 40.0; //Top row
timer.start();
var iter_count = 0;
do{
//Since all iterations are independent, we can use 'forall', which allows
//the Chapel runtime system to calculate the iterations in parallel
forall (i,j) in Interior do//Iterate over all non-border cells
...
...
@@ -32,7 +47,12 @@ do{
A[Interior] = T[Interior];
//When 'delta' is smaller than 'epsilon' the calculation has converged
iterations -= 1;
} while (delta > epsilon && iterations > 0);
iter_count += 1;
} while (delta > epsilon && iter_count >= iterations);
timer.stop();
writeln("Heat Equation (single machine) - n: ",n,
", iterations: ", iterations,
", elapsed: ", timer.elapsed(), " seconds");
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment