bones-compiler 1.1.0

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 (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,51 @@
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/seidel-2d.c
17
+ // Author.............Cedric Nugteren
18
+ // Last modified on...05-April-2012
19
+ //
20
+
21
+ #include "common.h"
22
+
23
+ // This is 'seidel-2d', a 2D Seidel stencil computation
24
+ int main(void) {
25
+ int i,j,t;
26
+
27
+ // Declare arrays on the stack
28
+ float A[N][N];
29
+
30
+ // Set the input data
31
+ for (i=0; i<N; i++) {
32
+ for (j=0; j<N; j++) {
33
+ A[i][j] = ((float) i*i*(j+2) + 2) / N;
34
+ }
35
+ }
36
+
37
+ // Perform the computation
38
+ for (t=0; t<TSTEPS-1; t++) {
39
+ for (i=1; i<=N-2; i++) {
40
+ for (j=1; j<=N-2; j++) {
41
+ A[i][j] = (A[i-1][j-1] + A[i-1][ j ] + A[i-1][j+1]
42
+ + A[ i ][j-1] + A[ i ][ j ] + A[ i ][j+1]
43
+ + A[i+1][j-1] + A[i+1][ j ] + A[i+1][j+1])/9.0;
44
+ }
45
+ }
46
+ }
47
+
48
+ // Clean-up and exit the function
49
+ fflush(stdout);
50
+ return 0;
51
+ }
@@ -0,0 +1,74 @@
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/symm.c
17
+ // Author.............Cedric Nugteren
18
+ // Last modified on...23-May-2012
19
+ //
20
+
21
+ #include "common.h"
22
+
23
+ // This is 'symm', a symmetric matrix multiplication kernel
24
+ int main(void) {
25
+ int i,j,k;
26
+ float acc[1];
27
+ float bij;
28
+
29
+ // Declare arrays on the stack
30
+ float A[NJ][NJ];
31
+ float B[NI][NJ];
32
+ float C[NI][NJ];
33
+
34
+ // Set the constants
35
+ float alpha = 32412;
36
+ float beta = 2123;
37
+
38
+ // Set the input data
39
+ for (i=0; i<NI; i++) {
40
+ for (j=0; j<NJ; j++) {
41
+ C[i][j] = ((float) i*j) / NI;
42
+ B[i][j] = ((float) i*j) / NI;
43
+ }
44
+ }
45
+ for (i=0; i<NJ; i++) {
46
+ for (j=0; j<NJ; j++) {
47
+ A[i][j] = ((float) i*j) / NI;
48
+ }
49
+ }
50
+
51
+ // Perform the computation (C := alpha*A*B + beta*C, with A symmetric)
52
+ for (i=0; i<NI; i++) {
53
+ for (j=0; j<NJ; j++) {
54
+ acc[0] = 0;
55
+ bij = B[i][j];
56
+ #pragma species kernel 0:j-2,j:j|element ^ 0:j-2,i:i|element -> 0:j-2,j:j|element
57
+ for (k=0; k<j-1; k++) {
58
+ C[k][j] += alpha*A[k][i] * bij;
59
+ }
60
+ #pragma species endkernel symm-part1
61
+ #pragma species kernel 0:j-2,j:j|element ^ 0:j-2,i:i|element -> 0:0|shared
62
+ for (k=0; k<j-1; k++) {
63
+ acc[0] += B[k][j] * A[k][i];
64
+ }
65
+ #pragma species endkernel symm-part2
66
+ C[i][j] = beta*C[i][j] + alpha*A[i][i]*bij + alpha*acc[0];
67
+ }
68
+ }
69
+
70
+ // Clean-up and exit the function
71
+ fflush(stdout);
72
+ return 0;
73
+ }
74
+
@@ -0,0 +1,65 @@
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/syr2k.c
17
+ // Author.............Cedric Nugteren
18
+ // Last modified on...03-April-2012
19
+ //
20
+
21
+ #include "common.h"
22
+
23
+ // This is 'syr2k', an algorithm for symmetric rank-2k operations
24
+ int main(void) {
25
+ int i,j,k;
26
+
27
+ // Declare arrays on the stack
28
+ float A[NI][NJ];
29
+ float B[NI][NJ];
30
+ float C[NI][NI];
31
+
32
+ // Set the constants
33
+ int alpha = 32412;
34
+ int beta = 2123;
35
+
36
+ // Set the input data
37
+ for (i=0; i<NI; i++) {
38
+ for (j=0; j<NJ; j++) {
39
+ A[i][j] = ((float) i*j) / NI;
40
+ B[i][j] = ((float) i*j) / NI;
41
+ }
42
+ }
43
+ for (i=0; i<NI; i++) {
44
+ for (j=0; j<NI; j++) {
45
+ C[i][j] = ((float) i*j) / NI;
46
+ }
47
+ }
48
+
49
+ // Perform the computation (C := alpha*A*B' + alpha*B*A' + beta*C)
50
+ #pragma species kernel 0:NI-1,0:NI-1|element ^ 0:NI-1,0:NJ-1|chunk(0:0,0:NJ-1) ^ 0:NI-1,0:NJ-1|chunk(0:0,0:NJ-1) -> 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] * B[j][k];
56
+ C[i][j] += alpha * B[i][k] * A[j][k];
57
+ }
58
+ }
59
+ }
60
+ #pragma species endkernel syr2k
61
+
62
+ // Clean-up and exit the function
63
+ fflush(stdout);
64
+ return 0;
65
+ }
@@ -0,0 +1,62 @@
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...08-May-2012
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 species kernel C[0:NI-1,0:NI-1]|element ^ A[0:NI-1,0:NJ-1]|chunk(0:0,0:NJ-1) ^ A[0:NI-1,0:NJ-1]|chunk(0:0,0:NJ-1) -> C[0:NI-1,0:NI-1]|element
49
+ for (i=0; i<NI; i++) {
50
+ for (j=0; j<NI; j++) {
51
+ C[i][j] *= beta;
52
+ for (k=0; k<NJ; k++) {
53
+ C[i][j] += alpha * A[i][k] * A[j][k];
54
+ }
55
+ }
56
+ }
57
+ #pragma species endkernel syrk
58
+
59
+ // Clean-up and exit the function
60
+ fflush(stdout);
61
+ return 0;
62
+ }
@@ -0,0 +1,57 @@
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
+ for (i=0; i<NX; i++) {
44
+ x[i] = c[i];
45
+ A_i_i = A[i][i];
46
+ //#pragma species kernel i:i,0:i-1|element -> i:i|shared
47
+ for (j=0; j<= i-1; j++) {
48
+ x[i] = x[i] - A[i][j] * x[j];
49
+ x[i] = x[i] / A_i_i;
50
+ }
51
+ //#pragma species endkernel trisolv
52
+ }
53
+
54
+ // Clean-up and exit the function
55
+ fflush(stdout);
56
+ return 0;
57
+ }
@@ -0,0 +1,57 @@
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
+ for (i=1; i<NI; i++) {
44
+ for (j=0; j<NI; j++) {
45
+ #pragma species kernel i:i,0:i-1|element ^ j:j,0:i-1|element -> i:i,j:j|shared
46
+ for (k=0; k<i; k++) {
47
+ B[i][j] += alpha * A[i][k] * B[j][k];
48
+ }
49
+ #pragma species endkernel trmm
50
+ }
51
+ }
52
+
53
+ // Clean-up and exit the function
54
+ fflush(stdout);
55
+ return 0;
56
+ }
57
+
@@ -0,0 +1,54 @@
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 species kernel 0:559,0:31|chunk(0:9,0:1) -> 0:55,0:15|element
37
+ for(i=0;i<56;i++) {
38
+ for(j=0;j<16;j++) {
39
+ result = 0;
40
+ for (i2=0;i2<10;i2++) {
41
+ for (j2=0;j2<2;j2++) {
42
+ result = result + A[i*10+i2][j*2+j2];
43
+ }
44
+ }
45
+ B[i][j] = result;
46
+ }
47
+ }
48
+ #pragma species endkernel example1
49
+
50
+ // Clean-up and exit the function
51
+ fflush(stdout);
52
+ return 0;
53
+ }
54
+
@@ -0,0 +1,44 @@
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 species kernel 0:SIZE-1|chunk(0:1) -> 0:HALFSIZE-1|element
35
+ for(i=0;i<HALFSIZE;i++) {
36
+ B[i] = A[i*2] + A[i*2+1];
37
+ }
38
+ #pragma species endkernel example2
39
+
40
+ // Clean-up and exit the function
41
+ fflush(stdout);
42
+ return 0;
43
+ }
44
+