Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Chapel #440

Open
wants to merge 25 commits into
base: default
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d922c91
add Chapel source from git@github.com:chapel-lang/chapel.git 5c698c8a…
jeffhammond Jul 13, 2016
83713d0
align Chapel build and run with rest of PRK
jeffhammond Jul 14, 2016
4701aef
add missing Chapel config file
jeffhammond Jul 14, 2016
c6c6af5
add makefile for stencil; some opts not working...
jeffhammond Jul 14, 2016
46062de
make opts work - sort of
jeffhammond Jul 14, 2016
e5cc1f8
add synch_p2p
jeffhammond Jul 14, 2016
50db20f
test Chapel in Travis
jeffhammond Jul 14, 2016
0eb252c
Travis Chapel stuff
jeffhammond Jul 14, 2016
da17005
fix and improve git ignore
jeffhammond Jul 14, 2016
8744c4c
fix logic for brew install of Chapel
jeffhammond Jul 14, 2016
d949ade
make chapel path dir
jeffhammond Jul 14, 2016
51032f7
fix print name [ci skip]
jeffhammond Jul 14, 2016
6b472e9
detect newer GCC and use for Chapel compiler build
jeffhammond Jul 14, 2016
9dc8419
build Chapel HEAD since 1.13 release missing StencilDist
jeffhammond Jul 14, 2016
bc9c607
Chapel synch_p2p requires numlocales
jeffhammond Jul 15, 2016
5d95738
disable Linux Clang Chapel
jeffhammond Jul 15, 2016
559a26f
use 1 locale if no comm support
jeffhammond Jul 15, 2016
f979e86
whitespace is bad - dumb jeff
jeffhammond Jul 15, 2016
a51afe4
add SSH_SERVERS to Chapel
jeffhammond Jul 15, 2016
0f3dcde
try ssh servers again
jeffhammond Jul 15, 2016
eb3af77
do not bother with GASNet Chapel at all
jeffhammond Jul 15, 2016
74eb8b0
try local spawn with GASNet
jeffhammond Jul 15, 2016
0662944
add numLocales to stencil and transpose
jeffhammond Jul 16, 2016
1ff4642
resolve merge conflict
Feb 19, 2020
29c9a44
fix merge
Feb 19, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,23 @@ func.c # PRK C89 stencil generated code

MPI1/AMR/amr
MPI1/Branch/branch
MPI1/Branch/func.c

# auto-generated files
func.c
*.incl

# scripts
common/make.defs
scripts/small/runfgmpi
scripts/wide/runfgmpi

# binaries
CHAPEL/Stencil/stencil
CHAPEL/Synch_p2p/p2p
CHAPEL/Transpose/transpose
MPI1/Branch/branch
MPI1/Branch/func.c
MPI1/DGEMM/dgemm
MPI1/Nstream/nstream
MPI1/PIC-static/pic
Expand All @@ -73,7 +90,10 @@ MPIOPENMP/Synch_p2p/p2p
MPIOPENMP/Transpose/transpose
MPIRMA/Stencil/stencil
MPIRMA/Synch_p2p/p2p
MPIRMA/Stencil/stencil
MPIRMA/Transpose/transpose
MPISHM/Stencil/loop_body_compact.incl
MPISHM/Stencil/loop_body_star.incl
MPISHM/Stencil/stencil
MPISHM/Synch_p2p/p2p
MPISHM/Transpose/transpose
Expand All @@ -91,6 +111,9 @@ OPENMP/Synch_p2p/p2p
OPENMP/Transpose/transpose
SERIAL/AMR/amr
SERIAL/Branch/branch
SERIAL/Branch/func.c
SERIAL/Branch/branch
SERIAL/Branch/func.c
SERIAL/DGEMM/dgemm
SERIAL/Nstream/nstream
SERIAL/PIC/pic
Expand Down
15 changes: 12 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ env:
#- PRK_TARGET=allupc UPC_IMPL=bupc GASNET_CONDUIT=mpi PRK_FLAGS="-Wc,-O3"
#- PRK_TARGET=allupc UPC_IMPL=bupc GASNET_CONDUIT=ofi PRK_FLAGS="-Wc,-O3"
# Chapel kernels are not merged yet. Activate these when they are.
#- PRK_TARGET=allchapel CHPL_COMM=none
#- PRK_TARGET=allchapel CHPL_COMM=gasnet
- PRK_TARGET=allchapel CHPL_COMM=none
- PRK_TARGET=allchapel CHPL_COMM=gasnet
# HPX-3 kernels are not merged yet. Activate these when they are.
#- PRK_TARGET=allhpx3
# HPX-5 kernels are not merged yet. Activate these when they are.
Expand Down Expand Up @@ -89,9 +89,18 @@ matrix:
# Revisit this once Grappa is working with Clang
- compiler: gcc
env: PRK_TARGET=allgrappa
# Mac + Chapel + GASNet does not work and I do not care
# Chapel + GASNet does not work in Travis
- os: osx
env: PRK_TARGET=allchapel CHPL_COMM=gasnet
#- os: linux
# env: PRK_TARGET=allchapel CHPL_COMM=gasnet
# Linux Clang/GCC too old ("no member named 'max_align_t' in the global namespace")
- os: linux
compiler: clang
env: PRK_TARGET=allchapel CHPL_COMM=none
- os: linux
compiler: clang
env: PRK_TARGET=allchapel CHPL_COMM=gasnet
# UPC GASNet OFI conduit is busted, perhaps due to SSH spawner
- env: PRK_TARGET=allupc UPC_IMPL=bupc GASNET_CONDUIT=ofi PRK_FLAGS="-Wc,-O3"
# probably because of old GCC (4.6)
Expand Down
23 changes: 23 additions & 0 deletions CHAPEL/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Intel's Parallel Research Kernels (PRK)

https://github.com/ParRes/Kernels

This is a set of simple programs that can be used to explore the features of a
parallel platform.


## Implementations:

Each kernel is implemented in a variety of parallel flavors, such as "serial",
"shared", and "dist"-ributed. There is also two versions for each flavor:
a "fast" version optimized for performance and a
"pretty" version optimized for elegance. Ideally, the performance delta
between these versions will approach zero over time.

The test inputs were taken from the inputs used in the PRK test scripts.

### Stencil

### Synch_p2p

### Transpose
23 changes: 23 additions & 0 deletions CHAPEL/Stencil/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
PROGRAM=stencil

include ../../common/CHAPEL.defs

CHPLFLAGS=-O

.PHONY: all clean run

all: $(PROGRAM) $(PROGRAM)-serial

$(PROGRAM): $(PROGRAM).chpl
$(CHPL) $(CHPLFLAGS) $< -o $@

$(PROGRAM)-serial: $(PROGRAM)-serial.chpl
$(CHPL) $(CHPLFLAGS) $< -o $@

run: $(PROGRAM)
$(PROGRAM) --iterations=10 --order=32000 --tileSize=20

clean:
-rm -f $(PROGRAM)
-rm -f $(PROGRAM)-serial

189 changes: 189 additions & 0 deletions CHAPEL/Stencil/stencil-serial.chpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
//
// Chapel's stencil implementation
//
use Time;

param PRKVERSION = "2.15";

config var tileSize: int = 0;

config const iterations: int = 0,
order: int = 0,
debug: bool = false,
validate: bool = false;

config param R = 2,
compact = false;

// Configurable type for array elements
config type dtype = real;

const activePoints = (order-2*R)*(order-2*R),
coefx: dtype = 1.0,
coefy: dtype = 1.0;

param stencilSize = 4*R + 1,
weightSize = 2*R + 1,
Wsize = 2*R + 1,
R1 = R+1;

var timer: Timer;

//
// Process and test input configs
//
if ( (iterations == 0) && (order==0) ) {
writeln("Usage: ./stencil --iterations=<# iterations> --order=<matrix order> [--tileSize=<tile_size>]");
// None of these work...
//writeln(" [--compact=<boolean>] [--useBlockDist=<boolean>] [--useStencilDist=<boolean>]");
exit(1);
}
if (iterations < 1) {
writeln("ERROR: iterations must be >= 1: ", iterations);
exit(1);
}
if (order < 1) {
writeln("ERROR: Matrix Order must be greater than 0 : ", order);
exit(1);
}
if (R < 1) {
writeln("ERROR: Stencil radius ", R, " should be positive");
exit(1);
}
if (2*R + 1 > order) {
writeln("ERROR: Stencil radius ", R, " exceeds grid size ", order);
exit(1);
}

// Determine tiling
var tiling = (tileSize > 0 && tileSize < order);

// Safety check for creation of tiledDom
if (!tiling) then tileSize = 1;

// Domains
const Dom = {0.. # order, 0.. # order},
innerDom = Dom.expand(-R),
weightDom = {-R..R, -R..R};

var tiledDom = {R.. # order-2*R by tileSize, R.. # order-2*R by tileSize};

// Arrays
var input, output: [Dom] dtype = 0.0;
var tmpout : dtype = 0.0;

// Tuple of tuples
var weight: Wsize*(Wsize*(dtype));

// Set up weight matrix
for i in 1..R {
const element : dtype = 1 / (2*i*R) : dtype;
weight[R1][R1+i] = element;
weight[R1+i][R1] = element;
weight[R1-i][R1] = -element;
weight[R1][R1-i] = -element;
}

// Initialize the input and output arrays
[(i, j) in Dom] input[i,j] = coefx*i + coefy*j;

//
// Print information before main loop
//
if (!validate) {
writeln("Parallel Research Kernels Version ", PRKVERSION);
writeln("Serial stencil execution on 2D grid");
writeln("Grid size = ", order);
writeln("Radius of stencil = ", R);
if compact then writeln("Type of stencil = compact");
else writeln("Type of stencil = star");
writeln("Data type = ", dtype:string);
if tiling then writeln("Tile size = ", tileSize);
else writeln("Untiled");
writeln("Number of iterations = ", iterations);
}

//
// Main loop
//
for iteration in 0..iterations {

// Start timer after warmup iteration
if (iteration == 1) {
timer.start();
}

if (!tiling) {
for (i,j) in innerDom {
var tmpout: dtype = 0.0;
if (!compact) {
for param jj in -R..-1 do tmpout += weight[R1][R1+jj] * input[i, j+jj];
for param jj in 1..R do tmpout += weight[R1][R1+jj] * input[i, j+jj];
for param ii in -R..-1 do tmpout += weight[R1+ii][R1] * input[i+ii, j];
for param ii in 1..R do tmpout += weight[R1+ii][R1] * input[i+ii, j];
} else {
for (ii, jj) in weightDom do
tmpout += weight[R1+ii][R1+jj] * input[i+ii, j+jj];
}
output[i, j] += tmpout;
}
} else {
for (it,jt) in tiledDom {
for i in it .. # min(order - R - it, tileSize) {
for j in jt .. # min(order - R - jt, tileSize) {
var tmpout: dtype = 0.0;
if (!compact) {
for param jj in -R..-1 do tmpout += weight[R1][R1+jj] * input[i, j+jj];
for param jj in 1..R do tmpout += weight[R1][R1+jj] * input[i, j+jj];
for param ii in -R..-1 do tmpout += weight[R1+ii][R1] * input[i+ii, j];
for param ii in 1..R do tmpout += weight[R1+ii][R1] * input[i+ii, j];
} else {
for (ii, jj) in weightDom do
tmpout += weight[R1+ii][R1+jj] * input[i+ii, j+jj];
}
output[i, j] += tmpout;
}
}
}
}

// Add constant to solution to force refresh of neighbor data, if any
for (i,j) in Dom do input[i,j] += 1.0;

} // end of iterations

timer.stop();

//
// Analyze and output results
//

// Timings
var stencilTime = timer.elapsed(),
flops = (2*stencilSize + 1) * activePoints,
avgTime = stencilTime / iterations;

// Compute L1 norm
var referenceNorm = (iterations + 1) * (coefx + coefy),
norm = + reduce abs(output);
norm /= activePoints;

// Error threshold
const epsilon = 1.e-8;

// Verify correctness
if abs(norm-referenceNorm) > epsilon then {
writeln("ERROR: L1 norm = ", norm, ", Reference L1 norm = ", referenceNorm);
exit(1);
} else {
writeln("Solution validates");

if debug {
writeln("L1 norm = ", norm, ", Reference L1 norm = ", referenceNorm);
}

if (!validate) {
writeln("Rate (MFlops/s): ", 1.0E-06 * flops/avgTime, " Avg time (s): ",
avgTime);
}
}