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,89 @@
|
|
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/adi.c
|
17
|
+
// Author.............Cedric Nugteren
|
18
|
+
// Last modified on...29-May-2012
|
19
|
+
//
|
20
|
+
|
21
|
+
#include "common.h"
|
22
|
+
|
23
|
+
// This is 'adi', an alternating direction implicit solver
|
24
|
+
int main(void) {
|
25
|
+
int t,i,j,i1,i2;
|
26
|
+
|
27
|
+
// Declare arrays on the stack
|
28
|
+
float X[N][N];
|
29
|
+
float A[N][N];
|
30
|
+
float B[N][N];
|
31
|
+
|
32
|
+
// Set the input data
|
33
|
+
for (i=0; i<N; i++) {
|
34
|
+
for (j=0; j<N; j++) {
|
35
|
+
X[i][j] = ((float) i*(j+1) + 1) / N;
|
36
|
+
A[i][j] = ((float) i*(j+2) + 2) / N;
|
37
|
+
B[i][j] = ((float) i*(j+3) + 3) / N;
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
// Perform the computation
|
42
|
+
#pragma scop
|
43
|
+
{
|
44
|
+
for (t = 0; t < TSTEPS; t++) {
|
45
|
+
for (i1 = 0; i1 < N; i1++) {
|
46
|
+
for (i2 = 1; i2 < N; i2++) {
|
47
|
+
X[i1][i2] = X[i1][i2] - X[i1][i2 - 1] * A[i1][i2] / B[i1][i2 - 1];
|
48
|
+
B[i1][i2] = B[i1][i2] - A[i1][i2] * A[i1][i2] / B[i1][i2 - 1];
|
49
|
+
}
|
50
|
+
}
|
51
|
+
#pragma species kernel X[0:N-1,N-1:N-1]|element ^ B[0:N-1,N-1:N-1]|element -> X[0:N-1,N-1:N-1]|element
|
52
|
+
for (i1 = 0; i1 < N; i1++) {
|
53
|
+
X[i1][N - 1] = X[i1][N - 1] / B[i1][N - 1];
|
54
|
+
}
|
55
|
+
#pragma species endkernel adi_k3
|
56
|
+
for (i1 = 0; i1 < N; i1++) {
|
57
|
+
for (i2 = 0; i2 < N - 2; i2++) {
|
58
|
+
X[i1][N - i2 - 2] = (X[i1][N - 2 - i2] - X[i1][N - 2 - i2 - 1] * A[i1][N - i2 - 3]) / B[i1][N - 3 - i2];
|
59
|
+
}
|
60
|
+
}
|
61
|
+
for (i1 = 1; i1 < N; i1++) {
|
62
|
+
#pragma species kernel X[i1-1:i1,0:N-1]|chunk(i1-1:i1,0:0) ^ A[i1:i1,0:N-1]|element ^ B[i1-1:i1,0:N-1]|chunk(i1-1:i1,0:0) -> X[i1:i1,0:N-1]|element ^ B[i1:i1,0:N-1]|element
|
63
|
+
for (i2 = 0; i2 < N; i2++) {
|
64
|
+
X[i1][i2] = X[i1][i2] - X[i1 - 1][i2] * A[i1][i2] / B[i1 - 1][i2];
|
65
|
+
B[i1][i2] = B[i1][i2] - A[i1][i2] * A[i1][i2] / B[i1 - 1][i2];
|
66
|
+
}
|
67
|
+
#pragma species endkernel adi_k14
|
68
|
+
}
|
69
|
+
#pragma species kernel X[N-1:N-1,0:N-1]|element ^ B[N-1:N-1,0:N-1]|element -> X[N-1:N-1,0:N-1]|element
|
70
|
+
for (i2 = 0; i2 < N; i2++) {
|
71
|
+
X[N - 1][i2] = X[N - 1][i2] / B[N - 1][i2];
|
72
|
+
}
|
73
|
+
#pragma species endkernel adi_k6
|
74
|
+
for (i1 = 0; i1 < N - 2; i1++) {
|
75
|
+
#pragma species kernel X[N-i1-3:N-i1-2,0:N-1]|chunk(N-i1-3:N-i1-2,0:0) ^ A[N-i1-3:N-i1-3,0:N-1]|element ^ B[N-i1-2:N-i1-2,0:N-1]|element -> X[N-i1-2:N-i1-2,0:N-1]|element
|
76
|
+
for (i2 = 0; i2 < N; i2++) {
|
77
|
+
X[N - 2 - i1][i2] = (X[N - 2 - i1][i2] - X[N - i1 - 3][i2] * A[N - 3 - i1][i2]) / B[N - 2 - i1][i2];
|
78
|
+
}
|
79
|
+
#pragma species endkernel adi_k18
|
80
|
+
}
|
81
|
+
}
|
82
|
+
}
|
83
|
+
#pragma endscop
|
84
|
+
|
85
|
+
// Clean-up and exit the function
|
86
|
+
fflush(stdout);
|
87
|
+
return 0;
|
88
|
+
}
|
89
|
+
|
@@ -0,0 +1,69 @@
|
|
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/atax.c
|
17
|
+
// Author.............Cedric Nugteren
|
18
|
+
// Last modified on...03-April-2012
|
19
|
+
//
|
20
|
+
|
21
|
+
#include "common.h"
|
22
|
+
|
23
|
+
// This is 'atax', a matrix transpose and vector multiplication kernel
|
24
|
+
int main(void) {
|
25
|
+
int i,j;
|
26
|
+
|
27
|
+
// Declare arrays on the stack
|
28
|
+
float A[NX][NY];
|
29
|
+
float x[NY];
|
30
|
+
float y[NX];
|
31
|
+
float tmp[NX];
|
32
|
+
|
33
|
+
// Set the input data
|
34
|
+
for (i=0; i<NY; i++) {
|
35
|
+
x[i] = i*3.14159;
|
36
|
+
}
|
37
|
+
for (i=0; i<NX; i++) {
|
38
|
+
for (j=0; j<NY; j++) {
|
39
|
+
A[i][j] = ((float) i*(j+1)) / NX;
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
// Perform the computation (y := A'Ax)
|
44
|
+
#pragma scop
|
45
|
+
{
|
46
|
+
#pragma species kernel A[0:NX-1,0:NY-1]|chunk(0:0,0:NY-1) ^ x[0:NY-1]|full -> tmp[0:NX-1]|element
|
47
|
+
for (i = 0; i < NX; i++) {
|
48
|
+
tmp[i] = 0;
|
49
|
+
for (j = 0; j < NY; j++) {
|
50
|
+
tmp[i] = tmp[i] + A[i][j] * x[j];
|
51
|
+
}
|
52
|
+
}
|
53
|
+
#pragma species endkernel atax_k1
|
54
|
+
#pragma species kernel A[0:NX-1,0:NY-1]|chunk(0:NX-1,0:0) ^ tmp[0:NX-1]|full -> y[0:NY-1]|element
|
55
|
+
for (j = 0; j < NY; j++) {
|
56
|
+
y[j] = 0;
|
57
|
+
for (i = 0; i < NX; i++) {
|
58
|
+
y[j] = y[j] + A[i][j] * tmp[i];
|
59
|
+
}
|
60
|
+
}
|
61
|
+
#pragma species endkernel atax_k2
|
62
|
+
}
|
63
|
+
#pragma endscop
|
64
|
+
|
65
|
+
// Clean-up and exit the function
|
66
|
+
fflush(stdout);
|
67
|
+
return 0;
|
68
|
+
}
|
69
|
+
|
@@ -0,0 +1,71 @@
|
|
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/bicg.c
|
17
|
+
// Author.............Cedric Nugteren
|
18
|
+
// Last modified on...03-April-2012
|
19
|
+
//
|
20
|
+
|
21
|
+
#include "common.h"
|
22
|
+
|
23
|
+
// This is 'bicg', a biconjugate gradients method kernel
|
24
|
+
int main(void) {
|
25
|
+
int i,j;
|
26
|
+
|
27
|
+
// Declare arrays on the stack
|
28
|
+
float A[NX][NY];
|
29
|
+
float p[NY];
|
30
|
+
float q[NX];
|
31
|
+
float r[NX];
|
32
|
+
float s[NY];
|
33
|
+
|
34
|
+
// Set the input data
|
35
|
+
for (i=0; i<NY; i++) {
|
36
|
+
p[i] = i*3.14159;
|
37
|
+
}
|
38
|
+
for (i=0; i<NX; i++) {
|
39
|
+
r[i] = i*3.14159;
|
40
|
+
for (j=0; j<NY; j++) {
|
41
|
+
A[i][j] = ((float) i*(j+1)) / NX;
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
45
|
+
// Perform the computation
|
46
|
+
#pragma scop
|
47
|
+
{
|
48
|
+
#pragma species kernel r[0:NX-1]|full ^ A[0:NX-1,0:NY-1]|chunk(0:NX-1,0:0) -> s[0:NY-1]|element
|
49
|
+
for (j = 0; j < NY; j++) {
|
50
|
+
s[j] = 0;
|
51
|
+
for (i = 0; i < NX; i++) {
|
52
|
+
s[j] = s[j] + r[i] * A[i][j];
|
53
|
+
}
|
54
|
+
}
|
55
|
+
#pragma species endkernel bicg_k1
|
56
|
+
#pragma species kernel A[0:NX-1,0:NY-1]|chunk(0:0,0:NY-1) ^ p[0:NY-1]|full -> q[0:NX-1]|element
|
57
|
+
for (i = 0; i < NX; i++) {
|
58
|
+
q[i] = 0;
|
59
|
+
for (j = 0; j < NY; j++) {
|
60
|
+
q[i] = q[i] + A[i][j] * p[j];
|
61
|
+
}
|
62
|
+
}
|
63
|
+
#pragma species endkernel bicg_k2
|
64
|
+
}
|
65
|
+
#pragma endscop
|
66
|
+
|
67
|
+
// Clean-up and exit the function
|
68
|
+
fflush(stdout);
|
69
|
+
return 0;
|
70
|
+
}
|
71
|
+
|
@@ -0,0 +1,68 @@
|
|
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/cholesky.c
|
17
|
+
// Author.............Cedric Nugteren
|
18
|
+
// Last modified on...03-Jul-2012
|
19
|
+
//
|
20
|
+
|
21
|
+
#include "common.h"
|
22
|
+
|
23
|
+
// This is 'cholesky', a cholesky decomposition kernel
|
24
|
+
int main(void) {
|
25
|
+
int i,j,k;
|
26
|
+
float x[1];
|
27
|
+
float p_i;
|
28
|
+
|
29
|
+
// Declare arrays on the stack
|
30
|
+
float A[N][N];
|
31
|
+
float p[N];
|
32
|
+
|
33
|
+
// Set the input data
|
34
|
+
for (i=0; i<N; i++) {
|
35
|
+
for (j=0; j<N; j++) {
|
36
|
+
A[i][j] = i*2.3 + 1;
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
// Perform the computation
|
41
|
+
#pragma scop
|
42
|
+
{
|
43
|
+
for (i = 0; i < N; i++) {
|
44
|
+
x[0] = A[i][i];
|
45
|
+
#pragma species kernel x[0:0]|full ^ A[i:i,0:i-1]|element -> x[0:0]|shared
|
46
|
+
for (j = 0; j <= i - 1; j++) {
|
47
|
+
x[0] = x[0] - A[i][j] * A[i][j];
|
48
|
+
}
|
49
|
+
#pragma species endkernel cholesky_k3
|
50
|
+
p[i] = 1.0 / sqrt(x[0]);
|
51
|
+
p_i = p[i];
|
52
|
+
#pragma species kernel A[i:i,N-1:i+1]|element ^ A[N-1:i+1,0:i-1]|chunk(0:0,0:i-1) ^ A[i:i,0:i-1]|full -> x[0:0]|shared ^ A[N-1:i+1,i:i]|element
|
53
|
+
for (j = i + 1; j < N; j++) {
|
54
|
+
x[0] = A[i][j];
|
55
|
+
for (k = 0; k <= i - 1; k++) {
|
56
|
+
x[0] = x[0] - A[j][k] * A[i][k];
|
57
|
+
}
|
58
|
+
A[j][i] = x[0] * p_i;
|
59
|
+
}
|
60
|
+
#pragma species endkernel cholesky_k6
|
61
|
+
}
|
62
|
+
}
|
63
|
+
#pragma endscop
|
64
|
+
|
65
|
+
// Clean-up and exit the function
|
66
|
+
fflush(stdout);
|
67
|
+
return 0;
|
68
|
+
}
|
@@ -0,0 +1,97 @@
|
|
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/correlation.c
|
17
|
+
// Author.............Cedric Nugteren
|
18
|
+
// Last modified on...07-Feb-2013
|
19
|
+
//
|
20
|
+
|
21
|
+
#include "common.h"
|
22
|
+
|
23
|
+
// This is 'correlation', a correlation computation algorithm
|
24
|
+
int main(void) {
|
25
|
+
int i,j,j1,j2;
|
26
|
+
float meanj;
|
27
|
+
|
28
|
+
// Declare arrays on the stack
|
29
|
+
float data[N][M];
|
30
|
+
float mean[M];
|
31
|
+
float stddev[M];
|
32
|
+
float symmat[M][M];
|
33
|
+
|
34
|
+
// Set the constants
|
35
|
+
float float_n = 1.2;
|
36
|
+
float eps = 0.1;
|
37
|
+
|
38
|
+
// Set the input data
|
39
|
+
for (i=0; i<N; i++) {
|
40
|
+
for (j=0; j<M; j++) {
|
41
|
+
data[i][j] = ((float) i*j) / M;
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
45
|
+
// Perform the computation
|
46
|
+
#pragma scop
|
47
|
+
{
|
48
|
+
#pragma species kernel data[0:N-1,0:M-1]|chunk(0:N-1,0:0) -> mean[0:M-1]|element
|
49
|
+
for (j = 0; j < M; j++) {
|
50
|
+
mean[j] = 0.0;
|
51
|
+
for (i = 0; i < N; i++) {
|
52
|
+
mean[j] += data[i][j];
|
53
|
+
}
|
54
|
+
mean[j] /= float_n;
|
55
|
+
}
|
56
|
+
#pragma species endkernel correlation_k1
|
57
|
+
#pragma species kernel mean[0:M-1]|element ^ data[0:N-1,0:M-1]|chunk(0:N-1,0:0) -> stddev[0:M-1]|element
|
58
|
+
for (j = 0; j < M; j++) {
|
59
|
+
stddev[j] = 0.0;
|
60
|
+
meanj = mean[j];
|
61
|
+
for (i = 0; i < N; i++) {
|
62
|
+
stddev[j] += (data[i][j] - meanj) * (data[i][j] - meanj);
|
63
|
+
}
|
64
|
+
stddev[j] /= float_n;
|
65
|
+
stddev[j] = sqrt(stddev[j]);
|
66
|
+
stddev[j] = stddev[j] <= eps ? 1.0 : stddev[j];
|
67
|
+
}
|
68
|
+
#pragma species endkernel correlation_k2
|
69
|
+
#pragma species kernel data[0:N-1,0:M-1]|element ^ mean[0:M-1]|element ^ stddev[0:M-1]|element -> data[0:N-1,0:M-1]|element
|
70
|
+
for (i = 0; i < N; i++) {
|
71
|
+
for (j = 0; j < M; j++) {
|
72
|
+
data[i][j] -= mean[j];
|
73
|
+
data[i][j] /= sqrt(float_n) * stddev[j];
|
74
|
+
}
|
75
|
+
}
|
76
|
+
#pragma species endkernel correlation_k3
|
77
|
+
}
|
78
|
+
#pragma endscop
|
79
|
+
|
80
|
+
// Calculate the MxM correlation matrix
|
81
|
+
for (j1=0; j1<M-1; j1++) {
|
82
|
+
symmat[j1][j1] = 1.0;
|
83
|
+
for (j2=j1+1; j2<M; j2++) {
|
84
|
+
symmat[j1][j2] = 0.0;
|
85
|
+
for (i = 0; i<N; i++) {
|
86
|
+
symmat[j1][j2] += (data[i][j1] * data[i][j2]);
|
87
|
+
}
|
88
|
+
symmat[j2][j1] = symmat[j1][j2];
|
89
|
+
}
|
90
|
+
}
|
91
|
+
symmat[M-1][M-1] = 1.0;
|
92
|
+
|
93
|
+
// Clean-up and exit the function
|
94
|
+
fflush(stdout);
|
95
|
+
return 0;
|
96
|
+
}
|
97
|
+
|
@@ -0,0 +1,78 @@
|
|
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/covariance.c
|
17
|
+
// Author.............Cedric Nugteren
|
18
|
+
// Last modified on...26-Jun-2012
|
19
|
+
//
|
20
|
+
|
21
|
+
#include "common.h"
|
22
|
+
|
23
|
+
// This is 'covariance', a covariance computation algorithm
|
24
|
+
int main(void) {
|
25
|
+
int i,j,j1,j2;
|
26
|
+
|
27
|
+
// Declare arrays on the stack
|
28
|
+
float data[N][M];
|
29
|
+
float mean[M];
|
30
|
+
float symmat[M][M];
|
31
|
+
|
32
|
+
// Set the constants
|
33
|
+
float float_n = 1.2;
|
34
|
+
|
35
|
+
// Set the input data
|
36
|
+
for (i=0; i<N; i++) {
|
37
|
+
for (j=0; j<M; j++) {
|
38
|
+
data[i][j] = ((float) i*j) / M;
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
// Perform the computation
|
43
|
+
#pragma scop
|
44
|
+
{
|
45
|
+
#pragma species kernel data[0:N-1,0:M-1]|chunk(0:N-1,0:0) -> mean[0:M-1]|element
|
46
|
+
for (j = 0; j < M; j++) {
|
47
|
+
mean[j] = 0.0;
|
48
|
+
for (i = 0; i < N; i++) {
|
49
|
+
mean[j] += data[i][j];
|
50
|
+
}
|
51
|
+
mean[j] /= float_n;
|
52
|
+
}
|
53
|
+
#pragma species endkernel covariance_k1
|
54
|
+
#pragma species kernel data[0:N-1,0:M-1]|element ^ mean[0:M-1]|element -> data[0:N-1,0:M-1]|element
|
55
|
+
for (i = 0; i < N; i++) {
|
56
|
+
for (j = 0; j < M; j++) {
|
57
|
+
data[i][j] -= mean[j];
|
58
|
+
}
|
59
|
+
}
|
60
|
+
#pragma species endkernel covariance_k2
|
61
|
+
}
|
62
|
+
#pragma endscop
|
63
|
+
|
64
|
+
// Calculate the MxM covariance matrix
|
65
|
+
for (j1=0; j1<M; j1++) {
|
66
|
+
for (j2=j1; j2<M; j2++) {
|
67
|
+
symmat[j1][j2] = 0.0;
|
68
|
+
for (i=0; i<N; i++) {
|
69
|
+
symmat[j1][j2] += data[i][j1] * data[i][j2];
|
70
|
+
}
|
71
|
+
symmat[j2][j1] = symmat[j1][j2];
|
72
|
+
}
|
73
|
+
}
|
74
|
+
|
75
|
+
// Clean-up and exit the function
|
76
|
+
fflush(stdout);
|
77
|
+
return 0;
|
78
|
+
}
|