Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jussi Enkovaara
chapel
Commits
4076693e
Commit
4076693e
authored
Apr 08, 2016
by
Mads R. B. Kristensen
Browse files
Added training materials for the Chapel Programming Language
parents
Changes
4
Hide whitespace changes
Inline
Side-by-side
README.md
0 → 100644
View file @
4076693e
Chapel
======
Compilation instructions
------------------------
There are no specific requirements for building examples,
just standard make, working MPI environment (for MPI examples) and
OpenMP enabled C or Fortran compiler (for OpenMP examples).
Move to proper subfolder (C or Fortran) and modify the top of the
**Makefile**
according to your environment (proper compiler commands and compiler flags).
All examples can be built with simple
**make**
,
**make mpi**
builds the MPI
examples and
**make omp**
OpenMP examples.
heat_equation/Makefile
0 → 100644
View file @
4076693e
# Makefile that builds each src/*.chpl file into a binary in bin/*
CC
=
chpl
CFLAGS
=
-g
LDFLAGS
=
SRC
=
$(
wildcard
src/
*
.chpl
)
PROGRAM
=
$(
addprefix
bin/,
$(
subst
.chpl,,
$(
subst
src/,,
$(SRC)
)))
all
:
mkdir $(PROGRAM)
bin/%
:
src/%.chpl
$(CC)
$(CFLAGS)
-o
$@
$<
.PHONY
:
clean mkdir
mkdir
:
mkdir
-p
bin
clean
:
rm
-R
bin
heat_equation/src/multiple_machines.chpl
0 → 100644
View file @
4076693e
use BlockDist;
config const n = 8;//Size of the domain squired
config const epsilon = 1.0e-10;//Stop condition in amount of change
config var iterations = 1000;//Stop condition in number of iterations
//A n+2 by n+2 domain.
const Grid = {0..n+1, 0..n+1} dmapped Block({1..n, 1..n});
//A n by n domain that represents the interior of 'Grid'
const Interior = {1..n, 1..n};
var A, T : [Grid] real;//Zero initialized as default
A[..,0] = -273.15; //Left column
A[..,n+1] = -273.15; //Right column
A[n+1,..] = -273.15; //Bottom row
A[0,..] = 40.0; //Top row
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
{
//Assign each cell in 'T' the mean of its neighboring cells in 'A'
T[i,j] = (A[i,j] + A[i-1,j] + A[i+1,j] + A[i,j-1] + A[i,j+1]) / 5;
}
//Delta is the total amount of change done in this iteration
const delta = + reduce abs(A[Interior] - T[Interior]);
//Copy back the non-border cells
A[Interior] = T[Interior];
//When 'delta' is smaller than 'epsilon' the calculation has converged
iterations -= 1;
} while (delta > epsilon && iterations > 0);
heat_equation/src/single_machine.chpl
0 → 100644
View file @
4076693e
config const n = 8;//Size of the domain squired
config const epsilon = 1.0e-10;//Stop condition in amount of change
config var iterations = 1000;//Stop condition in number of iterations
//A n+2 by n+2 domain.
const Grid = {0..n+1, 0..n+1};
//A n by n domain that represents the interior of 'Grid'
const Interior = {1..n, 1..n};
var A, T : [Grid] real;//Zero initialized as default
A[..,0] = -273.15; //Left column
A[..,n+1] = -273.15; //Right column
A[n+1,..] = -273.15; //Bottom row
A[0,..] = 40.0; //Top row
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
{
//Assign each cell in 'T' the mean of its neighboring cells in 'A'
T[i,j] = (A[i,j] + A[i-1,j] + A[i+1,j] + A[i,j-1] + A[i,j+1]) / 5;
}
//Delta is the total amount of change done in this iteration
const delta = + reduce abs(A[Interior] - T[Interior]);
//Copy back the non-border cells
A[Interior] = T[Interior];
//When 'delta' is smaller than 'epsilon' the calculation has converged
iterations -= 1;
} while (delta > epsilon && iterations > 0);
Write
Preview
Supports
Markdown
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