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,59 @@
1
+ //
2
+ // This file is part of the Bones source-to-source compiler examples. This C-code
3
+ // example is meant to illustrate the use of Bones. For more information on Bones
4
+ // use the contact information below.
5
+ //
6
+ // == More information on Bones
7
+ // Contact............Cedric Nugteren <c.nugteren@tue.nl>
8
+ // Web address........http://parse.ele.tue.nl/bones/
9
+ //
10
+ // == File information
11
+ // Filename...........chunk/example3.c
12
+ // Author.............Cedric Nugteren
13
+ // Last modified on...16-April-2012
14
+ //
15
+
16
+ #include <stdio.h>
17
+ #define BASE 2048
18
+ #define TILE 64
19
+ #define SIZE (BASE*TILE)
20
+
21
+ // This is 'example3', demonstrating a chunked input and a chunked output, and showing the importance of ordering (array referenced first should be placed first)
22
+ int main(void) {
23
+ int i;
24
+ int t = 0;
25
+ float result = 0;
26
+
27
+ // Declare input/output arrays
28
+ float A[BASE];
29
+ float B[SIZE];
30
+ float out1[SIZE];
31
+ float out2[SIZE];
32
+
33
+ // Set the input data
34
+ for(i=0;i<BASE;i++) {
35
+ A[i] = 0.6;
36
+ }
37
+ for(i=0;i<SIZE;i++) {
38
+ B[i] = i%6+i;
39
+ }
40
+
41
+ // Perform the computation
42
+ #pragma species kernel 0:BASE-1|element ^ 0:SIZE-1|chunk(0:TILE-1) -> 0:SIZE-1|chunk(0:TILE-1) ^ 0:SIZE-1|chunk(0:TILE-1)
43
+ for(i=0;i<BASE;i++) {
44
+ result = A[i];
45
+ for(t=0;t<TILE;t++) {
46
+ result = result + t*B[i*TILE+t];
47
+ }
48
+ for(t=0;t<TILE;t++) {
49
+ out1[i*TILE+t] = result;
50
+ out2[i*TILE+t] = -result;
51
+ }
52
+ }
53
+ #pragma species endkernel example3
54
+
55
+ // Clean-up and exit the function
56
+ fflush(stdout);
57
+ return 0;
58
+ }
59
+
@@ -0,0 +1,55 @@
1
+ //
2
+ // This file is part of the Bones source-to-source compiler examples. This C-code
3
+ // example is meant to illustrate the use of Bones. For more information on Bones
4
+ // use the contact information below.
5
+ //
6
+ // == More information on Bones
7
+ // Contact............Cedric Nugteren <c.nugteren@tue.nl>
8
+ // Web address........http://parse.ele.tue.nl/bones/
9
+ //
10
+ // == File information
11
+ // Filename...........chunk/example4.c
12
+ // Author.............Cedric Nugteren
13
+ // Last modified on...16-April-2012
14
+ //
15
+
16
+ #include <stdio.h>
17
+ #define SIZE 1024
18
+
19
+ // This is 'example4', a basic element to chunk example with an if-statement in the body
20
+ int main(void) {
21
+ int i;
22
+ int threshold = 19;
23
+
24
+ // Declare input/output arrays
25
+ char A[SIZE];
26
+ char B[SIZE*2];
27
+
28
+ // Set the input data
29
+ for(i=0;i<SIZE;i++) {
30
+ A[i] = i%100;
31
+ }
32
+
33
+ // Set the output data to zero
34
+ for(i=0;i<SIZE*2;i++) {
35
+ B[i] = 0;
36
+ }
37
+
38
+ // Perform the computation
39
+ #pragma species kernel 0:SIZE-1|element -> 0:SIZE*2-1|chunk(0:1)
40
+ for(i=0;i<SIZE;i++) {
41
+ B[i*2] = A[i];
42
+ if (A[i] > threshold) {
43
+ B[i*2+1] = A[i];
44
+ }
45
+ else {
46
+ B[i*2+1] = 0;
47
+ }
48
+ }
49
+ #pragma species endkernel example4
50
+
51
+ // Clean-up and exit the function
52
+ fflush(stdout);
53
+ return 0;
54
+ }
55
+
@@ -0,0 +1,52 @@
1
+ //
2
+ // This file is part of the Bones source-to-source compiler examples. This C-code
3
+ // example is meant to illustrate the use of Bones. For more information on Bones
4
+ // use the contact information below.
5
+ //
6
+ // == More information on Bones
7
+ // Contact............Cedric Nugteren <c.nugteren@tue.nl>
8
+ // Web address........http://parse.ele.tue.nl/bones/
9
+ //
10
+ // == File information
11
+ // Filename...........chunk/example5.c
12
+ // Author.............Cedric Nugteren
13
+ // Last modified on...16-April-2012
14
+ //
15
+
16
+ #include <stdio.h>
17
+
18
+ // This is 'example5', demonstrating a chunk to element example without a temporary variable but directly writing to the output
19
+ int main(void) {
20
+ int i,j;
21
+ int i2,j2;
22
+
23
+ // Declare input/output arrays
24
+ int A[560][32];
25
+ int B[56][16];
26
+
27
+ // Set the input data
28
+ for(i=0;i<560;i++) {
29
+ for(j=0;j<32;j++) {
30
+ A[i][j] = i+j;
31
+ }
32
+ }
33
+
34
+ // Perform the computation
35
+ #pragma species kernel 0:559,0:31|chunk(0:9,0:1) -> 0:55,0:15|element
36
+ for(i=0;i<56;i++) {
37
+ for(j=0;j<16;j++) {
38
+ B[i][j] = 0;
39
+ for (i2=0;i2<10;i2++) {
40
+ for (j2=0;j2<2;j2++) {
41
+ B[i][j] = B[i][j] + A[i*10+i2][j*2+j2];
42
+ }
43
+ }
44
+ }
45
+ }
46
+ #pragma species endkernel example5
47
+
48
+ // Clean-up and exit the function
49
+ fflush(stdout);
50
+ return 0;
51
+ }
52
+
@@ -0,0 +1,46 @@
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...........element/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 very basic element to element example using 2D arrays.
19
+ int main(void) {
20
+ int i,j;
21
+
22
+ // Declare input/output arrays
23
+ int A[100][16];
24
+ int B[100][16];
25
+
26
+ // Set the input data
27
+ for(i=0;i<100;i++) {
28
+ for(j=0;j<16;j++) {
29
+ A[i][j] = i+j;
30
+ }
31
+ }
32
+
33
+ // Perform the computation
34
+ #pragma species kernel 0:99,0:15|element -> 0:99,0:15|element
35
+ for(i=0;i<100;i++) {
36
+ for(j=0;j<16;j++) {
37
+ B[i][j] = 2*A[i][j];
38
+ }
39
+ }
40
+ #pragma species endkernel example1
41
+
42
+ // Clean-up and exit the function
43
+ fflush(stdout);
44
+ return 0;
45
+ }
46
+
@@ -0,0 +1,50 @@
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...........element/example10.c
12
+ // Author.............Cedric Nugteren
13
+ // Last modified on...16-April-2012
14
+ //
15
+
16
+ #include <stdio.h>
17
+ #include <stdlib.h>
18
+
19
+ // This is 'example10', demonstrating multiple loops not starting at 0 for a 2D array and a kernel without a given name
20
+ int main(void) {
21
+ int i,j;
22
+ int N = 4;
23
+ int M = 5;
24
+
25
+ // Declare input/output arrays
26
+ int A[N][M];
27
+ int B[N][M];
28
+
29
+ // Set the input data
30
+ for(i=0;i<N;i++) {
31
+ for(j=0;j<M;j++) {
32
+ A[i][j] = i*M+j;
33
+ B[i][j] = 9;
34
+ }
35
+ }
36
+
37
+ // Perform the computation
38
+ #pragma species kernel 2:N-1,1:M-1|element -> 2:N-1,1:M-1|element
39
+ for(i=2;i<N;i++) {
40
+ for(j=1;j<M;j++) {
41
+ B[i][j] = A[i][j];
42
+ }
43
+ }
44
+ #pragma species endkernel
45
+
46
+ // Clean-up and exit the function
47
+ fflush(stdout);
48
+ return 0;
49
+ }
50
+
@@ -0,0 +1,47 @@
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...........element/example11.c
12
+ // Author.............Cedric Nugteren
13
+ // Last modified on...16-April-2012
14
+ //
15
+
16
+ #include <stdio.h>
17
+
18
+ // This is 'example11', demonstrating an inner-loop which is dependent on an outer-loop variable and a classification of the inner-loop only
19
+ int main(void) {
20
+ int i,j;
21
+
22
+ // Declare input/output arrays
23
+ int A[128][128];
24
+ int B[128][128];
25
+
26
+ // Set the input data
27
+ for(i=0;i<128;i++) {
28
+ for(j=0;j<128;j++) {
29
+ A[i][j] = i+j;
30
+ B[i][j] = 999;
31
+ }
32
+ }
33
+
34
+ // Perform the computation
35
+ for(i=0;i<128;i++) {
36
+ #pragma species kernel i:i,i:127|element -> i:i,i:127|element
37
+ for(j=i;j<128;j++) {
38
+ B[i][j] = 2*A[i][j];
39
+ }
40
+ #pragma species endkernel example11
41
+ }
42
+
43
+ // Clean-up and exit the function
44
+ fflush(stdout);
45
+ return 0;
46
+ }
47
+
@@ -0,0 +1,56 @@
1
+ //
2
+ // This file is part of the Bones source-to-source compiler examples. This C-code
3
+ // example is meant to illustrate the use of Bones. For more information on Bones
4
+ // use the contact information below.
5
+ //
6
+ // == More information on Bones
7
+ // Contact............Cedric Nugteren <c.nugteren@tue.nl>
8
+ // Web address........http://parse.ele.tue.nl/bones/
9
+ //
10
+ // == File information
11
+ // Filename...........element/example12.c
12
+ // Author.............Cedric Nugteren
13
+ // Last modified on...06-Aug-2012
14
+ //
15
+
16
+ #include <stdio.h>
17
+ #include <stdlib.h>
18
+
19
+ void computation(int* A, int* B, int constant);
20
+
21
+ // This is 'example12', demonstrating a classification in another function
22
+ int main(void) {
23
+ int i;
24
+
25
+ // Declare input/output arrays
26
+ int* A = (int*)malloc(128*sizeof(int));
27
+ int* B = (int*)malloc(128*sizeof(int));
28
+
29
+ // Set the input data
30
+ for(i=0;i<128;i++) {
31
+ A[i] = i+3;
32
+ B[i] = 999;
33
+ }
34
+ int constant = 3;
35
+
36
+ // Call the computation function
37
+ computation(A,B,constant);
38
+
39
+ // Clean-up and exit the function
40
+ free(A);
41
+ free(B);
42
+ fflush(stdout);
43
+ return 0;
44
+ }
45
+
46
+ // Function implementing the computation for 'example12'
47
+ void computation(int* A, int* B, int constant) {
48
+ int i;
49
+
50
+ // Perform the computation
51
+ #pragma species kernel 0:127|element -> 0:127|element
52
+ for(i=0;i<128;i++) {
53
+ B[i] = 2*A[i] + constant;
54
+ }
55
+ #pragma species endkernel example12
56
+ }
@@ -0,0 +1,46 @@
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...........element/example2.c
12
+ // Author.............Cedric Nugteren
13
+ // Last modified on...16-April-2012
14
+ //
15
+
16
+ #include <stdio.h>
17
+
18
+ // This is 'example2', demonstrating unordered element-wise computation
19
+ int main(void) {
20
+ int i,j;
21
+
22
+ // Declare input/output arrays
23
+ int A[4][8];
24
+ int B[4][8];
25
+
26
+ // Set the input data
27
+ for(i=0;i<4;i++) {
28
+ for(j=0;j<8;j++) {
29
+ A[i][j] = i+j;
30
+ }
31
+ }
32
+
33
+ // Perform the computation
34
+ #pragma species kernel unordered 0:3,0:7|element -> 0:3,0:7|element
35
+ for(i=0;i<4;i++) {
36
+ for(j=0;j<8;j++) {
37
+ B[i][j] = A[i][7-j];
38
+ }
39
+ }
40
+ #pragma species endkernel example2
41
+
42
+ // Clean-up and exit the function
43
+ fflush(stdout);
44
+ return 0;
45
+ }
46
+
@@ -0,0 +1,58 @@
1
+ //
2
+ // This file is part of the Bones source-to-source compiler examples. This C-code
3
+ // example is meant to illustrate the use of Bones. For more information on Bones
4
+ // use the contact information below.
5
+ //
6
+ // == More information on Bones
7
+ // Contact............Cedric Nugteren <c.nugteren@tue.nl>
8
+ // Web address........http://parse.ele.tue.nl/bones/
9
+ //
10
+ // == File information
11
+ // Filename...........element/example3.c
12
+ // Author.............Cedric Nugteren
13
+ // Last modified on...16-April-2012
14
+ //
15
+
16
+ #include <stdio.h>
17
+ #define N1 2//8
18
+ #define N2 4//16
19
+ #define N3 8//32
20
+ #define N4 16//64
21
+
22
+ // This is 'example3', demonstrating a 4D array and defines for array sizes
23
+ int main(void) {
24
+ int i,j,k,l;
25
+
26
+ // Declare input/output arrays
27
+ int A[N1][N2][N3][N4];
28
+ int B[N1][N2][N3][N4];
29
+
30
+ // Set the input data
31
+ for(i=0;i<N1;i++) {
32
+ for(j=0;j<N2;j++) {
33
+ for(k=0;k<N3;k++) {
34
+ for(l=0;l<N4;l++) {
35
+ A[i][j][k][l] = i*j+k-l;
36
+ }
37
+ }
38
+ }
39
+ }
40
+
41
+ // Perform the computation
42
+ #pragma species kernel 0:N1-1,0:N2-1,0:N3-1,0:N4-1|element -> 0:N1-1,0:N2-1,0:N3-1,0:N4-1|element
43
+ for(i=0;i<N1;i++) {
44
+ for(j=0;j<N2;j++) {
45
+ for(k=0;k<N3;k++) {
46
+ for(l=0;l<N4;l++) {
47
+ B[i][j][k][l] = 3*A[i][j][k][l]+6;
48
+ }
49
+ }
50
+ }
51
+ }
52
+ #pragma species endkernel example3
53
+
54
+ // Clean-up and exit the function
55
+ fflush(stdout);
56
+ return 0;
57
+ }
58
+