bones-compiler 1.1.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/CHANGELOG +37 -0
- data/LICENSE +1 -1
- data/README.rdoc +95 -70
- data/Rakefile +78 -3
- data/VERSION +1 -1
- data/bin/adarwin +17 -0
- data/examples/benchmarks/PolyBench/2mm.c +104 -0
- data/examples/benchmarks/{3mm.c → PolyBench/3mm.c} +5 -2
- data/examples/benchmarks/{adi.c → PolyBench/adi.c} +6 -3
- data/examples/benchmarks/{atax.c → PolyBench/atax.c} +5 -2
- data/examples/benchmarks/{bicg.c → PolyBench/bicg.c} +5 -2
- data/examples/benchmarks/{cholesky.c → PolyBench/cholesky.c} +3 -0
- data/examples/benchmarks/{common.h → PolyBench/common.h} +2 -2
- data/examples/benchmarks/{correlation.c → PolyBench/correlation.c} +16 -7
- data/examples/benchmarks/{covariance.c → PolyBench/covariance.c} +7 -2
- data/examples/benchmarks/{doitgen.c → PolyBench/doitgen.c} +5 -2
- data/examples/benchmarks/{durbin.c → PolyBench/durbin.c} +3 -0
- data/examples/benchmarks/{dynprog.c → PolyBench/dynprog.c} +3 -0
- data/examples/benchmarks/{fdtd-2d-apml.c → PolyBench/fdtd-2d-apml.c} +3 -0
- data/examples/benchmarks/{fdtd-2d.c → PolyBench/fdtd-2d.c} +5 -2
- data/examples/benchmarks/{floyd-warshall.c → PolyBench/floyd-warshall.c} +3 -0
- data/examples/benchmarks/{gemm.c → PolyBench/gemm.c} +5 -2
- data/examples/benchmarks/{gemver.c → PolyBench/gemver.c} +5 -2
- data/examples/benchmarks/{gesummv.c → PolyBench/gesummv.c} +5 -2
- data/examples/benchmarks/{gramschmidt.c → PolyBench/gramschmidt.c} +3 -0
- data/examples/benchmarks/{jacobi-1d-imper.c → PolyBench/jacobi-1d-imper.c} +10 -2
- data/examples/benchmarks/{jacobi-2d-imper.c → PolyBench/jacobi-2d-imper.c} +8 -3
- data/examples/benchmarks/{lu.c → PolyBench/lu.c} +3 -0
- data/examples/benchmarks/{ludcmp.c → PolyBench/ludcmp.c} +3 -0
- data/examples/benchmarks/{mvt.c → PolyBench/mvt.c} +6 -2
- data/examples/benchmarks/{reg_detect.c → PolyBench/reg_detect.c} +3 -0
- data/examples/benchmarks/{seidel-2d.c → PolyBench/seidel-2d.c} +3 -0
- data/examples/benchmarks/{symm.c → PolyBench/symm.c} +3 -0
- data/examples/benchmarks/{syr2k.c → PolyBench/syr2k.c} +5 -2
- data/examples/benchmarks/{syrk.c → PolyBench/syrk.c} +7 -4
- data/examples/benchmarks/{trisolv.c → PolyBench/trisolv.c} +3 -0
- data/examples/benchmarks/{trmm.c → PolyBench/trmm.c} +3 -0
- data/examples/benchmarks/Rodinia/cfd.c +180 -0
- data/examples/benchmarks/Rodinia/hotspot.c +228 -0
- data/examples/benchmarks/Rodinia/kmeans.c +164 -0
- data/examples/benchmarks/Rodinia/srad.c +188 -0
- data/examples/benchmarks/other/common.h +0 -0
- data/examples/benchmarks/other/dct.c +58 -0
- data/examples/benchmarks/other/mm.c +50 -0
- data/examples/benchmarks/{saxpy.c → other/saxpy.c} +11 -7
- data/examples/chunk/{example1.c → example01.c} +0 -0
- data/examples/chunk/{example2.c → example02.c} +0 -0
- data/examples/chunk/{example3.c → example03.c} +0 -0
- data/examples/chunk/{example4.c → example04.c} +0 -0
- data/examples/chunk/{example5.c → example05.c} +0 -0
- data/examples/chunk/example06.c +45 -0
- data/examples/chunk/example07.c +49 -0
- data/examples/dependences/example01.c +42 -0
- data/examples/dependences/example02.c +40 -0
- data/examples/dependences/example03.c +43 -0
- data/examples/dependences/example04.c +44 -0
- data/examples/dependences/example05.c +42 -0
- data/examples/element/{example1.c → example01.c} +0 -0
- data/examples/element/{example2.c → example02.c} +2 -2
- data/examples/element/{example3.c → example03.c} +0 -0
- data/examples/element/{example4.c → example04.c} +0 -0
- data/examples/element/{example5.c → example05.c} +0 -0
- data/examples/element/{example6.c → example06.c} +0 -0
- data/examples/element/{example7.c → example07.c} +0 -0
- data/examples/element/{example8.c → example08.c} +0 -0
- data/examples/element/{example9.c → example09.c} +0 -0
- data/examples/element/example13.c +73 -0
- data/examples/fusion/example01.c +68 -0
- data/examples/fusion/example02.c +73 -0
- data/examples/fusion/example03.c +72 -0
- data/examples/fusion/example04.c +61 -0
- data/examples/fusion/example05.c +55 -0
- data/examples/neighbourhood/{example1.c → example01.c} +0 -0
- data/examples/neighbourhood/{example2.c → example02.c} +0 -0
- data/examples/neighbourhood/{example3.c → example03.c} +0 -0
- data/examples/neighbourhood/{example4.c → example04.c} +0 -0
- data/examples/neighbourhood/example05.c +44 -0
- data/examples/shared/{example1.c → example01.c} +0 -0
- data/examples/shared/{example2.c → example02.c} +0 -0
- data/examples/shared/{example3.c → example03.c} +0 -0
- data/examples/shared/{example4.c → example04.c} +0 -0
- data/examples/shared/{example5.c → example05.c} +0 -0
- data/lib/adarwin.rb +62 -0
- data/lib/adarwin/dependences.rb +268 -0
- data/lib/adarwin/engine.rb +277 -0
- data/lib/adarwin/fusion.rb +174 -0
- data/lib/adarwin/interval.rb +57 -0
- data/lib/adarwin/memorycopies.rb +153 -0
- data/lib/adarwin/nest.rb +225 -0
- data/lib/adarwin/preprocessor.rb +76 -0
- data/lib/adarwin/reference.rb +261 -0
- data/lib/bones.rb +4 -55
- data/lib/bones/algorithm.rb +77 -40
- data/lib/bones/copy.rb +26 -0
- data/lib/bones/engine.rb +147 -31
- data/lib/bones/preprocessor.rb +92 -12
- data/lib/bones/species.rb +4 -3
- data/lib/bones/structure.rb +14 -4
- data/lib/castaddon.rb +11 -6
- data/lib/castaddon/node_adarwin.rb +245 -0
- data/lib/castaddon/node_bones.rb +316 -0
- data/lib/castaddon/node_common.rb +289 -0
- data/lib/castaddon/transformations.rb +236 -0
- data/lib/common.rb +216 -0
- data/skeletons/CPU-C/common/header.c +3 -0
- data/skeletons/CPU-C/common/mem_global.c +0 -0
- data/skeletons/CPU-C/common/timer_2_start.c +11 -13
- data/skeletons/CPU-C/common/timer_2_stop.c +1 -1
- data/skeletons/CPU-C/common/timer_globals.c +29 -0
- data/skeletons/CPU-OPENCL-INTEL/common/globals.c +1 -1
- data/skeletons/CPU-OPENCL-INTEL/common/header.c +3 -0
- data/skeletons/CPU-OPENCL-INTEL/common/mem_copy_D2H.c +7 -2
- data/skeletons/CPU-OPENCL-INTEL/common/mem_copy_H2D.c +4 -2
- data/skeletons/CPU-OPENCL-INTEL/common/mem_global.c +0 -0
- data/skeletons/CPU-OPENCL-INTEL/common/mem_prologue.c +6 -3
- data/skeletons/CPU-OPENCL-INTEL/common/timer_2_stop.c +1 -1
- data/skeletons/CPU-OPENCL-INTEL/common/timer_globals.c +24 -0
- data/skeletons/CPU-OPENMP/common/globals.c +1 -0
- data/skeletons/CPU-OPENMP/common/header.c +3 -0
- data/skeletons/CPU-OPENMP/common/mem_global.c +0 -0
- data/skeletons/CPU-OPENMP/common/timer_1_start.c +0 -12
- data/skeletons/CPU-OPENMP/common/timer_2_stop.c +1 -1
- data/skeletons/CPU-OPENMP/common/timer_globals.c +33 -0
- data/skeletons/GPU-CUDA/common/globals.c +27 -3
- data/skeletons/GPU-CUDA/common/header.c +2 -0
- data/skeletons/GPU-CUDA/common/mem_async_alloc.c +6 -0
- data/skeletons/GPU-CUDA/common/mem_async_copyin.c +6 -0
- data/skeletons/GPU-CUDA/common/mem_async_copyout.c +6 -0
- data/skeletons/GPU-CUDA/common/mem_async_free.c +6 -0
- data/skeletons/GPU-CUDA/common/mem_copy_D2H.c +2 -1
- data/skeletons/GPU-CUDA/common/mem_copy_H2D.c +2 -1
- data/skeletons/GPU-CUDA/common/mem_global.c +1 -0
- data/skeletons/GPU-CUDA/common/mem_prologue.c +1 -2
- data/skeletons/GPU-CUDA/common/scheduler.c +86 -0
- data/skeletons/GPU-CUDA/common/timer_2_start.c +2 -4
- data/skeletons/GPU-CUDA/common/timer_2_stop.c +3 -5
- data/skeletons/GPU-CUDA/common/timer_globals.c +26 -0
- data/skeletons/GPU-CUDA/kernel/2xN-N-chunk-1-N-to-D-element.kernel.cu +5 -7
- data/skeletons/GPU-CUDA/kernel/N-N-chunk-1-N-to-D-element.kernel.cu +4 -6
- data/skeletons/GPU-CUDA/kernel/default.host.c +1 -1
- data/skeletons/GPU-CUDA/kernel/default.kernel.cu +6 -8
- data/skeletons/GPU-CUDA/skeletons.txt +6 -5
- data/{examples/benchmarks/2mm.c → test/examples/benchmarks/PolyBench/2mm_species.c} +19 -15
- data/test/examples/benchmarks/PolyBench/3mm_species.c +82 -0
- data/test/examples/benchmarks/PolyBench/adi_species.c +89 -0
- data/test/examples/benchmarks/PolyBench/atax_species.c +69 -0
- data/test/examples/benchmarks/PolyBench/bicg_species.c +71 -0
- data/test/examples/benchmarks/PolyBench/cholesky_species.c +68 -0
- data/test/examples/benchmarks/PolyBench/correlation_species.c +97 -0
- data/test/examples/benchmarks/PolyBench/covariance_species.c +78 -0
- data/test/examples/benchmarks/PolyBench/doitgen_species.c +67 -0
- data/test/examples/benchmarks/PolyBench/durbin_species.c +80 -0
- data/test/examples/benchmarks/PolyBench/dynprog_species.c +71 -0
- data/test/examples/benchmarks/PolyBench/fdtd-2d-apml_species.c +112 -0
- data/test/examples/benchmarks/PolyBench/fdtd-2d_species.c +78 -0
- data/test/examples/benchmarks/PolyBench/floyd-warshall_species.c +54 -0
- data/test/examples/benchmarks/PolyBench/gemm_species.c +73 -0
- data/test/examples/benchmarks/PolyBench/gemver_species.c +93 -0
- data/test/examples/benchmarks/PolyBench/gesummv_species.c +68 -0
- data/test/examples/benchmarks/PolyBench/gramschmidt_species.c +78 -0
- data/test/examples/benchmarks/PolyBench/jacobi-1d-imper_species.c +59 -0
- data/test/examples/benchmarks/PolyBench/jacobi-2d-imper_species.c +65 -0
- data/test/examples/benchmarks/PolyBench/lu_species.c +57 -0
- data/test/examples/benchmarks/PolyBench/ludcmp_species.c +89 -0
- data/test/examples/benchmarks/PolyBench/mvt_species.c +69 -0
- data/test/examples/benchmarks/PolyBench/reg_detect_species.c +86 -0
- data/test/examples/benchmarks/PolyBench/seidel-2d_species.c +53 -0
- data/test/examples/benchmarks/PolyBench/symm_species.c +74 -0
- data/test/examples/benchmarks/PolyBench/syr2k_species.c +69 -0
- data/test/examples/benchmarks/PolyBench/syrk_species.c +66 -0
- data/test/examples/benchmarks/PolyBench/trisolv_species.c +61 -0
- data/test/examples/benchmarks/PolyBench/trmm_species.c +61 -0
- data/test/examples/chunk/example01_species.c +58 -0
- data/test/examples/chunk/example02_species.c +48 -0
- data/test/examples/chunk/example03_species.c +63 -0
- data/test/examples/chunk/example04_species.c +58 -0
- data/test/examples/chunk/example05_species.c +56 -0
- data/test/examples/chunk/example06_species.c +49 -0
- data/test/examples/chunk/example07_species.c +53 -0
- data/test/examples/dependences/example01_species.c +46 -0
- data/test/examples/dependences/example02_species.c +44 -0
- data/test/examples/dependences/example03_species.c +47 -0
- data/test/examples/dependences/example04_species.c +48 -0
- data/test/examples/dependences/example05_species.c +46 -0
- data/test/examples/element/example01_species.c +50 -0
- data/test/examples/element/example02_species.c +50 -0
- data/test/examples/element/example03_species.c +62 -0
- data/test/examples/element/example04_species.c +53 -0
- data/test/examples/element/example05_species.c +59 -0
- data/test/examples/element/example06_species.c +50 -0
- data/test/examples/element/example07_species.c +58 -0
- data/test/examples/element/example08_species.c +49 -0
- data/test/examples/element/example09_species.c +52 -0
- data/test/examples/element/example10_species.c +54 -0
- data/test/examples/element/example11_species.c +51 -0
- data/test/examples/element/example12_species.c +60 -0
- data/test/examples/element/example13_species.c +77 -0
- data/test/examples/neighbourhood/example01_species.c +57 -0
- data/test/examples/neighbourhood/example02_species.c +56 -0
- data/test/examples/neighbourhood/example03_species.c +83 -0
- data/test/examples/neighbourhood/example04_species.c +55 -0
- data/test/examples/neighbourhood/example05_species.c +48 -0
- data/test/examples/shared/example01_species.c +49 -0
- data/test/examples/shared/example02_species.c +55 -0
- data/test/examples/shared/example03_species.c +59 -0
- data/test/examples/shared/example04_species.c +56 -0
- data/test/examples/shared/example05_species.c +52 -0
- metadata +193 -73
- data/examples/benchmarks/overview.txt +0 -38
- data/lib/castaddon/node.rb +0 -753
@@ -0,0 +1,66 @@
|
|
1
|
+
//
|
2
|
+
// This file is part of the Bones source-to-source compiler examples. The C-code
|
3
|
+
// is largely identical in terms of functionality and variable naming to the code
|
4
|
+
// found in PolyBench/C version 3.2. For more information on PolyBench/C or Bones
|
5
|
+
// please use the contact information below.
|
6
|
+
//
|
7
|
+
// == More information on PolyBench/C
|
8
|
+
// Contact............Louis-Noel Pouchet <pouchet@cse.ohio-state.edu>
|
9
|
+
// Web address........http://polybench.sourceforge.net/
|
10
|
+
//
|
11
|
+
// == More information on Bones
|
12
|
+
// Contact............Cedric Nugteren <c.nugteren@tue.nl>
|
13
|
+
// Web address........http://parse.ele.tue.nl/bones/
|
14
|
+
//
|
15
|
+
// == File information
|
16
|
+
// Filename...........benchmark/syrk.c
|
17
|
+
// Author.............Cedric Nugteren
|
18
|
+
// Last modified on...07-May-2013
|
19
|
+
//
|
20
|
+
|
21
|
+
#include "common.h"
|
22
|
+
|
23
|
+
// This is 'syrk', an algorithm for symmetric rank-k operations
|
24
|
+
int main(void) {
|
25
|
+
int i,j,k;
|
26
|
+
|
27
|
+
// Declare arrays on the stack
|
28
|
+
float A[NI][NJ];
|
29
|
+
float C[NI][NI];
|
30
|
+
|
31
|
+
// Set the constants
|
32
|
+
float alpha = 32412;
|
33
|
+
float beta = 2123;
|
34
|
+
|
35
|
+
// Set the input data
|
36
|
+
for (i=0; i<NI; i++) {
|
37
|
+
for (j=0; j<NJ; j++) {
|
38
|
+
A[i][j] = ((float) i*j) / NI;
|
39
|
+
}
|
40
|
+
}
|
41
|
+
for (i=0; i<NI; i++) {
|
42
|
+
for (j=0; j<NI; j++) {
|
43
|
+
C[i][j] = ((float) i*j) / NI;
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
// Perform the computation (C := alpha*A*A' + beta*C)
|
48
|
+
#pragma scop
|
49
|
+
{
|
50
|
+
#pragma species kernel C[0:NI-1,0:NI-1]|element ^ A[0:NI-1,0:NJ-1]|chunk(0:0,0:NJ-1) -> C[0:NI-1,0:NI-1]|element
|
51
|
+
for (i = 0; i < NI; i++) {
|
52
|
+
for (j = 0; j < NI; j++) {
|
53
|
+
C[i][j] *= beta;
|
54
|
+
for (k = 0; k < NJ; k++) {
|
55
|
+
C[i][j] += alpha * A[i][k] * A[j][k];
|
56
|
+
}
|
57
|
+
}
|
58
|
+
}
|
59
|
+
#pragma species endkernel syrk_k1
|
60
|
+
}
|
61
|
+
#pragma endscop
|
62
|
+
|
63
|
+
// Clean-up and exit the function
|
64
|
+
fflush(stdout);
|
65
|
+
return 0;
|
66
|
+
}
|
@@ -0,0 +1,61 @@
|
|
1
|
+
//
|
2
|
+
// This file is part of the Bones source-to-source compiler examples. The C-code
|
3
|
+
// is largely identical in terms of functionality and variable naming to the code
|
4
|
+
// found in PolyBench/C version 3.2. For more information on PolyBench/C or Bones
|
5
|
+
// please use the contact information below.
|
6
|
+
//
|
7
|
+
// == More information on PolyBench/C
|
8
|
+
// Contact............Louis-Noel Pouchet <pouchet@cse.ohio-state.edu>
|
9
|
+
// Web address........http://polybench.sourceforge.net/
|
10
|
+
//
|
11
|
+
// == More information on Bones
|
12
|
+
// Contact............Cedric Nugteren <c.nugteren@tue.nl>
|
13
|
+
// Web address........http://parse.ele.tue.nl/bones/
|
14
|
+
//
|
15
|
+
// == File information
|
16
|
+
// Filename...........benchmark/trisolv.c
|
17
|
+
// Author.............Cedric Nugteren
|
18
|
+
// Last modified on...03-Jul-2012
|
19
|
+
//
|
20
|
+
|
21
|
+
#include "common.h"
|
22
|
+
|
23
|
+
// This is 'trisolv', a solver for linear systems with triangular matrices
|
24
|
+
int main(void) {
|
25
|
+
int i,j;
|
26
|
+
float A_i_i;
|
27
|
+
|
28
|
+
// Declare arrays on the stack
|
29
|
+
float A[NX][NX];
|
30
|
+
float c[NX];
|
31
|
+
float x[NX];
|
32
|
+
|
33
|
+
// Set the input data
|
34
|
+
for (i=0; i<NX; i++) {
|
35
|
+
c[i] = ((float) i) / NX;
|
36
|
+
x[i] = ((float) i) / NX;
|
37
|
+
for (j=0; j<NX; j++) {
|
38
|
+
A[i][j] = ((float) i*j) / NX;
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
// Perform the computation
|
43
|
+
#pragma scop
|
44
|
+
{
|
45
|
+
for (i = 0; i < NX; i++) {
|
46
|
+
x[i] = c[i];
|
47
|
+
A_i_i = A[i][i];
|
48
|
+
#pragma species kernel x[i:i]|full ^ A[i:i,0:i-1]|element ^ x[0:i-1]|element -> x[i:i]|shared
|
49
|
+
for (j = 0; j <= i - 1; j++) {
|
50
|
+
x[i] = x[i] - A[i][j] * x[j];
|
51
|
+
x[i] = x[i] / A_i_i;
|
52
|
+
}
|
53
|
+
#pragma species endkernel trisolv_k4
|
54
|
+
}
|
55
|
+
}
|
56
|
+
#pragma endscop
|
57
|
+
|
58
|
+
// Clean-up and exit the function
|
59
|
+
fflush(stdout);
|
60
|
+
return 0;
|
61
|
+
}
|
@@ -0,0 +1,61 @@
|
|
1
|
+
//
|
2
|
+
// This file is part of the Bones source-to-source compiler examples. The C-code
|
3
|
+
// is largely identical in terms of functionality and variable naming to the code
|
4
|
+
// found in PolyBench/C version 3.2. For more information on PolyBench/C or Bones
|
5
|
+
// please use the contact information below.
|
6
|
+
//
|
7
|
+
// == More information on PolyBench/C
|
8
|
+
// Contact............Louis-Noel Pouchet <pouchet@cse.ohio-state.edu>
|
9
|
+
// Web address........http://polybench.sourceforge.net/
|
10
|
+
//
|
11
|
+
// == More information on Bones
|
12
|
+
// Contact............Cedric Nugteren <c.nugteren@tue.nl>
|
13
|
+
// Web address........http://parse.ele.tue.nl/bones/
|
14
|
+
//
|
15
|
+
// == File information
|
16
|
+
// Filename...........benchmark/trmm.c
|
17
|
+
// Author.............Cedric Nugteren
|
18
|
+
// Last modified on...26-Jun-2012
|
19
|
+
//
|
20
|
+
|
21
|
+
#include "common.h"
|
22
|
+
|
23
|
+
// This is 'trmm', a triangular matrix multiplication kernel
|
24
|
+
int main(void) {
|
25
|
+
int i,j,k;
|
26
|
+
|
27
|
+
// Declare arrays on the stack
|
28
|
+
float A[NI][NI];
|
29
|
+
float B[NI][NI];
|
30
|
+
|
31
|
+
// Set the constants
|
32
|
+
int alpha = 32412;
|
33
|
+
|
34
|
+
// Set the input data
|
35
|
+
for (i=0; i<NI; i++) {
|
36
|
+
for (j=0; j<NI; j++) {
|
37
|
+
A[i][j] = ((float) i*j) / NI;
|
38
|
+
B[i][j] = ((float) i*j) / NI;
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
// Perform the computation (B := alpha*A'*B, with A triangular)
|
43
|
+
#pragma scop
|
44
|
+
{
|
45
|
+
for (i = 1; i < NI; i++) {
|
46
|
+
for (j = 0; j < NI; j++) {
|
47
|
+
#pragma species kernel B[i:i,j:j]|full ^ A[i:i,0:i-1]|element ^ B[j:j,0:i-1]|element -> B[i:i,j:j]|shared
|
48
|
+
for (k = 0; k < i; k++) {
|
49
|
+
B[i][j] += alpha * A[i][k] * B[j][k];
|
50
|
+
}
|
51
|
+
#pragma species endkernel trmm_k3
|
52
|
+
}
|
53
|
+
}
|
54
|
+
}
|
55
|
+
#pragma endscop
|
56
|
+
|
57
|
+
// Clean-up and exit the function
|
58
|
+
fflush(stdout);
|
59
|
+
return 0;
|
60
|
+
}
|
61
|
+
|
@@ -0,0 +1,58 @@
|
|
1
|
+
//
|
2
|
+
// This file is part of the Bones source-to-source compiler examples. This C-code
|
3
|
+
// example is meant to illustrate the use of Bones. For more information on Bones
|
4
|
+
// use the contact information below.
|
5
|
+
//
|
6
|
+
// == More information on Bones
|
7
|
+
// Contact............Cedric Nugteren <c.nugteren@tue.nl>
|
8
|
+
// Web address........http://parse.ele.tue.nl/bones/
|
9
|
+
//
|
10
|
+
// == File information
|
11
|
+
// Filename...........chunk/example1.c
|
12
|
+
// Author.............Cedric Nugteren
|
13
|
+
// Last modified on...16-April-2012
|
14
|
+
//
|
15
|
+
|
16
|
+
#include <stdio.h>
|
17
|
+
|
18
|
+
// This is 'example1', a basic chunk to element example using a 2D tile
|
19
|
+
int main(void) {
|
20
|
+
int i,j;
|
21
|
+
int i2,j2;
|
22
|
+
int result = 0;
|
23
|
+
|
24
|
+
// Declare input/output arrays
|
25
|
+
int A[560][32];
|
26
|
+
int B[56][16];
|
27
|
+
|
28
|
+
// Set the input data
|
29
|
+
for(i=0;i<560;i++) {
|
30
|
+
for(j=0;j<32;j++) {
|
31
|
+
A[i][j] = i+j;
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
// Perform the computation
|
36
|
+
#pragma scop
|
37
|
+
{
|
38
|
+
#pragma species kernel A[0:559,0:31]|chunk(0:9,0:1) -> B[0:55,0:15]|element
|
39
|
+
for (i = 0; i < 56; i++) {
|
40
|
+
for (j = 0; j < 16; j++) {
|
41
|
+
result = 0;
|
42
|
+
for (i2 = 0; i2 < 10; i2++) {
|
43
|
+
for (j2 = 0; j2 < 2; j2++) {
|
44
|
+
result = result + A[i * 10 + i2][j * 2 + j2];
|
45
|
+
}
|
46
|
+
}
|
47
|
+
B[i][j] = result;
|
48
|
+
}
|
49
|
+
}
|
50
|
+
#pragma species endkernel example01_k1
|
51
|
+
}
|
52
|
+
#pragma endscop
|
53
|
+
|
54
|
+
// Clean-up and exit the function
|
55
|
+
fflush(stdout);
|
56
|
+
return 0;
|
57
|
+
}
|
58
|
+
|
@@ -0,0 +1,48 @@
|
|
1
|
+
//
|
2
|
+
// This file is part of the Bones source-to-source compiler examples. This C-code
|
3
|
+
// example is meant to illustrate the use of Bones. For more information on Bones
|
4
|
+
// use the contact information below.
|
5
|
+
//
|
6
|
+
// == More information on Bones
|
7
|
+
// Contact............Cedric Nugteren <c.nugteren@tue.nl>
|
8
|
+
// Web address........http://parse.ele.tue.nl/bones/
|
9
|
+
//
|
10
|
+
// == File information
|
11
|
+
// Filename...........chunk/example2.c
|
12
|
+
// Author.............Cedric Nugteren
|
13
|
+
// Last modified on...16-April-2012
|
14
|
+
//
|
15
|
+
|
16
|
+
#include <stdio.h>
|
17
|
+
#define SIZE 2048
|
18
|
+
#define HALFSIZE (SIZE/2)
|
19
|
+
|
20
|
+
// This is 'example2', demonstrating a chunk-example without an inner-loop, everything is unrolled manually
|
21
|
+
int main(void) {
|
22
|
+
int i;
|
23
|
+
|
24
|
+
// Declare input/output arrays
|
25
|
+
float A[SIZE];
|
26
|
+
float B[HALFSIZE];
|
27
|
+
|
28
|
+
// Set the input data
|
29
|
+
for(i=0;i<SIZE;i++) {
|
30
|
+
A[i] = i%6+i;
|
31
|
+
}
|
32
|
+
|
33
|
+
// Perform the computation
|
34
|
+
#pragma scop
|
35
|
+
{
|
36
|
+
#pragma species kernel A[0:2*HALFSIZE-1]|chunk(0:1) -> B[0:HALFSIZE-1]|element
|
37
|
+
for (i = 0; i < HALFSIZE; i++) {
|
38
|
+
B[i] = A[i * 2] + A[i * 2 + 1];
|
39
|
+
}
|
40
|
+
#pragma species endkernel example02_k1
|
41
|
+
}
|
42
|
+
#pragma endscop
|
43
|
+
|
44
|
+
// Clean-up and exit the function
|
45
|
+
fflush(stdout);
|
46
|
+
return 0;
|
47
|
+
}
|
48
|
+
|
@@ -0,0 +1,63 @@
|
|
1
|
+
//
|
2
|
+
// This file is part of the Bones source-to-source compiler examples. This C-code
|
3
|
+
// example is meant to illustrate the use of Bones. For more information on Bones
|
4
|
+
// use the contact information below.
|
5
|
+
//
|
6
|
+
// == More information on Bones
|
7
|
+
// Contact............Cedric Nugteren <c.nugteren@tue.nl>
|
8
|
+
// Web address........http://parse.ele.tue.nl/bones/
|
9
|
+
//
|
10
|
+
// == File information
|
11
|
+
// Filename...........chunk/example3.c
|
12
|
+
// Author.............Cedric Nugteren
|
13
|
+
// Last modified on...16-April-2012
|
14
|
+
//
|
15
|
+
|
16
|
+
#include <stdio.h>
|
17
|
+
#define BASE 2048
|
18
|
+
#define TILE 64
|
19
|
+
#define SIZE (BASE*TILE)
|
20
|
+
|
21
|
+
// This is 'example3', demonstrating a chunked input and a chunked output, and showing the importance of ordering (array referenced first should be placed first)
|
22
|
+
int main(void) {
|
23
|
+
int i;
|
24
|
+
int t = 0;
|
25
|
+
float result = 0;
|
26
|
+
|
27
|
+
// Declare input/output arrays
|
28
|
+
float A[BASE];
|
29
|
+
float B[SIZE];
|
30
|
+
float out1[SIZE];
|
31
|
+
float out2[SIZE];
|
32
|
+
|
33
|
+
// Set the input data
|
34
|
+
for(i=0;i<BASE;i++) {
|
35
|
+
A[i] = 0.6;
|
36
|
+
}
|
37
|
+
for(i=0;i<SIZE;i++) {
|
38
|
+
B[i] = i%6+i;
|
39
|
+
}
|
40
|
+
|
41
|
+
// Perform the computation
|
42
|
+
#pragma scop
|
43
|
+
{
|
44
|
+
#pragma species kernel A[0:BASE-1]|element ^ B[0:(BASE*TILE)-1]|chunk(0:TILE-1) -> out1[0:(BASE*TILE)-1]|chunk(0:TILE-1) ^ out2[0:(BASE*TILE)-1]|chunk(0:TILE-1)
|
45
|
+
for (i = 0; i < BASE; i++) {
|
46
|
+
result = A[i];
|
47
|
+
for (t = 0; t < TILE; t++) {
|
48
|
+
result = result + t * B[i * TILE + t];
|
49
|
+
}
|
50
|
+
for (t = 0; t < TILE; t++) {
|
51
|
+
out1[i * TILE + t] = result;
|
52
|
+
out2[i * TILE + t] = -result;
|
53
|
+
}
|
54
|
+
}
|
55
|
+
#pragma species endkernel example03_k1
|
56
|
+
}
|
57
|
+
#pragma endscop
|
58
|
+
|
59
|
+
// Clean-up and exit the function
|
60
|
+
fflush(stdout);
|
61
|
+
return 0;
|
62
|
+
}
|
63
|
+
|
@@ -0,0 +1,58 @@
|
|
1
|
+
//
|
2
|
+
// This file is part of the Bones source-to-source compiler examples. This C-code
|
3
|
+
// example is meant to illustrate the use of Bones. For more information on Bones
|
4
|
+
// use the contact information below.
|
5
|
+
//
|
6
|
+
// == More information on Bones
|
7
|
+
// Contact............Cedric Nugteren <c.nugteren@tue.nl>
|
8
|
+
// Web address........http://parse.ele.tue.nl/bones/
|
9
|
+
//
|
10
|
+
// == File information
|
11
|
+
// Filename...........chunk/example4.c
|
12
|
+
// Author.............Cedric Nugteren
|
13
|
+
// Last modified on...16-April-2012
|
14
|
+
//
|
15
|
+
|
16
|
+
#include <stdio.h>
|
17
|
+
#define SIZE 1024
|
18
|
+
|
19
|
+
// This is 'example4', a basic element to chunk example with an if-statement in the body
|
20
|
+
int main(void) {
|
21
|
+
int i;
|
22
|
+
int threshold = 19;
|
23
|
+
|
24
|
+
// Declare input/output arrays
|
25
|
+
char A[SIZE];
|
26
|
+
char B[SIZE*2];
|
27
|
+
|
28
|
+
// Set the input data
|
29
|
+
for(i=0;i<SIZE;i++) {
|
30
|
+
A[i] = i%100;
|
31
|
+
}
|
32
|
+
|
33
|
+
// Set the output data to zero
|
34
|
+
for(i=0;i<SIZE*2;i++) {
|
35
|
+
B[i] = 0;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Perform the computation
|
39
|
+
#pragma scop
|
40
|
+
{
|
41
|
+
#pragma species kernel A[0:SIZE-1]|element -> B[0:2*SIZE-1]|chunk(0:1)
|
42
|
+
for (i = 0; i < SIZE; i++) {
|
43
|
+
B[i * 2] = A[i];
|
44
|
+
if (A[i] > threshold) {
|
45
|
+
B[i * 2 + 1] = A[i];
|
46
|
+
} else {
|
47
|
+
B[i * 2 + 1] = 0;
|
48
|
+
}
|
49
|
+
}
|
50
|
+
#pragma species endkernel example04_k1
|
51
|
+
}
|
52
|
+
#pragma endscop
|
53
|
+
|
54
|
+
// Clean-up and exit the function
|
55
|
+
fflush(stdout);
|
56
|
+
return 0;
|
57
|
+
}
|
58
|
+
|
@@ -0,0 +1,56 @@
|
|
1
|
+
//
|
2
|
+
// This file is part of the Bones source-to-source compiler examples. This C-code
|
3
|
+
// example is meant to illustrate the use of Bones. For more information on Bones
|
4
|
+
// use the contact information below.
|
5
|
+
//
|
6
|
+
// == More information on Bones
|
7
|
+
// Contact............Cedric Nugteren <c.nugteren@tue.nl>
|
8
|
+
// Web address........http://parse.ele.tue.nl/bones/
|
9
|
+
//
|
10
|
+
// == File information
|
11
|
+
// Filename...........chunk/example5.c
|
12
|
+
// Author.............Cedric Nugteren
|
13
|
+
// Last modified on...16-April-2012
|
14
|
+
//
|
15
|
+
|
16
|
+
#include <stdio.h>
|
17
|
+
|
18
|
+
// This is 'example5', demonstrating a chunk to element example without a temporary variable but directly writing to the output
|
19
|
+
int main(void) {
|
20
|
+
int i,j;
|
21
|
+
int i2,j2;
|
22
|
+
|
23
|
+
// Declare input/output arrays
|
24
|
+
int A[560][32];
|
25
|
+
int B[56][16];
|
26
|
+
|
27
|
+
// Set the input data
|
28
|
+
for(i=0;i<560;i++) {
|
29
|
+
for(j=0;j<32;j++) {
|
30
|
+
A[i][j] = i+j;
|
31
|
+
}
|
32
|
+
}
|
33
|
+
|
34
|
+
// Perform the computation
|
35
|
+
#pragma scop
|
36
|
+
{
|
37
|
+
#pragma species kernel A[0:559,0:31]|chunk(0:9,0:1) -> B[0:55,0:15]|element
|
38
|
+
for (i = 0; i < 56; i++) {
|
39
|
+
for (j = 0; j < 16; j++) {
|
40
|
+
B[i][j] = 0;
|
41
|
+
for (i2 = 0; i2 < 10; i2++) {
|
42
|
+
for (j2 = 0; j2 < 2; j2++) {
|
43
|
+
B[i][j] = B[i][j] + A[i * 10 + i2][j * 2 + j2];
|
44
|
+
}
|
45
|
+
}
|
46
|
+
}
|
47
|
+
}
|
48
|
+
#pragma species endkernel example05_k1
|
49
|
+
}
|
50
|
+
#pragma endscop
|
51
|
+
|
52
|
+
// Clean-up and exit the function
|
53
|
+
fflush(stdout);
|
54
|
+
return 0;
|
55
|
+
}
|
56
|
+
|