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.
Files changed (211) hide show
  1. checksums.yaml +15 -0
  2. data/CHANGELOG +37 -0
  3. data/LICENSE +1 -1
  4. data/README.rdoc +95 -70
  5. data/Rakefile +78 -3
  6. data/VERSION +1 -1
  7. data/bin/adarwin +17 -0
  8. data/examples/benchmarks/PolyBench/2mm.c +104 -0
  9. data/examples/benchmarks/{3mm.c → PolyBench/3mm.c} +5 -2
  10. data/examples/benchmarks/{adi.c → PolyBench/adi.c} +6 -3
  11. data/examples/benchmarks/{atax.c → PolyBench/atax.c} +5 -2
  12. data/examples/benchmarks/{bicg.c → PolyBench/bicg.c} +5 -2
  13. data/examples/benchmarks/{cholesky.c → PolyBench/cholesky.c} +3 -0
  14. data/examples/benchmarks/{common.h → PolyBench/common.h} +2 -2
  15. data/examples/benchmarks/{correlation.c → PolyBench/correlation.c} +16 -7
  16. data/examples/benchmarks/{covariance.c → PolyBench/covariance.c} +7 -2
  17. data/examples/benchmarks/{doitgen.c → PolyBench/doitgen.c} +5 -2
  18. data/examples/benchmarks/{durbin.c → PolyBench/durbin.c} +3 -0
  19. data/examples/benchmarks/{dynprog.c → PolyBench/dynprog.c} +3 -0
  20. data/examples/benchmarks/{fdtd-2d-apml.c → PolyBench/fdtd-2d-apml.c} +3 -0
  21. data/examples/benchmarks/{fdtd-2d.c → PolyBench/fdtd-2d.c} +5 -2
  22. data/examples/benchmarks/{floyd-warshall.c → PolyBench/floyd-warshall.c} +3 -0
  23. data/examples/benchmarks/{gemm.c → PolyBench/gemm.c} +5 -2
  24. data/examples/benchmarks/{gemver.c → PolyBench/gemver.c} +5 -2
  25. data/examples/benchmarks/{gesummv.c → PolyBench/gesummv.c} +5 -2
  26. data/examples/benchmarks/{gramschmidt.c → PolyBench/gramschmidt.c} +3 -0
  27. data/examples/benchmarks/{jacobi-1d-imper.c → PolyBench/jacobi-1d-imper.c} +10 -2
  28. data/examples/benchmarks/{jacobi-2d-imper.c → PolyBench/jacobi-2d-imper.c} +8 -3
  29. data/examples/benchmarks/{lu.c → PolyBench/lu.c} +3 -0
  30. data/examples/benchmarks/{ludcmp.c → PolyBench/ludcmp.c} +3 -0
  31. data/examples/benchmarks/{mvt.c → PolyBench/mvt.c} +6 -2
  32. data/examples/benchmarks/{reg_detect.c → PolyBench/reg_detect.c} +3 -0
  33. data/examples/benchmarks/{seidel-2d.c → PolyBench/seidel-2d.c} +3 -0
  34. data/examples/benchmarks/{symm.c → PolyBench/symm.c} +3 -0
  35. data/examples/benchmarks/{syr2k.c → PolyBench/syr2k.c} +5 -2
  36. data/examples/benchmarks/{syrk.c → PolyBench/syrk.c} +7 -4
  37. data/examples/benchmarks/{trisolv.c → PolyBench/trisolv.c} +3 -0
  38. data/examples/benchmarks/{trmm.c → PolyBench/trmm.c} +3 -0
  39. data/examples/benchmarks/Rodinia/cfd.c +180 -0
  40. data/examples/benchmarks/Rodinia/hotspot.c +228 -0
  41. data/examples/benchmarks/Rodinia/kmeans.c +164 -0
  42. data/examples/benchmarks/Rodinia/srad.c +188 -0
  43. data/examples/benchmarks/other/common.h +0 -0
  44. data/examples/benchmarks/other/dct.c +58 -0
  45. data/examples/benchmarks/other/mm.c +50 -0
  46. data/examples/benchmarks/{saxpy.c → other/saxpy.c} +11 -7
  47. data/examples/chunk/{example1.c → example01.c} +0 -0
  48. data/examples/chunk/{example2.c → example02.c} +0 -0
  49. data/examples/chunk/{example3.c → example03.c} +0 -0
  50. data/examples/chunk/{example4.c → example04.c} +0 -0
  51. data/examples/chunk/{example5.c → example05.c} +0 -0
  52. data/examples/chunk/example06.c +45 -0
  53. data/examples/chunk/example07.c +49 -0
  54. data/examples/dependences/example01.c +42 -0
  55. data/examples/dependences/example02.c +40 -0
  56. data/examples/dependences/example03.c +43 -0
  57. data/examples/dependences/example04.c +44 -0
  58. data/examples/dependences/example05.c +42 -0
  59. data/examples/element/{example1.c → example01.c} +0 -0
  60. data/examples/element/{example2.c → example02.c} +2 -2
  61. data/examples/element/{example3.c → example03.c} +0 -0
  62. data/examples/element/{example4.c → example04.c} +0 -0
  63. data/examples/element/{example5.c → example05.c} +0 -0
  64. data/examples/element/{example6.c → example06.c} +0 -0
  65. data/examples/element/{example7.c → example07.c} +0 -0
  66. data/examples/element/{example8.c → example08.c} +0 -0
  67. data/examples/element/{example9.c → example09.c} +0 -0
  68. data/examples/element/example13.c +73 -0
  69. data/examples/fusion/example01.c +68 -0
  70. data/examples/fusion/example02.c +73 -0
  71. data/examples/fusion/example03.c +72 -0
  72. data/examples/fusion/example04.c +61 -0
  73. data/examples/fusion/example05.c +55 -0
  74. data/examples/neighbourhood/{example1.c → example01.c} +0 -0
  75. data/examples/neighbourhood/{example2.c → example02.c} +0 -0
  76. data/examples/neighbourhood/{example3.c → example03.c} +0 -0
  77. data/examples/neighbourhood/{example4.c → example04.c} +0 -0
  78. data/examples/neighbourhood/example05.c +44 -0
  79. data/examples/shared/{example1.c → example01.c} +0 -0
  80. data/examples/shared/{example2.c → example02.c} +0 -0
  81. data/examples/shared/{example3.c → example03.c} +0 -0
  82. data/examples/shared/{example4.c → example04.c} +0 -0
  83. data/examples/shared/{example5.c → example05.c} +0 -0
  84. data/lib/adarwin.rb +62 -0
  85. data/lib/adarwin/dependences.rb +268 -0
  86. data/lib/adarwin/engine.rb +277 -0
  87. data/lib/adarwin/fusion.rb +174 -0
  88. data/lib/adarwin/interval.rb +57 -0
  89. data/lib/adarwin/memorycopies.rb +153 -0
  90. data/lib/adarwin/nest.rb +225 -0
  91. data/lib/adarwin/preprocessor.rb +76 -0
  92. data/lib/adarwin/reference.rb +261 -0
  93. data/lib/bones.rb +4 -55
  94. data/lib/bones/algorithm.rb +77 -40
  95. data/lib/bones/copy.rb +26 -0
  96. data/lib/bones/engine.rb +147 -31
  97. data/lib/bones/preprocessor.rb +92 -12
  98. data/lib/bones/species.rb +4 -3
  99. data/lib/bones/structure.rb +14 -4
  100. data/lib/castaddon.rb +11 -6
  101. data/lib/castaddon/node_adarwin.rb +245 -0
  102. data/lib/castaddon/node_bones.rb +316 -0
  103. data/lib/castaddon/node_common.rb +289 -0
  104. data/lib/castaddon/transformations.rb +236 -0
  105. data/lib/common.rb +216 -0
  106. data/skeletons/CPU-C/common/header.c +3 -0
  107. data/skeletons/CPU-C/common/mem_global.c +0 -0
  108. data/skeletons/CPU-C/common/timer_2_start.c +11 -13
  109. data/skeletons/CPU-C/common/timer_2_stop.c +1 -1
  110. data/skeletons/CPU-C/common/timer_globals.c +29 -0
  111. data/skeletons/CPU-OPENCL-INTEL/common/globals.c +1 -1
  112. data/skeletons/CPU-OPENCL-INTEL/common/header.c +3 -0
  113. data/skeletons/CPU-OPENCL-INTEL/common/mem_copy_D2H.c +7 -2
  114. data/skeletons/CPU-OPENCL-INTEL/common/mem_copy_H2D.c +4 -2
  115. data/skeletons/CPU-OPENCL-INTEL/common/mem_global.c +0 -0
  116. data/skeletons/CPU-OPENCL-INTEL/common/mem_prologue.c +6 -3
  117. data/skeletons/CPU-OPENCL-INTEL/common/timer_2_stop.c +1 -1
  118. data/skeletons/CPU-OPENCL-INTEL/common/timer_globals.c +24 -0
  119. data/skeletons/CPU-OPENMP/common/globals.c +1 -0
  120. data/skeletons/CPU-OPENMP/common/header.c +3 -0
  121. data/skeletons/CPU-OPENMP/common/mem_global.c +0 -0
  122. data/skeletons/CPU-OPENMP/common/timer_1_start.c +0 -12
  123. data/skeletons/CPU-OPENMP/common/timer_2_stop.c +1 -1
  124. data/skeletons/CPU-OPENMP/common/timer_globals.c +33 -0
  125. data/skeletons/GPU-CUDA/common/globals.c +27 -3
  126. data/skeletons/GPU-CUDA/common/header.c +2 -0
  127. data/skeletons/GPU-CUDA/common/mem_async_alloc.c +6 -0
  128. data/skeletons/GPU-CUDA/common/mem_async_copyin.c +6 -0
  129. data/skeletons/GPU-CUDA/common/mem_async_copyout.c +6 -0
  130. data/skeletons/GPU-CUDA/common/mem_async_free.c +6 -0
  131. data/skeletons/GPU-CUDA/common/mem_copy_D2H.c +2 -1
  132. data/skeletons/GPU-CUDA/common/mem_copy_H2D.c +2 -1
  133. data/skeletons/GPU-CUDA/common/mem_global.c +1 -0
  134. data/skeletons/GPU-CUDA/common/mem_prologue.c +1 -2
  135. data/skeletons/GPU-CUDA/common/scheduler.c +86 -0
  136. data/skeletons/GPU-CUDA/common/timer_2_start.c +2 -4
  137. data/skeletons/GPU-CUDA/common/timer_2_stop.c +3 -5
  138. data/skeletons/GPU-CUDA/common/timer_globals.c +26 -0
  139. data/skeletons/GPU-CUDA/kernel/2xN-N-chunk-1-N-to-D-element.kernel.cu +5 -7
  140. data/skeletons/GPU-CUDA/kernel/N-N-chunk-1-N-to-D-element.kernel.cu +4 -6
  141. data/skeletons/GPU-CUDA/kernel/default.host.c +1 -1
  142. data/skeletons/GPU-CUDA/kernel/default.kernel.cu +6 -8
  143. data/skeletons/GPU-CUDA/skeletons.txt +6 -5
  144. data/{examples/benchmarks/2mm.c → test/examples/benchmarks/PolyBench/2mm_species.c} +19 -15
  145. data/test/examples/benchmarks/PolyBench/3mm_species.c +82 -0
  146. data/test/examples/benchmarks/PolyBench/adi_species.c +89 -0
  147. data/test/examples/benchmarks/PolyBench/atax_species.c +69 -0
  148. data/test/examples/benchmarks/PolyBench/bicg_species.c +71 -0
  149. data/test/examples/benchmarks/PolyBench/cholesky_species.c +68 -0
  150. data/test/examples/benchmarks/PolyBench/correlation_species.c +97 -0
  151. data/test/examples/benchmarks/PolyBench/covariance_species.c +78 -0
  152. data/test/examples/benchmarks/PolyBench/doitgen_species.c +67 -0
  153. data/test/examples/benchmarks/PolyBench/durbin_species.c +80 -0
  154. data/test/examples/benchmarks/PolyBench/dynprog_species.c +71 -0
  155. data/test/examples/benchmarks/PolyBench/fdtd-2d-apml_species.c +112 -0
  156. data/test/examples/benchmarks/PolyBench/fdtd-2d_species.c +78 -0
  157. data/test/examples/benchmarks/PolyBench/floyd-warshall_species.c +54 -0
  158. data/test/examples/benchmarks/PolyBench/gemm_species.c +73 -0
  159. data/test/examples/benchmarks/PolyBench/gemver_species.c +93 -0
  160. data/test/examples/benchmarks/PolyBench/gesummv_species.c +68 -0
  161. data/test/examples/benchmarks/PolyBench/gramschmidt_species.c +78 -0
  162. data/test/examples/benchmarks/PolyBench/jacobi-1d-imper_species.c +59 -0
  163. data/test/examples/benchmarks/PolyBench/jacobi-2d-imper_species.c +65 -0
  164. data/test/examples/benchmarks/PolyBench/lu_species.c +57 -0
  165. data/test/examples/benchmarks/PolyBench/ludcmp_species.c +89 -0
  166. data/test/examples/benchmarks/PolyBench/mvt_species.c +69 -0
  167. data/test/examples/benchmarks/PolyBench/reg_detect_species.c +86 -0
  168. data/test/examples/benchmarks/PolyBench/seidel-2d_species.c +53 -0
  169. data/test/examples/benchmarks/PolyBench/symm_species.c +74 -0
  170. data/test/examples/benchmarks/PolyBench/syr2k_species.c +69 -0
  171. data/test/examples/benchmarks/PolyBench/syrk_species.c +66 -0
  172. data/test/examples/benchmarks/PolyBench/trisolv_species.c +61 -0
  173. data/test/examples/benchmarks/PolyBench/trmm_species.c +61 -0
  174. data/test/examples/chunk/example01_species.c +58 -0
  175. data/test/examples/chunk/example02_species.c +48 -0
  176. data/test/examples/chunk/example03_species.c +63 -0
  177. data/test/examples/chunk/example04_species.c +58 -0
  178. data/test/examples/chunk/example05_species.c +56 -0
  179. data/test/examples/chunk/example06_species.c +49 -0
  180. data/test/examples/chunk/example07_species.c +53 -0
  181. data/test/examples/dependences/example01_species.c +46 -0
  182. data/test/examples/dependences/example02_species.c +44 -0
  183. data/test/examples/dependences/example03_species.c +47 -0
  184. data/test/examples/dependences/example04_species.c +48 -0
  185. data/test/examples/dependences/example05_species.c +46 -0
  186. data/test/examples/element/example01_species.c +50 -0
  187. data/test/examples/element/example02_species.c +50 -0
  188. data/test/examples/element/example03_species.c +62 -0
  189. data/test/examples/element/example04_species.c +53 -0
  190. data/test/examples/element/example05_species.c +59 -0
  191. data/test/examples/element/example06_species.c +50 -0
  192. data/test/examples/element/example07_species.c +58 -0
  193. data/test/examples/element/example08_species.c +49 -0
  194. data/test/examples/element/example09_species.c +52 -0
  195. data/test/examples/element/example10_species.c +54 -0
  196. data/test/examples/element/example11_species.c +51 -0
  197. data/test/examples/element/example12_species.c +60 -0
  198. data/test/examples/element/example13_species.c +77 -0
  199. data/test/examples/neighbourhood/example01_species.c +57 -0
  200. data/test/examples/neighbourhood/example02_species.c +56 -0
  201. data/test/examples/neighbourhood/example03_species.c +83 -0
  202. data/test/examples/neighbourhood/example04_species.c +55 -0
  203. data/test/examples/neighbourhood/example05_species.c +48 -0
  204. data/test/examples/shared/example01_species.c +49 -0
  205. data/test/examples/shared/example02_species.c +55 -0
  206. data/test/examples/shared/example03_species.c +59 -0
  207. data/test/examples/shared/example04_species.c +56 -0
  208. data/test/examples/shared/example05_species.c +52 -0
  209. metadata +193 -73
  210. data/examples/benchmarks/overview.txt +0 -38
  211. data/lib/castaddon/node.rb +0 -753
@@ -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/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 scop
38
+ {
39
+ #pragma species kernel A[0:NR-1,0:NQ-1,0:NP-1]|chunk(0:0,0:0,0:NP-1) ^ C4[0:NP-1,0:NP-1]|chunk(0:NP-1,0:0) -> sum[0:NR-1,0:NQ-1,0:NP-1]|element
40
+ for (r = 0; r < NR; r++) {
41
+ for (q = 0; q < NQ; q++) {
42
+ for (p = 0; p < NP; p++) {
43
+ sum[r][q][p] = 0;
44
+ for (s = 0; s < NP; s++) {
45
+ sum[r][q][p] = sum[r][q][p] + A[r][q][s] * C4[s][p];
46
+ }
47
+ }
48
+ }
49
+ }
50
+ #pragma species endkernel doitgen_k1
51
+ #pragma species kernel sum[0:NR-1,0:NQ-1,0:NP-1]|element -> A[0:NR-1,0:NQ-1,0:NP-1]|element
52
+ for (r = 0; r < NR; r++) {
53
+ for (q = 0; q < NQ; q++) {
54
+ for (p = 0; p < NP; p++) {
55
+ A[r][q][p] = sum[r][q][p];
56
+ }
57
+ }
58
+ }
59
+ #pragma species endkernel doitgen_k2
60
+ }
61
+ #pragma endscop
62
+
63
+ // Clean-up and exit the function
64
+ fflush(stdout);
65
+ return 0;
66
+ }
67
+
@@ -0,0 +1,80 @@
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
+ #pragma scop
49
+ {
50
+ y[0][0] = r[0];
51
+ beta[0] = 1;
52
+ alpha[0] = r[0];
53
+ for (k = 1; k < NX; k++) {
54
+ beta[k] = beta[k - 1] - alpha[k - 1] * alpha[k - 1] * beta[k - 1];
55
+ sum[0][k] = r[k];
56
+ for (i = 0; i <= k - 1; i++) {
57
+ sum[i + 1][k] = sum[i][k] + r[k - i - 1] * y[i][k - 1];
58
+ }
59
+ alpha[k] = -sum[k][k] * beta[k];
60
+ alpha_k = alpha[k];
61
+ #pragma species kernel y[0:k-1,k-1:k-1]|element ^ y[k-1:0,k-1:k-1]|element -> y[0:k-1,k:k]|element
62
+ for (i = 0; i <= k - 1; i++) {
63
+ y[i][k] = y[i][k - 1] + alpha_k * y[k - i - 1][k - 1];
64
+ }
65
+ #pragma species endkernel durbin_k11
66
+ y[k][k] = alpha[k];
67
+ }
68
+ #pragma species kernel y[0:NX-1,NX-1:NX-1]|element -> out[0:NX-1]|element
69
+ for (i = 0; i < NX; i++) {
70
+ out[i] = y[i][NX - 1];
71
+ }
72
+ #pragma species endkernel durbin_k5
73
+ }
74
+ #pragma endscop
75
+
76
+ // Clean-up and exit the function
77
+ fflush(stdout);
78
+ return 0;
79
+ }
80
+
@@ -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/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
+ #pragma scop
44
+ {
45
+ for (iter = 0; iter < ITER; iter++) {
46
+ #pragma species kernel 0:0|void -> c[0:LENGTH-1,0:LENGTH-1]|element
47
+ for (i = 0; i <= LENGTH - 1; i++) {
48
+ for (j = 0; j <= LENGTH - 1; j++) {
49
+ c[i][j] = 0;
50
+ }
51
+ }
52
+ #pragma species endkernel dynprog_k2
53
+ for (i = 0; i <= LENGTH - 2; i++) {
54
+ for (j = i + 1; j <= LENGTH - 1; j++) {
55
+ sum_c[i][j][i] = 0;
56
+ for (k = i + 1; k <= j - 1; k++) {
57
+ sum_c[i][j][k] = sum_c[i][j][k - 1] + c[i][k] + c[k][j];
58
+ }
59
+ c[i][j] = sum_c[i][j][j - 1] + W[i][j];
60
+ }
61
+ }
62
+ out += c[0][LENGTH - 1];
63
+ }
64
+ }
65
+ #pragma endscop
66
+
67
+ // Clean-up and exit the function
68
+ fflush(stdout);
69
+ return 0;
70
+ }
71
+
@@ -0,0 +1,112 @@
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
+ #pragma scop
76
+ {
77
+ for (iz = 0; iz < CZ; iz++) {
78
+ for (iy = 0; iy < CYM; iy++) {
79
+ czm_iz = czm[iz];
80
+ czp_iz = czp[iz];
81
+ cymh_iy = cymh[iy];
82
+ cyph_iy = cyph[iy];
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
+ clf = Ex[iz][iy][CXM] - Ex[iz][iy + 1][CXM] + Ry[iz][iy] - Ey[iz][iy][CXM];
90
+ tmp = cymh_iy / cyph_iy * Bza[iz][iy][CXM] - ch / cyph_iy * clf;
91
+ 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];
92
+ Bza[iz][iy][CXM] = tmp;
93
+ for (ix = 0; ix < CXM; ix++) {
94
+ clf = Ex[iz][CYM][ix] - Ax[iz][ix] + Ey[iz][CYM][ix + 1] - Ey[iz][CYM][ix];
95
+ tmp = cymh[CYM] / cyph_iy * Bza[iz][iy][ix] - ch / cyph_iy * clf;
96
+ 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];
97
+ Bza[iz][CYM][ix] = tmp;
98
+ }
99
+ clf = Ex[iz][CYM][CXM] - Ax[iz][CXM] + Ry[iz][CYM] - Ey[iz][CYM][CXM];
100
+ tmp = cymh[CYM] / cyph[CYM] * Bza[iz][CYM][CXM] - ch / cyph[CYM] * clf;
101
+ 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];
102
+ Bza[iz][CYM][CXM] = tmp;
103
+ }
104
+ }
105
+ }
106
+ #pragma endscop
107
+
108
+ // Clean-up and exit the function
109
+ fflush(stdout);
110
+ return 0;
111
+ }
112
+
@@ -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/fdtd-2d.c
17
+ // Author.............Cedric Nugteren
18
+ // Last modified on...08-May-2012
19
+ //
20
+
21
+ #include "common.h"
22
+
23
+ // This is 'fdtd-2d', a 2D finite different time domain kernel
24
+ int main(void) {
25
+ int i,j,t;
26
+
27
+ // Declare arrays on the stack
28
+ float ex[NI][NJ];
29
+ float ey[NI][NJ];
30
+ float hz[NI][NJ];
31
+
32
+ // Set the input data
33
+ for (i=0; i<NI; i++) {
34
+ for (j=0; j<NJ; j++) {
35
+ ex[i][j] = ((float) i*(j+1)) / NI;
36
+ ey[i][j] = ((float) i*(j+2)) / NJ;
37
+ hz[i][j] = ((float) i*(j+3)) / NI;
38
+ }
39
+ }
40
+
41
+ // Perform the computation
42
+ #pragma scop
43
+ {
44
+ for (t = 0; t < TSTEPS; t++) {
45
+ #pragma species kernel 0:0|void -> ey[0:0,0:NJ-1]|element
46
+ for (j = 0; j < NJ; j++) {
47
+ ey[0][j] = t;
48
+ }
49
+ #pragma species endkernel fdtd-2d_k2
50
+ #pragma species kernel ey[1:NI-1,0:NJ-1]|element ^ hz[0:NI-1,0:NJ-1]|neighbourhood(-1:0,0:0) -> ey[1:NI-1,0:NJ-1]|element
51
+ for (i = 1; i < NI; i++) {
52
+ for (j = 0; j < NJ; j++) {
53
+ ey[i][j] = ey[i][j] - 0.5 * (hz[i][j] - hz[i - 1][j]);
54
+ }
55
+ }
56
+ #pragma species endkernel fdtd-2d_k3
57
+ #pragma species kernel ex[0:NI-1,1:NJ-1]|element ^ hz[0:NI-1,0:NJ-1]|neighbourhood(0:0,-1:0) -> ex[0:NI-1,1:NJ-1]|element
58
+ for (i = 0; i < NI; i++) {
59
+ for (j = 1; j < NJ; j++) {
60
+ ex[i][j] = ex[i][j] - 0.5 * (hz[i][j] - hz[i][j - 1]);
61
+ }
62
+ }
63
+ #pragma species endkernel fdtd-2d_k4
64
+ #pragma species kernel hz[0:NI-2,0:NJ-2]|element ^ ex[0:NI-2,0:NJ-1]|neighbourhood(0:0,0:1) ^ ey[0:NI-1,0:NJ-2]|neighbourhood(0:1,0:0) -> hz[0:NI-2,0:NJ-2]|element
65
+ for (i = 0; i < NI - 1; i++) {
66
+ for (j = 0; j < NJ - 1; j++) {
67
+ hz[i][j] = hz[i][j] - 0.7 * (ex[i][j + 1] - ex[i][j] + ey[i + 1][j] - ey[i][j]);
68
+ }
69
+ }
70
+ #pragma species endkernel fdtd-2d_k5
71
+ }
72
+ }
73
+ #pragma endscop
74
+
75
+ // Clean-up and exit the function
76
+ fflush(stdout);
77
+ return 0;
78
+ }
@@ -0,0 +1,54 @@
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/floyd-warshall.c
17
+ // Author.............Cedric Nugteren
18
+ // Last modified on...10-April-2012
19
+ //
20
+
21
+ #include "common.h"
22
+
23
+ // This is 'floyd-warshall', a graph analysis algorithm to find shortest paths in a weighted graph
24
+ int main(void) {
25
+ int i,j,k;
26
+
27
+ // Declare arrays on the stack
28
+ float path[N][N];
29
+
30
+ // Set the input data
31
+ for (i=0; i<N; i++) {
32
+ for (j=0; j<N; j++) {
33
+ path[i][j] = ((float) (i+1)*(j+1)) / N;
34
+ }
35
+ }
36
+
37
+ // Perform the computation
38
+ #pragma scop
39
+ {
40
+ for (k = 0; k < N; k++) {
41
+ for (i = 0; i < N; i++) {
42
+ for (j = 0; j < N; j++) {
43
+ path[i][j] = path[i][j] < path[i][k] + path[k][j] ? path[i][j] : path[i][k] + path[k][j];
44
+ }
45
+ }
46
+ }
47
+ }
48
+ #pragma endscop
49
+
50
+ // Clean-up and exit the function
51
+ fflush(stdout);
52
+ return 0;
53
+ }
54
+