bones-compiler 1.3.1 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (307) hide show
  1. data/CHANGELOG +62 -0
  2. data/README.rdoc +14 -3
  3. data/Rakefile +13 -12
  4. data/VERSION +1 -1
  5. data/examples/applications/ffos.c +24 -8
  6. data/examples/benchmarks/PolyBench/2mm.c +0 -0
  7. data/examples/benchmarks/PolyBench/3mm.c +0 -0
  8. data/examples/benchmarks/PolyBench/adi.c +0 -0
  9. data/examples/benchmarks/PolyBench/atax.c +0 -0
  10. data/examples/benchmarks/PolyBench/bicg.c +0 -0
  11. data/examples/benchmarks/PolyBench/cholesky.c +0 -0
  12. data/examples/benchmarks/PolyBench/common.h +0 -0
  13. data/examples/benchmarks/PolyBench/correlation.c +0 -0
  14. data/examples/benchmarks/PolyBench/covariance.c +0 -0
  15. data/examples/benchmarks/PolyBench/doitgen.c +0 -0
  16. data/examples/benchmarks/PolyBench/durbin.c +0 -0
  17. data/examples/benchmarks/PolyBench/dynprog.c +0 -0
  18. data/examples/benchmarks/PolyBench/fdtd-2d-apml.c +0 -0
  19. data/examples/benchmarks/PolyBench/fdtd-2d.c +0 -0
  20. data/examples/benchmarks/PolyBench/floyd-warshall.c +0 -0
  21. data/examples/benchmarks/PolyBench/gemm.c +0 -0
  22. data/examples/benchmarks/PolyBench/gemver.c +0 -0
  23. data/examples/benchmarks/PolyBench/gesummv.c +0 -0
  24. data/examples/benchmarks/PolyBench/gramschmidt.c +0 -0
  25. data/examples/benchmarks/PolyBench/jacobi-1d-imper.c +4 -2
  26. data/examples/benchmarks/PolyBench/jacobi-2d-imper.c +1 -1
  27. data/examples/benchmarks/PolyBench/lu.c +0 -0
  28. data/examples/benchmarks/PolyBench/ludcmp.c +0 -0
  29. data/examples/benchmarks/PolyBench/mvt.c +0 -0
  30. data/examples/benchmarks/PolyBench/reg_detect.c +0 -0
  31. data/examples/benchmarks/PolyBench/seidel-2d.c +0 -0
  32. data/examples/benchmarks/PolyBench/symm.c +0 -0
  33. data/examples/benchmarks/PolyBench/syr2k.c +0 -0
  34. data/examples/benchmarks/PolyBench/syrk.c +0 -0
  35. data/examples/benchmarks/PolyBench/trisolv.c +0 -0
  36. data/examples/benchmarks/PolyBench/trmm.c +0 -0
  37. data/examples/benchmarks/Rodinia/bfs.c +143 -0
  38. data/examples/benchmarks/Rodinia/common.h +78 -0
  39. data/examples/benchmarks/Rodinia/hotspot.c +106 -126
  40. data/examples/benchmarks/Rodinia/kmeans.c +157 -164
  41. data/examples/benchmarks/Rodinia/nw.c +151 -0
  42. data/examples/benchmarks/Rodinia/pathfinder.c +88 -0
  43. data/examples/benchmarks/Rodinia/srad.c +50 -59
  44. data/examples/benchmarks/other/common.h +0 -0
  45. data/examples/benchmarks/other/dct.c +0 -0
  46. data/examples/benchmarks/other/mm.c +0 -0
  47. data/examples/benchmarks/other/saxpy.c +0 -0
  48. data/examples/chunk/example01.c +6 -4
  49. data/examples/chunk/example02.c +6 -4
  50. data/examples/chunk/example03.c +6 -4
  51. data/examples/chunk/example04.c +8 -5
  52. data/examples/chunk/example05.c +6 -4
  53. data/examples/chunk/example06.c +3 -1
  54. data/examples/chunk/example07.c +5 -2
  55. data/examples/dependences/example01.c +3 -1
  56. data/examples/dependences/example02.c +3 -1
  57. data/examples/dependences/example03.c +3 -1
  58. data/examples/dependences/example04.c +3 -1
  59. data/examples/dependences/example05.c +3 -1
  60. data/examples/element/example01.c +6 -4
  61. data/examples/element/example02.c +6 -4
  62. data/examples/element/example03.c +10 -8
  63. data/examples/element/example04.c +6 -4
  64. data/examples/element/example05.c +8 -5
  65. data/examples/element/example06.c +6 -4
  66. data/examples/element/example07.c +6 -4
  67. data/examples/element/example08.c +6 -4
  68. data/examples/element/example09.c +6 -4
  69. data/examples/element/example10.c +4 -2
  70. data/examples/element/example11.c +4 -2
  71. data/examples/element/example12.c +4 -2
  72. data/examples/element/example13.c +3 -1
  73. data/examples/fusion/example01.c +3 -12
  74. data/examples/fusion/example02.c +3 -16
  75. data/examples/fusion/example03.c +3 -1
  76. data/examples/fusion/example04.c +5 -3
  77. data/examples/fusion/example05.c +3 -1
  78. data/examples/neighbourhood/example01.c +6 -4
  79. data/examples/neighbourhood/example02.c +6 -4
  80. data/examples/neighbourhood/example03.c +6 -4
  81. data/examples/neighbourhood/example04.c +5 -3
  82. data/examples/neighbourhood/example05.c +3 -1
  83. data/examples/shared/example01.c +6 -4
  84. data/examples/shared/example02.c +6 -4
  85. data/examples/shared/example03.c +6 -4
  86. data/examples/shared/example04.c +6 -4
  87. data/examples/shared/example05.c +6 -4
  88. data/lib/adarwin/engine.rb +16 -5
  89. data/lib/adarwin/memorycopies.rb +21 -9
  90. data/lib/adarwin/nest.rb +18 -1
  91. data/lib/adarwin/preprocessor.rb +5 -2
  92. data/lib/adarwin/reference.rb +71 -6
  93. data/lib/bones/algorithm.rb +20 -5
  94. data/lib/bones/copy.rb +3 -2
  95. data/lib/bones/engine.rb +12 -9
  96. data/lib/bones/preprocessor.rb +170 -120
  97. data/lib/bones/variablelist.rb +1 -1
  98. data/lib/cast.rb +11 -0
  99. data/lib/castaddon.rb +23 -6
  100. data/lib/castaddon/node_adarwin.rb +17 -0
  101. data/lib/castaddon/node_common.rb +6 -0
  102. data/lib/castaddon/transformations.rb +13 -9
  103. data/skeletons/CPU-C/common/epilogue.c +0 -0
  104. data/skeletons/CPU-C/common/globals.c +0 -0
  105. data/skeletons/CPU-C/common/globals_kernel.c +0 -0
  106. data/skeletons/CPU-C/common/header.c +0 -0
  107. data/skeletons/CPU-C/common/mem_copy_D2H.c +0 -0
  108. data/skeletons/CPU-C/common/mem_copy_H2D.c +0 -0
  109. data/skeletons/CPU-C/common/mem_epilogue.c +0 -0
  110. data/skeletons/CPU-C/common/mem_global.c +0 -0
  111. data/skeletons/CPU-C/common/mem_prologue.c +0 -0
  112. data/skeletons/CPU-C/common/prologue.c +0 -0
  113. data/skeletons/CPU-C/common/timer_1_start.c +0 -0
  114. data/skeletons/CPU-C/common/timer_1_stop.c +0 -0
  115. data/skeletons/CPU-C/common/timer_2_start.c +0 -0
  116. data/skeletons/CPU-C/common/timer_2_stop.c +0 -0
  117. data/skeletons/CPU-C/common/timer_globals.c +5 -0
  118. data/skeletons/CPU-C/kernel/default.host.c +0 -0
  119. data/skeletons/CPU-C/kernel/default.kernel.c +0 -0
  120. data/skeletons/CPU-C/skeletons.txt +0 -0
  121. data/skeletons/CPU-OPENCL-AMD/common/epilogue.c +0 -0
  122. data/skeletons/CPU-OPENCL-AMD/common/globals.c +0 -0
  123. data/skeletons/CPU-OPENCL-AMD/common/globals_kernel.c +0 -0
  124. data/skeletons/CPU-OPENCL-AMD/common/header.c +0 -0
  125. data/skeletons/CPU-OPENCL-AMD/common/mem_copy_D2H.c +0 -0
  126. data/skeletons/CPU-OPENCL-AMD/common/mem_copy_H2D.c +0 -0
  127. data/skeletons/CPU-OPENCL-AMD/common/mem_epilogue.c +0 -0
  128. data/skeletons/CPU-OPENCL-AMD/common/mem_prologue.c +0 -0
  129. data/skeletons/CPU-OPENCL-AMD/common/prologue.c +0 -0
  130. data/skeletons/CPU-OPENCL-AMD/common/timer_1_start.c +0 -0
  131. data/skeletons/CPU-OPENCL-AMD/common/timer_1_stop.c +0 -0
  132. data/skeletons/CPU-OPENCL-AMD/common/timer_2_start.c +0 -0
  133. data/skeletons/CPU-OPENCL-AMD/common/timer_2_stop.c +0 -0
  134. data/skeletons/CPU-OPENCL-AMD/kernel/D-element-to-1-shared.host.c +0 -0
  135. data/skeletons/CPU-OPENCL-AMD/kernel/D-element-to-1-shared.kernel.cl +0 -0
  136. data/skeletons/CPU-OPENCL-AMD/kernel/default.host.c +0 -0
  137. data/skeletons/CPU-OPENCL-AMD/kernel/default.kernel.cl +0 -0
  138. data/skeletons/CPU-OPENCL-AMD/skeletons.txt +0 -0
  139. data/skeletons/CPU-OPENCL-INTEL/common/epilogue.c +0 -0
  140. data/skeletons/CPU-OPENCL-INTEL/common/globals.c +0 -0
  141. data/skeletons/CPU-OPENCL-INTEL/common/globals_kernel.c +0 -0
  142. data/skeletons/CPU-OPENCL-INTEL/common/header.c +0 -0
  143. data/skeletons/CPU-OPENCL-INTEL/common/mem_copy_D2H.c +0 -0
  144. data/skeletons/CPU-OPENCL-INTEL/common/mem_copy_H2D.c +0 -0
  145. data/skeletons/CPU-OPENCL-INTEL/common/mem_epilogue.c +0 -0
  146. data/skeletons/CPU-OPENCL-INTEL/common/mem_global.c +0 -0
  147. data/skeletons/CPU-OPENCL-INTEL/common/mem_prologue.c +0 -0
  148. data/skeletons/CPU-OPENCL-INTEL/common/prologue.c +0 -0
  149. data/skeletons/CPU-OPENCL-INTEL/common/timer_1_start.c +0 -0
  150. data/skeletons/CPU-OPENCL-INTEL/common/timer_1_stop.c +0 -0
  151. data/skeletons/CPU-OPENCL-INTEL/common/timer_2_start.c +0 -0
  152. data/skeletons/CPU-OPENCL-INTEL/common/timer_2_stop.c +0 -0
  153. data/skeletons/CPU-OPENCL-INTEL/common/timer_globals.c +5 -0
  154. data/skeletons/CPU-OPENCL-INTEL/kernel/D-element-to-1-shared.host.c +0 -0
  155. data/skeletons/CPU-OPENCL-INTEL/kernel/D-element-to-1-shared.kernel.cl +0 -0
  156. data/skeletons/CPU-OPENCL-INTEL/kernel/default.host.c +0 -0
  157. data/skeletons/CPU-OPENCL-INTEL/kernel/default.kernel.cl +0 -0
  158. data/skeletons/CPU-OPENCL-INTEL/skeletons.txt +0 -0
  159. data/skeletons/CPU-OPENMP/common/epilogue.c +0 -0
  160. data/skeletons/CPU-OPENMP/common/globals.c +0 -0
  161. data/skeletons/CPU-OPENMP/common/globals_kernel.c +0 -0
  162. data/skeletons/CPU-OPENMP/common/header.c +0 -0
  163. data/skeletons/CPU-OPENMP/common/mem_copy_D2H.c +0 -0
  164. data/skeletons/CPU-OPENMP/common/mem_copy_H2D.c +0 -0
  165. data/skeletons/CPU-OPENMP/common/mem_epilogue.c +0 -0
  166. data/skeletons/CPU-OPENMP/common/mem_global.c +0 -0
  167. data/skeletons/CPU-OPENMP/common/mem_prologue.c +0 -0
  168. data/skeletons/CPU-OPENMP/common/prologue.c +0 -0
  169. data/skeletons/CPU-OPENMP/common/timer_1_start.c +0 -0
  170. data/skeletons/CPU-OPENMP/common/timer_1_stop.c +0 -0
  171. data/skeletons/CPU-OPENMP/common/timer_2_start.c +0 -0
  172. data/skeletons/CPU-OPENMP/common/timer_2_stop.c +0 -0
  173. data/skeletons/CPU-OPENMP/common/timer_globals.c +2 -0
  174. data/skeletons/CPU-OPENMP/kernel/D-element-to-1-shared.host.c +0 -0
  175. data/skeletons/CPU-OPENMP/kernel/D-element-to-1-shared.kernel.c +3 -3
  176. data/skeletons/CPU-OPENMP/kernel/default.host.c +0 -0
  177. data/skeletons/CPU-OPENMP/kernel/default.kernel.c +0 -0
  178. data/skeletons/CPU-OPENMP/skeletons.txt +0 -0
  179. data/skeletons/GPU-CUDA/common/epilogue.c +0 -0
  180. data/skeletons/GPU-CUDA/common/globals.c +0 -0
  181. data/skeletons/GPU-CUDA/common/globals_kernel.c +0 -0
  182. data/skeletons/GPU-CUDA/common/header.c +0 -0
  183. data/skeletons/GPU-CUDA/common/mem_async_alloc.c +0 -0
  184. data/skeletons/GPU-CUDA/common/mem_async_copyin.c +0 -0
  185. data/skeletons/GPU-CUDA/common/mem_async_copyout.c +0 -0
  186. data/skeletons/GPU-CUDA/common/mem_async_free.c +0 -0
  187. data/skeletons/GPU-CUDA/common/mem_copy_D2H.c +0 -0
  188. data/skeletons/GPU-CUDA/common/mem_copy_H2D.c +0 -0
  189. data/skeletons/GPU-CUDA/common/mem_epilogue.c +0 -0
  190. data/skeletons/GPU-CUDA/common/mem_global.c +0 -0
  191. data/skeletons/GPU-CUDA/common/mem_prologue.c +0 -0
  192. data/skeletons/GPU-CUDA/common/prologue.c +0 -0
  193. data/skeletons/GPU-CUDA/common/scheduler.c +2 -2
  194. data/skeletons/GPU-CUDA/common/timer_1_start.c +0 -0
  195. data/skeletons/GPU-CUDA/common/timer_1_stop.c +0 -0
  196. data/skeletons/GPU-CUDA/common/timer_2_start.c +0 -0
  197. data/skeletons/GPU-CUDA/common/timer_2_stop.c +0 -0
  198. data/skeletons/GPU-CUDA/common/timer_globals.c +0 -0
  199. data/skeletons/GPU-CUDA/kernel/2xN-N-chunk-1-N-to-D-element.host.c +0 -0
  200. data/skeletons/GPU-CUDA/kernel/2xN-N-chunk-1-N-to-D-element.kernel.cu +0 -0
  201. data/skeletons/GPU-CUDA/kernel/D-element-to-1-shared.host.c +0 -0
  202. data/skeletons/GPU-CUDA/kernel/D-element-to-1-shared.kernel.cu +0 -0
  203. data/skeletons/GPU-CUDA/kernel/D-element-to-N-shared.host.c +0 -0
  204. data/skeletons/GPU-CUDA/kernel/D-element-to-N-shared.kernel.cu +0 -0
  205. data/skeletons/GPU-CUDA/kernel/N-N-chunk-1-N-to-D-element.host.c +0 -0
  206. data/skeletons/GPU-CUDA/kernel/N-N-chunk-1-N-to-D-element.kernel.cu +0 -0
  207. data/skeletons/GPU-CUDA/kernel/N-neighbourhood-N-to-N-element.host.c +0 -0
  208. data/skeletons/GPU-CUDA/kernel/N-neighbourhood-N-to-N-element.kernel.cu +0 -0
  209. data/skeletons/GPU-CUDA/kernel/default.host.c +0 -0
  210. data/skeletons/GPU-CUDA/kernel/default.kernel.cu +0 -0
  211. data/skeletons/GPU-CUDA/skeletons.txt +4 -2
  212. data/skeletons/GPU-OPENCL-AMD/common/epilogue.c +0 -0
  213. data/skeletons/GPU-OPENCL-AMD/common/globals.c +0 -0
  214. data/skeletons/GPU-OPENCL-AMD/common/globals_kernel.c +0 -0
  215. data/skeletons/GPU-OPENCL-AMD/common/header.c +0 -0
  216. data/skeletons/GPU-OPENCL-AMD/common/mem_copy_D2H.c +0 -0
  217. data/skeletons/GPU-OPENCL-AMD/common/mem_copy_H2D.c +0 -0
  218. data/skeletons/GPU-OPENCL-AMD/common/mem_epilogue.c +0 -0
  219. data/skeletons/GPU-OPENCL-AMD/common/mem_prologue.c +0 -0
  220. data/skeletons/GPU-OPENCL-AMD/common/prologue.c +0 -0
  221. data/skeletons/GPU-OPENCL-AMD/common/timer_1_start.c +0 -0
  222. data/skeletons/GPU-OPENCL-AMD/common/timer_1_stop.c +0 -0
  223. data/skeletons/GPU-OPENCL-AMD/common/timer_2_start.c +0 -0
  224. data/skeletons/GPU-OPENCL-AMD/common/timer_2_stop.c +0 -0
  225. data/skeletons/GPU-OPENCL-AMD/kernel/D-element-to-1-shared.host.c +0 -0
  226. data/skeletons/GPU-OPENCL-AMD/kernel/D-element-to-1-shared.kernel.cl +0 -0
  227. data/skeletons/GPU-OPENCL-AMD/kernel/default.host.c +0 -0
  228. data/skeletons/GPU-OPENCL-AMD/kernel/default.kernel.cl +0 -0
  229. data/skeletons/GPU-OPENCL-AMD/skeletons.txt +0 -0
  230. data/skeletons/verification/header.c +0 -0
  231. data/skeletons/verification/timer_start.c +0 -0
  232. data/skeletons/verification/timer_stop.c +0 -0
  233. data/skeletons/verification/verify_results.c +0 -0
  234. data/test/bones/test_algorithm.rb +0 -0
  235. data/test/bones/test_common.rb +0 -0
  236. data/test/bones/test_preprocessor.rb +0 -0
  237. data/test/bones/test_species.rb +0 -0
  238. data/test/bones/test_variable.rb +0 -0
  239. data/test/examples/benchmarks/PolyBench/2mm_species.c +1 -1
  240. data/test/examples/benchmarks/PolyBench/3mm_species.c +0 -0
  241. data/test/examples/benchmarks/PolyBench/adi_species.c +0 -0
  242. data/test/examples/benchmarks/PolyBench/atax_species.c +0 -0
  243. data/test/examples/benchmarks/PolyBench/bicg_species.c +0 -0
  244. data/test/examples/benchmarks/PolyBench/cholesky_species.c +0 -0
  245. data/test/examples/benchmarks/PolyBench/correlation_species.c +0 -0
  246. data/test/examples/benchmarks/PolyBench/covariance_species.c +0 -0
  247. data/test/examples/benchmarks/PolyBench/doitgen_species.c +0 -0
  248. data/test/examples/benchmarks/PolyBench/durbin_species.c +0 -0
  249. data/test/examples/benchmarks/PolyBench/dynprog_species.c +0 -0
  250. data/test/examples/benchmarks/PolyBench/fdtd-2d-apml_species.c +0 -0
  251. data/test/examples/benchmarks/PolyBench/fdtd-2d_species.c +0 -0
  252. data/test/examples/benchmarks/PolyBench/floyd-warshall_species.c +0 -0
  253. data/test/examples/benchmarks/PolyBench/gemm_species.c +0 -0
  254. data/test/examples/benchmarks/PolyBench/gemver_species.c +0 -0
  255. data/test/examples/benchmarks/PolyBench/gesummv_species.c +0 -0
  256. data/test/examples/benchmarks/PolyBench/gramschmidt_species.c +0 -0
  257. data/test/examples/benchmarks/PolyBench/jacobi-1d-imper_species.c +0 -0
  258. data/test/examples/benchmarks/PolyBench/jacobi-2d-imper_species.c +0 -0
  259. data/test/examples/benchmarks/PolyBench/lu_species.c +0 -0
  260. data/test/examples/benchmarks/PolyBench/ludcmp_species.c +0 -0
  261. data/test/examples/benchmarks/PolyBench/mvt_species.c +0 -0
  262. data/test/examples/benchmarks/PolyBench/reg_detect_species.c +0 -0
  263. data/test/examples/benchmarks/PolyBench/seidel-2d_species.c +0 -0
  264. data/test/examples/benchmarks/PolyBench/symm_species.c +0 -0
  265. data/test/examples/benchmarks/PolyBench/syr2k_species.c +0 -0
  266. data/test/examples/benchmarks/PolyBench/syrk_species.c +0 -0
  267. data/test/examples/benchmarks/PolyBench/trisolv_species.c +0 -0
  268. data/test/examples/benchmarks/PolyBench/trmm_species.c +0 -0
  269. data/test/examples/chunk/example01_species.c +3 -3
  270. data/test/examples/chunk/example02_species.c +3 -3
  271. data/test/examples/chunk/example03_species.c +3 -3
  272. data/test/examples/chunk/example04_species.c +3 -3
  273. data/test/examples/chunk/example05_species.c +3 -3
  274. data/test/examples/chunk/example06_species.c +1 -1
  275. data/test/examples/chunk/example07_species.c +3 -2
  276. data/test/examples/dependences/example01_species.c +1 -1
  277. data/test/examples/dependences/example02_species.c +1 -1
  278. data/test/examples/dependences/example03_species.c +1 -1
  279. data/test/examples/dependences/example04_species.c +1 -1
  280. data/test/examples/dependences/example05_species.c +1 -1
  281. data/test/examples/element/example01_species.c +3 -3
  282. data/test/examples/element/example02_species.c +3 -3
  283. data/test/examples/element/example03_species.c +7 -7
  284. data/test/examples/element/example04_species.c +3 -3
  285. data/test/examples/element/example05_species.c +3 -3
  286. data/test/examples/element/example06_species.c +3 -3
  287. data/test/examples/element/example07_species.c +3 -3
  288. data/test/examples/element/example08_species.c +3 -3
  289. data/test/examples/element/example09_species.c +3 -3
  290. data/test/examples/element/example10_species.c +1 -1
  291. data/test/examples/element/example11_species.c +1 -1
  292. data/test/examples/element/example12_species.c +1 -1
  293. data/test/examples/element/example13_species.c +1 -1
  294. data/test/examples/neighbourhood/example01_species.c +3 -3
  295. data/test/examples/neighbourhood/example02_species.c +3 -3
  296. data/test/examples/neighbourhood/example03_species.c +3 -3
  297. data/test/examples/neighbourhood/example04_species.c +3 -3
  298. data/test/examples/neighbourhood/example05_species.c +1 -1
  299. data/test/examples/shared/example01_species.c +3 -3
  300. data/test/examples/shared/example02_species.c +3 -3
  301. data/test/examples/shared/example03_species.c +3 -3
  302. data/test/examples/shared/example04_species.c +3 -3
  303. data/test/examples/shared/example05_species.c +3 -3
  304. data/test/test_helper.rb +2 -2
  305. metadata +266 -252
  306. checksums.yaml +0 -15
  307. data/examples/benchmarks/Rodinia/cfd.c +0 -180
@@ -0,0 +1,151 @@
1
+ //
2
+ // This file is part of the Bones source-to-source compiler examples. This C-code
3
+ // demonstrates the use of Bones for an example application: 'nw', taken from
4
+ // the Rodinia benchmark suite. For more information on the application or on Bones
5
+ // please use the contact information below.
6
+ //
7
+ // == More information on Hotspot
8
+ // Original code......https://www.cs.virginia.edu/~skadron/wiki/rodinia/
9
+ //
10
+ // == More information on Bones
11
+ // Contact............Cedric Nugteren <c.nugteren@tue.nl>
12
+ // Web address........http://parse.ele.tue.nl/bones/
13
+ //
14
+ // == File information
15
+ // Filename...........applications/nw.c
16
+ // Authors............Cedric Nugteren
17
+ // Last modified on...01-Jun-2014
18
+ //
19
+
20
+ //########################################################################
21
+ //### Includes
22
+ //########################################################################
23
+
24
+ #include <stdio.h>
25
+ #include <stdlib.h>
26
+ #include <math.h>
27
+
28
+ //########################################################################
29
+ //### Defines
30
+ //########################################################################
31
+
32
+ // Config
33
+ #define MAX_ROWS (2048+1)
34
+ #define MAX_COLS (2048+1)
35
+ #define PENALTY 10
36
+
37
+ // Reference
38
+ int blosum62[24][24] = {
39
+ { 4, -1, -2, -2, 0, -1, -1, 0, -2, -1, -1, -1, -1, -2, -1, 1, 0, -3, -2, 0, -2, -1, 0, -4},
40
+ {-1, 5, 0, -2, -3, 1, 0, -2, 0, -3, -2, 2, -1, -3, -2, -1, -1, -3, -2, -3, -1, 0, -1, -4},
41
+ {-2, 0, 6, 1, -3, 0, 0, 0, 1, -3, -3, 0, -2, -3, -2, 1, 0, -4, -2, -3, 3, 0, -1, -4},
42
+ {-2, -2, 1, 6, -3, 0, 2, -1, -1, -3, -4, -1, -3, -3, -1, 0, -1, -4, -3, -3, 4, 1, -1, -4},
43
+ { 0, -3, -3, -3, 9, -3, -4, -3, -3, -1, -1, -3, -1, -2, -3, -1, -1, -2, -2, -1, -3, -3, -2, -4},
44
+ {-1, 1, 0, 0, -3, 5, 2, -2, 0, -3, -2, 1, 0, -3, -1, 0, -1, -2, -1, -2, 0, 3, -1, -4},
45
+ {-1, 0, 0, 2, -4, 2, 5, -2, 0, -3, -3, 1, -2, -3, -1, 0, -1, -3, -2, -2, 1, 4, -1, -4},
46
+ { 0, -2, 0, -1, -3, -2, -2, 6, -2, -4, -4, -2, -3, -3, -2, 0, -2, -2, -3, -3, -1, -2, -1, -4},
47
+ {-2, 0, 1, -1, -3, 0, 0, -2, 8, -3, -3, -1, -2, -1, -2, -1, -2, -2, 2, -3, 0, 0, -1, -4},
48
+ {-1, -3, -3, -3, -1, -3, -3, -4, -3, 4, 2, -3, 1, 0, -3, -2, -1, -3, -1, 3, -3, -3, -1, -4},
49
+ {-1, -2, -3, -4, -1, -2, -3, -4, -3, 2, 4, -2, 2, 0, -3, -2, -1, -2, -1, 1, -4, -3, -1, -4},
50
+ {-1, 2, 0, -1, -3, 1, 1, -2, -1, -3, -2, 5, -1, -3, -1, 0, -1, -3, -2, -2, 0, 1, -1, -4},
51
+ {-1, -1, -2, -3, -1, 0, -2, -3, -2, 1, 2, -1, 5, 0, -2, -1, -1, -1, -1, 1, -3, -1, -1, -4},
52
+ {-2, -3, -3, -3, -2, -3, -3, -3, -1, 0, 0, -3, 0, 6, -4, -2, -2, 1, 3, -1, -3, -3, -1, -4},
53
+ {-1, -2, -2, -1, -3, -1, -1, -2, -2, -3, -3, -1, -2, -4, 7, -1, -1, -4, -3, -2, -2, -1, -2, -4},
54
+ { 1, -1, 1, 0, -1, 0, 0, 0, -1, -2, -2, 0, -1, -2, -1, 4, 1, -3, -2, -2, 0, 0, 0, -4},
55
+ { 0, -1, 0, -1, -1, -1, -1, -2, -2, -1, -1, -1, -1, -2, -1, 1, 5, -2, -2, 0, -1, -1, 0, -4},
56
+ {-3, -3, -4, -4, -2, -2, -3, -2, -2, -3, -2, -3, -1, 1, -4, -3, -2, 11, 2, -3, -4, -3, -2, -4},
57
+ {-2, -2, -2, -3, -2, -1, -2, -3, 2, -1, -1, -2, -1, 3, -3, -2, -2, 2, 7, -1, -3, -2, -1, -4},
58
+ { 0, -3, -3, -3, -1, -2, -2, -3, -3, 3, 1, -2, 1, -1, -2, -2, 0, -3, -1, 4, -3, -2, -1, -4},
59
+ {-2, -1, 3, 4, -3, 0, 1, -1, 0, -3, -4, 0, -3, -3, -2, 0, -1, -4, -3, -3, 4, 1, -1, -4},
60
+ {-1, 0, 0, 1, -3, 3, 4, -2, 0, -3, -3, 1, -1, -3, -1, 0, -1, -3, -2, -2, 1, 4, -1, -4},
61
+ { 0, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, 0, 0, -2, -1, -1, -1, -1, -1, -4},
62
+ {-4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, 1}
63
+ };
64
+
65
+ //########################################################################
66
+ //### Start of the main function
67
+ //########################################################################
68
+
69
+ int main(void) {
70
+ printf("[nw] Start Needleman-Wunsch\n");
71
+
72
+ // Arrays
73
+ int similarity[MAX_ROWS][MAX_COLS];
74
+ int items[MAX_ROWS][MAX_COLS];
75
+
76
+ // Initialize random input data
77
+ srand (7);
78
+ for (int i=0; i<MAX_ROWS; i++) {
79
+ for (int j=0; j<MAX_COLS; j++) {
80
+ items[i][j] = 0;
81
+ }
82
+ }
83
+ for (int i=1; i<MAX_ROWS; i++) {
84
+ items[i][0] = rand()%10 + 1;
85
+ }
86
+ for (int j=1; j<MAX_COLS; j++) {
87
+ items[0][j] = rand()%10 + 1;
88
+ }
89
+
90
+ // Initialize reference
91
+ for (int i=0; i<MAX_ROWS; i++) {
92
+ for (int j=0; j<MAX_COLS; j++) {
93
+ similarity[i][j] = blosum62[items[i][0]][items[0][j]];
94
+ }
95
+ }
96
+
97
+ // Update input with penalty
98
+ for (int i=1; i<MAX_ROWS; i++) {
99
+ items[i][0] = -i*PENALTY;
100
+ }
101
+ for (int j=1; j<MAX_COLS; j++) {
102
+ items[0][j] = -j*PENALTY;
103
+ }
104
+
105
+ // Start of computation
106
+ #pragma scop
107
+
108
+ // Compute top-left matrix
109
+ for (int i=0; i<MAX_ROWS-2; i++) {
110
+ for (int idx=0; idx <= i; idx++) {
111
+ int a = items[idx+0][i+0-idx] + similarity[idx+1][i+1-idx];
112
+ int b = items[idx+1][i+0-idx] - PENALTY;
113
+ int c = items[idx+0][i+1-idx] - PENALTY;
114
+ int max_val = a;
115
+ if (b > max_val) {
116
+ max_val = b;
117
+ }
118
+ if (c > max_val) {
119
+ max_val = c;
120
+ }
121
+ items[idx+1][i+1-idx] = max_val;
122
+ }
123
+ }
124
+
125
+ // Compute bottom-right matrix
126
+ for (int i=MAX_ROWS-4; i>=0; i--) {
127
+ for (int idx=0; idx <= i; idx++) {
128
+ int a = items[MAX_ROWS-idx-3][idx+MAX_COLS-i-3] + similarity[MAX_ROWS-idx-2][idx+MAX_COLS-i-2];
129
+ int b = items[MAX_ROWS-idx-2][idx+MAX_COLS-i-3] - PENALTY;
130
+ int c = items[MAX_ROWS-idx-3][idx+MAX_COLS-i-2] - PENALTY;
131
+ int max_val = a;
132
+ if (b > max_val) {
133
+ max_val = b;
134
+ }
135
+ if (c > max_val) {
136
+ max_val = c;
137
+ }
138
+ items[MAX_ROWS-idx-2][idx+MAX_COLS-i-2] = max_val;
139
+ }
140
+ }
141
+
142
+ // End of computation
143
+ #pragma endscop
144
+
145
+ // Clean-up and exit
146
+ printf("\n[nw] Completed\n\n"); fflush(stdout);
147
+ fflush(stdout);
148
+ return 0;
149
+ }
150
+
151
+ //########################################################################
@@ -0,0 +1,88 @@
1
+ //
2
+ // This file is part of the Bones source-to-source compiler examples. This C-code
3
+ // demonstrates the use of Bones for an example application: 'pathfinder', taken from
4
+ // the Rodinia benchmark suite. For more information on the application or on Bones
5
+ // please use the contact information below.
6
+ //
7
+ // == More information on Hotspot
8
+ // Original code......https://www.cs.virginia.edu/~skadron/wiki/rodinia/
9
+ //
10
+ // == More information on Bones
11
+ // Contact............Cedric Nugteren <c.nugteren@tue.nl>
12
+ // Web address........http://parse.ele.tue.nl/bones/
13
+ //
14
+ // == File information
15
+ // Filename...........applications/pathfinder.c
16
+ // Authors............Cedric Nugteren
17
+ // Last modified on...05-Jun-2014
18
+ //
19
+ //########################################################################
20
+
21
+ // Includes
22
+ #include "common.h"
23
+
24
+ //########################################################################
25
+ //### Start of the main function
26
+ //########################################################################
27
+
28
+ int main(void) {
29
+
30
+ // Variables
31
+ unsigned long long cycles;
32
+ int min;
33
+
34
+ // Initialize arrays
35
+ int wall[PATHROWS][PATHCOLS];
36
+ int result[PATHCOLS];
37
+ int input[PATHCOLS];
38
+
39
+ // Seed
40
+ int seed = M_SEED;
41
+ srand(seed);
42
+
43
+ // Set initial values
44
+ for (int i=0; i<PATHROWS; i++) {
45
+ for (int j=0; j<PATHCOLS; j++) {
46
+ wall[i][j] = rand() % 10;
47
+ }
48
+ }
49
+ for (int j=0; j<PATHCOLS; j++) {
50
+ result[j] = wall[0][j];
51
+ }
52
+
53
+ // Iterate over the PATHROWS
54
+ #pragma scop
55
+ for (int t=1; t<PATHROWS; t++) {
56
+
57
+ // Copy result of previous iteration as current input
58
+ for (int n=0; n<PATHCOLS; n++) {
59
+ input[n] = result[n];
60
+ }
61
+
62
+ // Iterate over the columns
63
+ for (int n=0; n<PATHCOLS; n++) {
64
+ min = input[n];
65
+ if (n > 0) {
66
+ int val1 = input[n-1];
67
+ if (val1 < min) {
68
+ min = val1;
69
+ }
70
+ }
71
+ if (n < PATHCOLS-1) {
72
+ int val2 = input[n+1];
73
+ if (val2 < min) {
74
+ min = val2;
75
+ }
76
+ }
77
+ result[n] = wall[t][n] + min;
78
+ }
79
+ }
80
+ #pragma endscop
81
+
82
+ // Clean-up and exit
83
+ printf("\n[pathfinder] Completed\n\n"); fflush(stdout);
84
+ fflush(stdout);
85
+ return 0;
86
+ }
87
+
88
+ //########################################################################
@@ -17,29 +17,12 @@
17
17
  // Filename...........applications/srad.c
18
18
  // Authors............Cedric Nugteren
19
19
  // Original authors...Rob Janiczek, Drew Gilliam, Lukasz Szafaryn
20
- // Last modified on...10-Aug-2012
20
+ // Last modified on...05-Jun-2014
21
21
  //
22
-
23
- //########################################################################
24
- //### Includes
25
- //########################################################################
26
-
27
- #include <stdio.h>
28
- #include <stdlib.h>
29
- #include <math.h>
30
-
31
- //########################################################################
32
- //### Defines
33
22
  //########################################################################
34
23
 
35
- #define ROWS 128 // Number of ROWS in the domain
36
- #define COLS 128 // Number of COLS in the domain
37
- #define R1 0 // y1 position of the speckle
38
- #define R2 31 // y2 position of the speckle
39
- #define C1 0 // x1 position of the speckle
40
- #define C2 31 // x2 position of the speckle
41
- #define LAMBDA 0.5 // Lambda value
42
- #define NITER 2 // Number of iterations
24
+ // Includes
25
+ #include "common.h"
43
26
 
44
27
  //########################################################################
45
28
  //### Start of the main function
@@ -74,19 +57,19 @@ int main(void) {
74
57
  printf("\n[srad] Initialising memory"); fflush(stdout);
75
58
  int size = COLS*ROWS;
76
59
  int size_roi = (R2-R1+1)*(C2-C1+1);
77
- float* values = (float*) malloc(sizeof(float)*size);
78
- float* coefficent = (float*) malloc(sizeof(float)*size);
79
- float* dN = (float*) malloc(sizeof(float)*size);
80
- float* dS = (float*) malloc(sizeof(float)*size);
81
- float* dW = (float*) malloc(sizeof(float)*size);
82
- float* dE = (float*) malloc(sizeof(float)*size);
60
+ float values[ROWS][COLS];
61
+ float coefficent[ROWS][COLS];
62
+ float dN[ROWS][COLS];
63
+ float dS[ROWS][COLS];
64
+ float dW[ROWS][COLS];
65
+ float dE[ROWS][COLS];
83
66
 
84
67
  // Populate the input matrix
85
68
  printf("\n[srad] Populating the input matrix with random values"); fflush(stdout);
86
69
  for (i=0; i<ROWS; i++) {
87
70
  for (j=0; j<COLS; j++) {
88
71
  temp_value = rand()/(float)RAND_MAX;
89
- values[i*COLS+j] = (float)exp(temp_value);
72
+ values[i][j] = (float)exp(temp_value);
90
73
  }
91
74
  }
92
75
 
@@ -99,7 +82,7 @@ int main(void) {
99
82
  sum2 = 0;
100
83
  for (i=R1; i<=R2; i++) {
101
84
  for (j=C1; j<=C2; j++) {
102
- temp_value = values[i*COLS+j];
85
+ temp_value = values[i][j];
103
86
  sum1 += temp_value;
104
87
  sum2 += temp_value*temp_value;
105
88
  }
@@ -108,61 +91,69 @@ int main(void) {
108
91
  var_roi = (sum2/size_roi) - mean_roi*mean_roi;
109
92
  q0s = var_roi / (mean_roi*mean_roi);
110
93
 
111
- // Iterate over the full image and compute
112
94
  #pragma scop
95
+ // Iterate over the full image and computeΩ
113
96
  for (i=0; i<ROWS; i++) {
114
97
  for (j=0; j<COLS; j++) {
115
- index = i*COLS+j;
116
- current_value = values[index];
98
+
99
+ current_value = values[i][j];
100
+
101
+ // Temporary variables
102
+ float valN = 0;
103
+ float valS = 0;
104
+ float valW = 0;
105
+ float valE = 0;
117
106
 
118
107
  // Compute the directional derivates (N,S,W,E)
119
- if (i==0) { dN[index] = 0; }
120
- else { dN[index] = values[(i-1)*COLS + j ] - current_value; }
121
- if (i==ROWS-1) { dS[index] = 0; }
122
- else { dS[index] = values[(i+1)*COLS + j ] - current_value; }
123
- if (j==0) { dW[index] = 0; }
124
- else { dW[index] = values[i *COLS + (j-1)] - current_value; }
125
- if (j==COLS-1) { dE[index] = 0; }
126
- else { dE[index] = values[i *COLS + (j+1)] - current_value; }
108
+ if (i > 0) { valN = values[i-1][j ] - current_value; }
109
+ if (i < ROWS-1) { valS = values[i+1][j ] - current_value; }
110
+ if (j > 0) { valW = values[i ][j-1] - current_value; }
111
+ if (j < COLS-1) { valE = values[i ][j+1] - current_value; }
127
112
 
128
113
  // Compute the instantaneous coefficient of variation (qs) (equation 35)
129
- G2 = (dN[index]*dN[index] + dS[index]*dS[index] + dW[index]*dW[index] + dE[index]*dE[index]) / (current_value*current_value);
130
- L = (dN[index] + dS[index] + dW[index] + dE[index] ) / (current_value );
114
+ G2 = (valN*valN + valS*valS + valW*valW + valE*valE) / (current_value*current_value);
115
+ L = (valN + valS + valW + valE ) / (current_value );
131
116
  temp_a = (0.5*G2)-((1.0/16.0)*(L*L));
132
117
  temp_b = 1+(0.25*L);
133
118
  qs = temp_a/(temp_b*temp_b);
134
119
 
120
+ // Write the data
121
+ dN[i][j] = valN;
122
+ dS[i][j] = valS;
123
+ dW[i][j] = valW;
124
+ dE[i][j] = valE;
125
+
135
126
  // Set the diffusion coefficent (equation 33)
136
- coefficent[index] = 1.0 / (1.0+( (qs-q0s)/(q0s*(1+q0s)) ));
127
+ float val = 1.0 / (1.0+( (qs-q0s)/(q0s*(1+q0s)) ));
137
128
 
138
129
  // Saturate the diffusion coefficent
139
- if (coefficent[index] < 0) {
140
- coefficent[index] = 0;
130
+ if (val < 0) {
131
+ val = 0;
141
132
  }
142
- else if (coefficent[index] > 1) {
143
- coefficent[index] = 1;
133
+ else if (val > 1) {
134
+ val = 1;
144
135
  }
136
+ coefficent[i][j] = val;
145
137
  }
146
138
  }
147
-
139
+
148
140
  // Iterate over the full image again and compute the final values
149
141
  for (i=0; i<ROWS; i++) {
150
142
  for (j=0; j<COLS; j++) {
151
- index = i*COLS+j;
152
143
 
153
144
  // Calculate the diffusion coefficent
154
- cN = coefficent[i *COLS+j ];
145
+ cN = coefficent[i ][j ];
155
146
  if (i==ROWS-1) { cS = 0; }
156
- else { cS = coefficent[(i+1)*COLS+j ]; }
157
- cW = coefficent[i *COLS+j ];
147
+ else { cS = coefficent[i+1][j ]; }
148
+ cW = coefficent[i ][j ];
158
149
  if (j==COLS-1) { cE = 0; }
159
- else { cE = coefficent[i *COLS+(j+1)]; }
150
+ else { cE = coefficent[i ][j+1]; }
160
151
 
161
152
  // Calculate the divergence (equation 58)
162
- divergence = cN*dN[index] + cS*dS[index] + cW*dW[index] + cE*dE[index];
153
+ divergence = cN*dN[i][j] + cS*dS[i][j] + cW*dW[i][j] + cE*dE[i][j];
163
154
 
164
155
  // Update the image accordingly (equation 61)
165
- values[index] = values[index] + 0.25*LAMBDA*divergence;
156
+ values[i][j] = values[i][j] + 0.25*LAMBDA*divergence;
166
157
  }
167
158
  }
168
159
  #pragma endscop
@@ -172,15 +163,15 @@ int main(void) {
172
163
  printf("\n[srad] Printing the output matrix:\n\n"); fflush(stdout);
173
164
  for (i=0; i<ROWS; i++) {
174
165
  for (j=0; j<COLS; j++) {
175
- printf("%.5f ", values[i*COLS+j]);
166
+ if (i == 5 && j == 5) {
167
+ printf("%.5f ", values[i][j]);
168
+ }
176
169
  }
177
- printf("\n");
170
+ //printf("\n");
178
171
  }
179
172
 
180
173
  // Clean-up and exit
181
- printf("\n[srad] Completed\n\n"); fflush(stdout);
182
- free(values); free(coefficent);
183
- free(dN); free(dS); free(dW); free(dE);
174
+ printf("\n[srad] Completed\n\n");
184
175
  fflush(stdout);
185
176
  return 0;
186
177
  }
File without changes
File without changes
File without changes
File without changes
@@ -8,14 +8,14 @@
8
8
  // Web address........http://parse.ele.tue.nl/bones/
9
9
  //
10
10
  // == File information
11
- // Filename...........chunk/example1.c
11
+ // Filename...........chunk/example01.c
12
12
  // Author.............Cedric Nugteren
13
- // Last modified on...16-April-2012
13
+ // Last modified on...10-October-2014
14
14
  //
15
15
 
16
16
  #include <stdio.h>
17
17
 
18
- // This is 'example1', a basic chunk to element example using a 2D tile
18
+ // This is 'example01', a basic chunk to element example using a 2D tile
19
19
  int main(void) {
20
20
  int i,j;
21
21
  int i2,j2;
@@ -33,7 +33,8 @@ int main(void) {
33
33
  }
34
34
 
35
35
  // Perform the computation
36
- #pragma species kernel 0:559,0:31|chunk(0:9,0:1) -> 0:55,0:15|element
36
+ #pragma scop
37
+ #pragma species kernel A[0:559,0:31]|chunk(0:9,0:1) -> B[0:55,0:15]|element
37
38
  for(i=0;i<56;i++) {
38
39
  for(j=0;j<16;j++) {
39
40
  result = 0;
@@ -46,6 +47,7 @@ int main(void) {
46
47
  }
47
48
  }
48
49
  #pragma species endkernel example1
50
+ #pragma endscop
49
51
 
50
52
  // Clean-up and exit the function
51
53
  fflush(stdout);