bones-compiler 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (203) hide show
  1. data/CHANGELOG +117 -0
  2. data/LICENSE +9 -0
  3. data/README.rdoc +126 -0
  4. data/Rakefile +107 -0
  5. data/VERSION +1 -0
  6. data/bin/bones +20 -0
  7. data/examples/applications/ffos.c +552 -0
  8. data/examples/benchmarks/2mm.c +70 -0
  9. data/examples/benchmarks/3mm.c +81 -0
  10. data/examples/benchmarks/adi.c +81 -0
  11. data/examples/benchmarks/atax.c +65 -0
  12. data/examples/benchmarks/bicg.c +67 -0
  13. data/examples/benchmarks/cholesky.c +64 -0
  14. data/examples/benchmarks/common.h +168 -0
  15. data/examples/benchmarks/correlation.c +97 -0
  16. data/examples/benchmarks/covariance.c +77 -0
  17. data/examples/benchmarks/doitgen.c +63 -0
  18. data/examples/benchmarks/durbin.c +76 -0
  19. data/examples/benchmarks/dynprog.c +67 -0
  20. data/examples/benchmarks/fdtd-2d-apml.c +114 -0
  21. data/examples/benchmarks/fdtd-2d.c +74 -0
  22. data/examples/benchmarks/floyd-warshall.c +50 -0
  23. data/examples/benchmarks/gemm.c +69 -0
  24. data/examples/benchmarks/gemver.c +89 -0
  25. data/examples/benchmarks/gesummv.c +64 -0
  26. data/examples/benchmarks/gramschmidt.c +84 -0
  27. data/examples/benchmarks/jacobi-1d-imper.c +55 -0
  28. data/examples/benchmarks/jacobi-2d-imper.c +61 -0
  29. data/examples/benchmarks/lu.c +57 -0
  30. data/examples/benchmarks/ludcmp.c +91 -0
  31. data/examples/benchmarks/mvt.c +65 -0
  32. data/examples/benchmarks/overview.txt +38 -0
  33. data/examples/benchmarks/reg_detect.c +82 -0
  34. data/examples/benchmarks/saxpy.c +45 -0
  35. data/examples/benchmarks/seidel-2d.c +51 -0
  36. data/examples/benchmarks/symm.c +74 -0
  37. data/examples/benchmarks/syr2k.c +65 -0
  38. data/examples/benchmarks/syrk.c +62 -0
  39. data/examples/benchmarks/trisolv.c +57 -0
  40. data/examples/benchmarks/trmm.c +57 -0
  41. data/examples/chunk/example1.c +54 -0
  42. data/examples/chunk/example2.c +44 -0
  43. data/examples/chunk/example3.c +59 -0
  44. data/examples/chunk/example4.c +55 -0
  45. data/examples/chunk/example5.c +52 -0
  46. data/examples/element/example1.c +46 -0
  47. data/examples/element/example10.c +50 -0
  48. data/examples/element/example11.c +47 -0
  49. data/examples/element/example12.c +56 -0
  50. data/examples/element/example2.c +46 -0
  51. data/examples/element/example3.c +58 -0
  52. data/examples/element/example4.c +49 -0
  53. data/examples/element/example5.c +56 -0
  54. data/examples/element/example6.c +46 -0
  55. data/examples/element/example7.c +54 -0
  56. data/examples/element/example8.c +45 -0
  57. data/examples/element/example9.c +48 -0
  58. data/examples/neighbourhood/example1.c +54 -0
  59. data/examples/neighbourhood/example2.c +55 -0
  60. data/examples/neighbourhood/example3.c +82 -0
  61. data/examples/neighbourhood/example4.c +52 -0
  62. data/examples/shared/example1.c +45 -0
  63. data/examples/shared/example2.c +51 -0
  64. data/examples/shared/example3.c +55 -0
  65. data/examples/shared/example4.c +52 -0
  66. data/examples/shared/example5.c +48 -0
  67. data/lib/bones.rb +266 -0
  68. data/lib/bones/algorithm.rb +541 -0
  69. data/lib/bones/engine.rb +386 -0
  70. data/lib/bones/preprocessor.rb +161 -0
  71. data/lib/bones/species.rb +196 -0
  72. data/lib/bones/structure.rb +94 -0
  73. data/lib/bones/variable.rb +169 -0
  74. data/lib/bones/variablelist.rb +72 -0
  75. data/lib/castaddon.rb +27 -0
  76. data/lib/castaddon/index.rb +40 -0
  77. data/lib/castaddon/node.rb +753 -0
  78. data/lib/castaddon/type.rb +37 -0
  79. data/skeletons/CPU-C/common/epilogue.c +0 -0
  80. data/skeletons/CPU-C/common/globals.c +17 -0
  81. data/skeletons/CPU-C/common/globals_kernel.c +1 -0
  82. data/skeletons/CPU-C/common/header.c +0 -0
  83. data/skeletons/CPU-C/common/mem_copy_D2H.c +0 -0
  84. data/skeletons/CPU-C/common/mem_copy_H2D.c +0 -0
  85. data/skeletons/CPU-C/common/mem_epilogue.c +0 -0
  86. data/skeletons/CPU-C/common/mem_prologue.c +3 -0
  87. data/skeletons/CPU-C/common/prologue.c +0 -0
  88. data/skeletons/CPU-C/common/timer_1_start.c +0 -0
  89. data/skeletons/CPU-C/common/timer_1_stop.c +0 -0
  90. data/skeletons/CPU-C/common/timer_2_start.c +20 -0
  91. data/skeletons/CPU-C/common/timer_2_stop.c +8 -0
  92. data/skeletons/CPU-C/kernel/default.host.c +3 -0
  93. data/skeletons/CPU-C/kernel/default.kernel.c +15 -0
  94. data/skeletons/CPU-C/skeletons.txt +24 -0
  95. data/skeletons/CPU-OPENCL-AMD/common/epilogue.c +6 -0
  96. data/skeletons/CPU-OPENCL-AMD/common/globals.c +155 -0
  97. data/skeletons/CPU-OPENCL-AMD/common/globals_kernel.c +4 -0
  98. data/skeletons/CPU-OPENCL-AMD/common/header.c +0 -0
  99. data/skeletons/CPU-OPENCL-AMD/common/mem_copy_D2H.c +8 -0
  100. data/skeletons/CPU-OPENCL-AMD/common/mem_copy_H2D.c +4 -0
  101. data/skeletons/CPU-OPENCL-AMD/common/mem_epilogue.c +3 -0
  102. data/skeletons/CPU-OPENCL-AMD/common/mem_prologue.c +6 -0
  103. data/skeletons/CPU-OPENCL-AMD/common/prologue.c +24 -0
  104. data/skeletons/CPU-OPENCL-AMD/common/timer_1_start.c +5 -0
  105. data/skeletons/CPU-OPENCL-AMD/common/timer_1_stop.c +9 -0
  106. data/skeletons/CPU-OPENCL-AMD/common/timer_2_start.c +16 -0
  107. data/skeletons/CPU-OPENCL-AMD/common/timer_2_stop.c +11 -0
  108. data/skeletons/CPU-OPENCL-AMD/kernel/D-element-to-1-shared.host.c +67 -0
  109. data/skeletons/CPU-OPENCL-AMD/kernel/D-element-to-1-shared.kernel.cl +72 -0
  110. data/skeletons/CPU-OPENCL-AMD/kernel/default.host.c +14 -0
  111. data/skeletons/CPU-OPENCL-AMD/kernel/default.kernel.cl +13 -0
  112. data/skeletons/CPU-OPENCL-AMD/skeletons.txt +26 -0
  113. data/skeletons/CPU-OPENCL-INTEL/common/epilogue.c +3 -0
  114. data/skeletons/CPU-OPENCL-INTEL/common/globals.c +154 -0
  115. data/skeletons/CPU-OPENCL-INTEL/common/globals_kernel.c +4 -0
  116. data/skeletons/CPU-OPENCL-INTEL/common/header.c +31 -0
  117. data/skeletons/CPU-OPENCL-INTEL/common/mem_copy_D2H.c +5 -0
  118. data/skeletons/CPU-OPENCL-INTEL/common/mem_copy_H2D.c +3 -0
  119. data/skeletons/CPU-OPENCL-INTEL/common/mem_epilogue.c +3 -0
  120. data/skeletons/CPU-OPENCL-INTEL/common/mem_prologue.c +4 -0
  121. data/skeletons/CPU-OPENCL-INTEL/common/prologue.c +24 -0
  122. data/skeletons/CPU-OPENCL-INTEL/common/timer_1_start.c +5 -0
  123. data/skeletons/CPU-OPENCL-INTEL/common/timer_1_stop.c +9 -0
  124. data/skeletons/CPU-OPENCL-INTEL/common/timer_2_start.c +16 -0
  125. data/skeletons/CPU-OPENCL-INTEL/common/timer_2_stop.c +11 -0
  126. data/skeletons/CPU-OPENCL-INTEL/kernel/D-element-to-1-shared.host.c +67 -0
  127. data/skeletons/CPU-OPENCL-INTEL/kernel/D-element-to-1-shared.kernel.cl +72 -0
  128. data/skeletons/CPU-OPENCL-INTEL/kernel/default.host.c +14 -0
  129. data/skeletons/CPU-OPENCL-INTEL/kernel/default.kernel.cl +13 -0
  130. data/skeletons/CPU-OPENCL-INTEL/skeletons.txt +26 -0
  131. data/skeletons/CPU-OPENMP/common/epilogue.c +0 -0
  132. data/skeletons/CPU-OPENMP/common/globals.c +37 -0
  133. data/skeletons/CPU-OPENMP/common/globals_kernel.c +6 -0
  134. data/skeletons/CPU-OPENMP/common/header.c +0 -0
  135. data/skeletons/CPU-OPENMP/common/mem_copy_D2H.c +0 -0
  136. data/skeletons/CPU-OPENMP/common/mem_copy_H2D.c +0 -0
  137. data/skeletons/CPU-OPENMP/common/mem_epilogue.c +0 -0
  138. data/skeletons/CPU-OPENMP/common/mem_prologue.c +3 -0
  139. data/skeletons/CPU-OPENMP/common/prologue.c +0 -0
  140. data/skeletons/CPU-OPENMP/common/timer_1_start.c +12 -0
  141. data/skeletons/CPU-OPENMP/common/timer_1_stop.c +0 -0
  142. data/skeletons/CPU-OPENMP/common/timer_2_start.c +18 -0
  143. data/skeletons/CPU-OPENMP/common/timer_2_stop.c +8 -0
  144. data/skeletons/CPU-OPENMP/kernel/D-element-to-1-shared.host.c +27 -0
  145. data/skeletons/CPU-OPENMP/kernel/D-element-to-1-shared.kernel.c +46 -0
  146. data/skeletons/CPU-OPENMP/kernel/default.host.c +11 -0
  147. data/skeletons/CPU-OPENMP/kernel/default.kernel.c +18 -0
  148. data/skeletons/CPU-OPENMP/skeletons.txt +26 -0
  149. data/skeletons/GPU-CUDA/common/epilogue.c +0 -0
  150. data/skeletons/GPU-CUDA/common/globals.c +31 -0
  151. data/skeletons/GPU-CUDA/common/globals_kernel.c +4 -0
  152. data/skeletons/GPU-CUDA/common/header.c +0 -0
  153. data/skeletons/GPU-CUDA/common/mem_copy_D2H.c +3 -0
  154. data/skeletons/GPU-CUDA/common/mem_copy_H2D.c +3 -0
  155. data/skeletons/GPU-CUDA/common/mem_epilogue.c +3 -0
  156. data/skeletons/GPU-CUDA/common/mem_prologue.c +5 -0
  157. data/skeletons/GPU-CUDA/common/prologue.c +6 -0
  158. data/skeletons/GPU-CUDA/common/timer_1_start.c +6 -0
  159. data/skeletons/GPU-CUDA/common/timer_1_stop.c +10 -0
  160. data/skeletons/GPU-CUDA/common/timer_2_start.c +6 -0
  161. data/skeletons/GPU-CUDA/common/timer_2_stop.c +10 -0
  162. data/skeletons/GPU-CUDA/kernel/2xN-N-chunk-1-N-to-D-element.host.c +3 -0
  163. data/skeletons/GPU-CUDA/kernel/2xN-N-chunk-1-N-to-D-element.kernel.cu +105 -0
  164. data/skeletons/GPU-CUDA/kernel/D-element-to-1-shared.host.c +3 -0
  165. data/skeletons/GPU-CUDA/kernel/D-element-to-1-shared.kernel.cu +119 -0
  166. data/skeletons/GPU-CUDA/kernel/D-element-to-N-shared.host.c +3 -0
  167. data/skeletons/GPU-CUDA/kernel/D-element-to-N-shared.kernel.cu +166 -0
  168. data/skeletons/GPU-CUDA/kernel/N-N-chunk-1-N-to-D-element.host.c +3 -0
  169. data/skeletons/GPU-CUDA/kernel/N-N-chunk-1-N-to-D-element.kernel.cu +69 -0
  170. data/skeletons/GPU-CUDA/kernel/N-neighbourhood-N-to-N-element.host.c +3 -0
  171. data/skeletons/GPU-CUDA/kernel/N-neighbourhood-N-to-N-element.kernel.cu +42 -0
  172. data/skeletons/GPU-CUDA/kernel/default.host.c +3 -0
  173. data/skeletons/GPU-CUDA/kernel/default.kernel.cu +28 -0
  174. data/skeletons/GPU-CUDA/skeletons.txt +30 -0
  175. data/skeletons/GPU-OPENCL-AMD/common/epilogue.c +3 -0
  176. data/skeletons/GPU-OPENCL-AMD/common/globals.c +155 -0
  177. data/skeletons/GPU-OPENCL-AMD/common/globals_kernel.c +4 -0
  178. data/skeletons/GPU-OPENCL-AMD/common/header.c +0 -0
  179. data/skeletons/GPU-OPENCL-AMD/common/mem_copy_D2H.c +4 -0
  180. data/skeletons/GPU-OPENCL-AMD/common/mem_copy_H2D.c +4 -0
  181. data/skeletons/GPU-OPENCL-AMD/common/mem_epilogue.c +3 -0
  182. data/skeletons/GPU-OPENCL-AMD/common/mem_prologue.c +3 -0
  183. data/skeletons/GPU-OPENCL-AMD/common/prologue.c +24 -0
  184. data/skeletons/GPU-OPENCL-AMD/common/timer_1_start.c +5 -0
  185. data/skeletons/GPU-OPENCL-AMD/common/timer_1_stop.c +9 -0
  186. data/skeletons/GPU-OPENCL-AMD/common/timer_2_start.c +4 -0
  187. data/skeletons/GPU-OPENCL-AMD/common/timer_2_stop.c +11 -0
  188. data/skeletons/GPU-OPENCL-AMD/kernel/D-element-to-1-shared.host.c +67 -0
  189. data/skeletons/GPU-OPENCL-AMD/kernel/D-element-to-1-shared.kernel.cl +72 -0
  190. data/skeletons/GPU-OPENCL-AMD/kernel/default.host.c +14 -0
  191. data/skeletons/GPU-OPENCL-AMD/kernel/default.kernel.cl +13 -0
  192. data/skeletons/GPU-OPENCL-AMD/skeletons.txt +26 -0
  193. data/skeletons/verification/header.c +2 -0
  194. data/skeletons/verification/timer_start.c +4 -0
  195. data/skeletons/verification/timer_stop.c +6 -0
  196. data/skeletons/verification/verify_results.c +23 -0
  197. data/test/bones/test_algorithm.rb +40 -0
  198. data/test/bones/test_common.rb +54 -0
  199. data/test/bones/test_preprocessor.rb +46 -0
  200. data/test/bones/test_species.rb +21 -0
  201. data/test/bones/test_variable.rb +84 -0
  202. data/test/test_helper.rb +106 -0
  203. metadata +303 -0
@@ -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...26-Jun-2012
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
+ // Determine the mean of the column vectors of the input data matrix
47
+ #pragma species kernel 0:N-1,0:M-1|chunk(0:N-1,0:0) -> 0:M-1|element
48
+ for (j=0; j<M; j++) {
49
+ mean[j] = 0.0;
50
+ for (i=0; i<N; i++) {
51
+ mean[j] += data[i][j];
52
+ }
53
+ mean[j] /= float_n;
54
+ }
55
+ #pragma species endkernel correlation-part1
56
+ #pragma species kernel 0:M-1|element ^ 0:N-1,0:M-1|chunk(0:N-1,0:0) -> 0:M-1|element
57
+ // Determine the standard deviations of the column vectors of the input data matrix
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-part2
69
+ #pragma species kernel 0:N-1,0:M-1|element ^ 0:M-1|element ^ 0:M-1|element -> 0:N-1,0:M-1|element
70
+ // Center and reduce the column vectors
71
+ for (i=0; i<N; i++) {
72
+ for (j=0; j<M; j++) {
73
+ data[i][j] -= mean[j];
74
+ data[i][j] /= sqrt(float_n) * stddev[j];
75
+ }
76
+ }
77
+ #pragma species endkernel correlation-part3
78
+ // Calculate the MxM correlation matrix
79
+ for (j1=0; j1<M-1; j1++) {
80
+ symmat[j1][j1] = 1.0;
81
+ #pragma species kernel 0:N-1,j1:j1|full ^ 0:N-1,j1+1:M-1|chunk(0:N-1,0:0) -> j1+1:M-1,j1:j1|element ^ j1:j1,j1+1:M-1|element
82
+ for (j2=j1+1; j2<M; j2++) {
83
+ symmat[j1][j2] = 0.0;
84
+ for (i = 0; i<N; i++) {
85
+ symmat[j1][j2] += (data[i][j1] * data[i][j2]);
86
+ }
87
+ symmat[j2][j1] = symmat[j1][j2];
88
+ }
89
+ #pragma species endkernel correlation-part4
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,77 @@
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 species kernel 0:N-1,0:M-1|chunk(0:N-1,0:0) -> 0:M-1|element
44
+ // Determine the mean of the column vectors of the input data matrix
45
+ for (j=0; j<M; j++) {
46
+ mean[j] = 0.0;
47
+ for (i=0; i<N; i++) {
48
+ mean[j] += data[i][j];
49
+ }
50
+ mean[j] /= float_n;
51
+ }
52
+ #pragma species endkernel covariance-part1
53
+ #pragma species kernel 0:N-1,0:M-1|element ^ 0:M-1|element -> 0:N-1,0:M-1|element
54
+ // Center the column vectors
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-part2
61
+ // Calculate the MxM covariance matrix
62
+ for (j1=0; j1<M; j1++) {
63
+ #pragma species kernel 0:N-1,j1:j1|full ^ 0:N-1,j1:M-1|chunk(0:N-1,0:0) -> j1:M-1,j1:j1|element ^ j1:j1,j1:M-1|element
64
+ for (j2=j1; j2<M; j2++) {
65
+ symmat[j1][j2] = 0.0;
66
+ for (i=0; i<N; i++) {
67
+ symmat[j1][j2] += data[i][j1] * data[i][j2];
68
+ }
69
+ symmat[j2][j1] = symmat[j1][j2];
70
+ }
71
+ #pragma species endkernel covariance-part3
72
+ }
73
+
74
+ // Clean-up and exit the function
75
+ fflush(stdout);
76
+ return 0;
77
+ }
@@ -0,0 +1,63 @@
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/doitgen.c
17
+ // Author.............Cedric Nugteren
18
+ // Last modified on...10-April-2012
19
+ //
20
+
21
+ #include "common.h"
22
+
23
+ // This is 'doitgen', a multiresolution analysis kernel
24
+ int main(void) {
25
+ int i,j,k,p,q,r,s;
26
+
27
+ // Declare arrays on the stack
28
+ float A[NR][NQ][NP];
29
+ float sum[NR][NQ][NP];
30
+ float C4[NP][NP];
31
+
32
+ // Set the input data
33
+ for (i=0; i<NR; i++) { for (j=0; j<NQ; j++) { for (k=0; k<NP; k++) { A[i][j][k] = ((float) i*j + k) / NP; } } }
34
+ for (i=0; i<NP; i++) { for (j=0; j<NP; j++) { C4[i][j] = ((float) i*j) / NP; } }
35
+
36
+ // Perform the computation
37
+ #pragma species kernel 0:NR-1,0:NQ-1,0:NP-1|chunk(0:0,0:0,0:NP-1) ^ 0:NP-1,0:NP-1|chunk(0:NP-1,0:0) -> 0:NR-1,0:NQ-1,0:NP-1|element
38
+ for (r=0; r<NR; r++) {
39
+ for (q=0; q<NQ; q++) {
40
+ for (p=0; p<NP; p++) {
41
+ sum[r][q][p] = 0;
42
+ for (s=0; s<NP; s++) {
43
+ sum[r][q][p] = sum[r][q][p] + A[r][q][s] * C4[s][p];
44
+ }
45
+ }
46
+ }
47
+ }
48
+ #pragma species endkernel doitgen-part1
49
+ #pragma species kernel 0:NR-1,0:NQ-1,0:NP-1|element -> 0:NR-1,0:NQ-1,0:NP-1|element
50
+ for (r=0; r<NR; r++) {
51
+ for (q=0; q<NQ; q++) {
52
+ for (p=0; p<NP; p++) {
53
+ A[r][q][p] = sum[r][q][p];
54
+ }
55
+ }
56
+ }
57
+ #pragma species endkernel doitgen-part2
58
+
59
+ // Clean-up and exit the function
60
+ fflush(stdout);
61
+ return 0;
62
+ }
63
+
@@ -0,0 +1,76 @@
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/durbin.c
17
+ // Author.............Cedric Nugteren
18
+ // Last modified on...03-Jul-2012
19
+ //
20
+
21
+ #include "common.h"
22
+
23
+ // This is 'durbin', an algorithm to solve an equation involving a Toeplitz matrix using the Levinson-Durbin recursion
24
+ int main(void) {
25
+ int i,j,k;
26
+ float alpha_k;
27
+
28
+ // Declare arrays on the stack
29
+ float alpha[NX];
30
+ float beta[NX];
31
+ float r[NX];
32
+ float y[NX][NX];
33
+ float sum[NX][NX];
34
+ float out[NX];
35
+
36
+ // Set the input data
37
+ for (i=0; i<NX; i++) {
38
+ alpha[i] = i;
39
+ beta[i] = (i+1)/NX/2.0;
40
+ r[i] = (i+1)/NX/4.0;
41
+ for (j=0; j<NX; j++) {
42
+ y[i][j] = ((float) i*j) / NX;
43
+ sum[i][j] = ((float) i*j) / NX;
44
+ }
45
+ }
46
+
47
+ // Perform the computation
48
+ y[0][0] = r[0];
49
+ beta[0] = 1;
50
+ alpha[0] = r[0];
51
+ for (k=1; k<NX; k++) {
52
+ beta[k] = beta[k-1] - alpha[k-1] * alpha[k-1] * beta[k-1];
53
+ sum[0][k] = r[k];
54
+ for (i=0; i<=k-1; i++) {
55
+ sum[i+1][k] = sum[i][k] + r[k-i-1] * y[i][k-1];
56
+ }
57
+ alpha[k] = -sum[k][k] * beta[k];
58
+ alpha_k = alpha[k];
59
+ #pragma species kernel 0:k-1,k-1:k-1|element ^ k-1:0,k-1:k-1|element -> 0:k-1,k:k|element
60
+ for (i=0; i<=k-1; i++) {
61
+ y[i][k] = y[i][k-1] + alpha_k * y[k-i-1][k-1];
62
+ }
63
+ #pragma species endkernel durbin-part1
64
+ y[k][k] = alpha[k];
65
+ }
66
+ #pragma species kernel 0:NX-1,NX-1:NX-1|element -> 0:NX-1|element
67
+ for (i=0; i<NX; i++) {
68
+ out[i] = y[i][NX-1];
69
+ }
70
+ #pragma species endkernel durbin-part2
71
+
72
+ // Clean-up and exit the function
73
+ fflush(stdout);
74
+ return 0;
75
+ }
76
+
@@ -0,0 +1,67 @@
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/dynprog.c
17
+ // Author.............Cedric Nugteren
18
+ // Last modified on...29-May-2012
19
+ //
20
+
21
+ #include "common.h"
22
+
23
+ // This is 'dynprog', a 2D dynamic programming algorithm
24
+ int main(void) {
25
+ int i,j,k,iter;
26
+
27
+ // Declare arrays on the stack
28
+ float C[LENGTH][LENGTH];
29
+ float W[LENGTH][LENGTH];
30
+ float c[LENGTH][LENGTH];
31
+ float sum_c[LENGTH][LENGTH][LENGTH];
32
+ float out;
33
+
34
+ // Set the input data
35
+ for (i=0; i<LENGTH; i++) {
36
+ for (j=0; j<LENGTH; j++) {
37
+ C[i][j] = i*j % 2;
38
+ W[i][j] = ((float) i-j) / LENGTH;
39
+ }
40
+ }
41
+
42
+ // Perform the computation
43
+ for (iter=0; iter<ITER; iter++) {
44
+ #pragma species kernel 0:0|void -> 0:LENGTH-1,0:LENGTH-1|element
45
+ for (i=0; i<=LENGTH-1; i++) {
46
+ for (j=0; j<=LENGTH-1; j++) {
47
+ c[i][j] = 0;
48
+ }
49
+ }
50
+ #pragma species endkernel dynprog
51
+ for (i=0; i<=LENGTH-2; i++) {
52
+ for (j=i+1; j<=LENGTH-1; j++) {
53
+ sum_c[i][j][i] = 0;
54
+ for (k=i+1; k<=j-1; k++) {
55
+ sum_c[i][j][k] = sum_c[i][j][k - 1] + c[i][k] + c[k][j];
56
+ }
57
+ c[i][j] = sum_c[i][j][j-1] + W[i][j];
58
+ }
59
+ }
60
+ out += c[0][LENGTH-1];
61
+ }
62
+
63
+ // Clean-up and exit the function
64
+ fflush(stdout);
65
+ return 0;
66
+ }
67
+
@@ -0,0 +1,114 @@
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/fdtd-2d-apml.c
17
+ // Author.............Cedric Nugteren
18
+ // Last modified on...30-May-2012
19
+ //
20
+
21
+ #include "common.h"
22
+
23
+ // This is 'fdtd-2d-apml', a 2D finite different time domain kernel using an anisotropic perfectly matched layer
24
+ int main(void) {
25
+ int i,j,k;
26
+ int ix,iy,iz;
27
+ float clf, tmp;
28
+ float czm_iz, czp_iz;
29
+ float cymh_iy, cyph_iy;
30
+
31
+ // Declare arrays on the stack
32
+ float czm[CZ+1];
33
+ float czp[CZ+1];
34
+ float cxmh[CXM+1];
35
+ float cxph[CXM+1];
36
+ float cymh[CYM+1];
37
+ float cyph[CYM+1];
38
+ float Ry[CZ+1][CYM+1];
39
+ float Ax[CZ+1][CYM+1];
40
+ float Ex[CZ+1][CYM+1][CXM+1];
41
+ float Ey[CZ+1][CYM+1][CXM+1];
42
+ float Hz[CZ+1][CYM+1][CXM+1];
43
+ float Bza[CZ+1][CYM+1][CXM+1];
44
+
45
+ // Set the constants
46
+ float mui = 2341;
47
+ float ch = 42;
48
+
49
+ // Set the input data
50
+ for (i=0; i<=CZ; i++) {
51
+ czm[i] = ((float) i+1) / CXM;
52
+ czp[i] = ((float) i+2) / CXM;
53
+ }
54
+ for (i=0; i<=CXM; i++) {
55
+ cxmh[i] = ((float) i+3) / CXM;
56
+ cxph[i] = ((float) i+4) / CXM;
57
+ }
58
+ for (i=0; i<=CYM; i++) {
59
+ cymh[i] = ((float) i+5) / CXM;
60
+ cyph[i] = ((float) i+6) / CXM;
61
+ }
62
+ for (i=0; i<=CZ; i++) {
63
+ for (j=0; j<=CYM; j++) {
64
+ Ry[i][j] = ((float) i*(j+1) + 10) / CYM;
65
+ Ax[i][j] = ((float) i*(j+2) + 11) / CYM;
66
+ for (k=0; k<=CXM; k++) {
67
+ Ex[i][j][k] = ((float) i*(j+3) + k+1) / CXM;
68
+ Ey[i][j][k] = ((float) i*(j+4) + k+2) / CYM;
69
+ Hz[i][j][k] = ((float) i*(j+5) + k+3) / CZ;
70
+ }
71
+ }
72
+ }
73
+
74
+ // Perform the computation
75
+ for (iz=0; iz<CZ; iz++) {
76
+ for (iy=0; iy<CYM; iy++) {
77
+ czm_iz = czm[iz];
78
+ czp_iz = czp[iz];
79
+ cymh_iy = cymh[iy];
80
+ cyph_iy = cyph[iy];
81
+
82
+ #pragma species kernel iz:iz,iy:iy+1,0:CXM-1|chunk(0:0,0:1,0:0) ^ iz:iz,iy:iy,0:CXM-1|neighbourhood(0:0,0:0,0:1) ^ iz:iz,iy:iy,0:CXM-1|element ^ iz:iz,iy:iy,0:CXM-1|element ^ 0:CXM-1|element ^ 0:CXM-1|element -> iz:iz,iy:iy,0:CXM-1|element ^ iz:iz,iy:iy,0:CXM-1|element
83
+ for (ix=0; ix<CXM; ix++) {
84
+ clf = Ex[iz][iy][ix] - Ex[iz][iy+1][ix] + Ey[iz][iy][ix+1] - Ey[iz][iy][ix];
85
+ tmp = (cymh_iy/cyph_iy) * Bza[iz][iy][ix] - (ch/cyph_iy) * clf;
86
+ Hz[iz][iy][ix] = Hz[iz][iy][ix] * (cxmh[ix]/cxph[ix]) + (mui * czp_iz/cxph[ix]) * tmp - (mui * czm_iz/cxph[ix]) * Bza[iz][iy][ix];
87
+ Bza[iz][iy][ix] = tmp;
88
+ }
89
+ #pragma species endkernel fdtd-2d-apml
90
+
91
+ clf = Ex[iz][iy][CXM] - Ex[iz][iy+1][CXM] + Ry[iz][iy] - Ey[iz][iy][CXM];
92
+ tmp = (cymh_iy/cyph_iy) * Bza[iz][iy][CXM] - (ch/cyph_iy) * clf;
93
+ Hz[iz][iy][CXM] = (cxmh[CXM]/cxph[CXM]) * Hz[iz][iy][CXM] + (mui * czp_iz/cxph[CXM]) * tmp - (mui * czm_iz/cxph[CXM]) * Bza[iz][iy][CXM];
94
+ Bza[iz][iy][CXM] = tmp;
95
+
96
+ for (ix=0; ix<CXM; ix++) {
97
+ clf = Ex[iz][CYM][ix] - Ax[iz][ix] + Ey[iz][CYM][ix+1] - Ey[iz][CYM][ix];
98
+ tmp = (cymh[CYM]/cyph_iy) * Bza[iz][iy][ix] - (ch/cyph_iy) * clf;
99
+ Hz[iz][CYM][ix] = (cxmh[ix]/cxph[ix]) * Hz[iz][CYM][ix] + (mui * czp_iz/cxph[ix]) * tmp - (mui * czm_iz/cxph[ix]) * Bza[iz][CYM][ix];
100
+ Bza[iz][CYM][ix] = tmp;
101
+ }
102
+
103
+ clf = Ex[iz][CYM][CXM] - Ax[iz][CXM] + Ry[iz][CYM] - Ey[iz][CYM][CXM];
104
+ tmp = (cymh[CYM]/cyph[CYM]) * Bza[iz][CYM][CXM] - (ch/cyph[CYM]) * clf;
105
+ Hz[iz][CYM][CXM] = (cxmh[CXM]/cxph[CXM]) * Hz[iz][CYM][CXM] + (mui * czp_iz/cxph[CXM]) * tmp - (mui * czm_iz/cxph[CXM]) * Bza[iz][CYM][CXM];
106
+ Bza[iz][CYM][CXM] = tmp;
107
+ }
108
+ }
109
+
110
+ // Clean-up and exit the function
111
+ fflush(stdout);
112
+ return 0;
113
+ }
114
+