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.
- data/CHANGELOG +62 -0
- data/README.rdoc +14 -3
- data/Rakefile +13 -12
- data/VERSION +1 -1
- data/examples/applications/ffos.c +24 -8
- data/examples/benchmarks/PolyBench/2mm.c +0 -0
- data/examples/benchmarks/PolyBench/3mm.c +0 -0
- data/examples/benchmarks/PolyBench/adi.c +0 -0
- data/examples/benchmarks/PolyBench/atax.c +0 -0
- data/examples/benchmarks/PolyBench/bicg.c +0 -0
- data/examples/benchmarks/PolyBench/cholesky.c +0 -0
- data/examples/benchmarks/PolyBench/common.h +0 -0
- data/examples/benchmarks/PolyBench/correlation.c +0 -0
- data/examples/benchmarks/PolyBench/covariance.c +0 -0
- data/examples/benchmarks/PolyBench/doitgen.c +0 -0
- data/examples/benchmarks/PolyBench/durbin.c +0 -0
- data/examples/benchmarks/PolyBench/dynprog.c +0 -0
- data/examples/benchmarks/PolyBench/fdtd-2d-apml.c +0 -0
- data/examples/benchmarks/PolyBench/fdtd-2d.c +0 -0
- data/examples/benchmarks/PolyBench/floyd-warshall.c +0 -0
- data/examples/benchmarks/PolyBench/gemm.c +0 -0
- data/examples/benchmarks/PolyBench/gemver.c +0 -0
- data/examples/benchmarks/PolyBench/gesummv.c +0 -0
- data/examples/benchmarks/PolyBench/gramschmidt.c +0 -0
- data/examples/benchmarks/PolyBench/jacobi-1d-imper.c +4 -2
- data/examples/benchmarks/PolyBench/jacobi-2d-imper.c +1 -1
- data/examples/benchmarks/PolyBench/lu.c +0 -0
- data/examples/benchmarks/PolyBench/ludcmp.c +0 -0
- data/examples/benchmarks/PolyBench/mvt.c +0 -0
- data/examples/benchmarks/PolyBench/reg_detect.c +0 -0
- data/examples/benchmarks/PolyBench/seidel-2d.c +0 -0
- data/examples/benchmarks/PolyBench/symm.c +0 -0
- data/examples/benchmarks/PolyBench/syr2k.c +0 -0
- data/examples/benchmarks/PolyBench/syrk.c +0 -0
- data/examples/benchmarks/PolyBench/trisolv.c +0 -0
- data/examples/benchmarks/PolyBench/trmm.c +0 -0
- data/examples/benchmarks/Rodinia/bfs.c +143 -0
- data/examples/benchmarks/Rodinia/common.h +78 -0
- data/examples/benchmarks/Rodinia/hotspot.c +106 -126
- data/examples/benchmarks/Rodinia/kmeans.c +157 -164
- data/examples/benchmarks/Rodinia/nw.c +151 -0
- data/examples/benchmarks/Rodinia/pathfinder.c +88 -0
- data/examples/benchmarks/Rodinia/srad.c +50 -59
- data/examples/benchmarks/other/common.h +0 -0
- data/examples/benchmarks/other/dct.c +0 -0
- data/examples/benchmarks/other/mm.c +0 -0
- data/examples/benchmarks/other/saxpy.c +0 -0
- data/examples/chunk/example01.c +6 -4
- data/examples/chunk/example02.c +6 -4
- data/examples/chunk/example03.c +6 -4
- data/examples/chunk/example04.c +8 -5
- data/examples/chunk/example05.c +6 -4
- data/examples/chunk/example06.c +3 -1
- data/examples/chunk/example07.c +5 -2
- data/examples/dependences/example01.c +3 -1
- data/examples/dependences/example02.c +3 -1
- data/examples/dependences/example03.c +3 -1
- data/examples/dependences/example04.c +3 -1
- data/examples/dependences/example05.c +3 -1
- data/examples/element/example01.c +6 -4
- data/examples/element/example02.c +6 -4
- data/examples/element/example03.c +10 -8
- data/examples/element/example04.c +6 -4
- data/examples/element/example05.c +8 -5
- data/examples/element/example06.c +6 -4
- data/examples/element/example07.c +6 -4
- data/examples/element/example08.c +6 -4
- data/examples/element/example09.c +6 -4
- data/examples/element/example10.c +4 -2
- data/examples/element/example11.c +4 -2
- data/examples/element/example12.c +4 -2
- data/examples/element/example13.c +3 -1
- data/examples/fusion/example01.c +3 -12
- data/examples/fusion/example02.c +3 -16
- data/examples/fusion/example03.c +3 -1
- data/examples/fusion/example04.c +5 -3
- data/examples/fusion/example05.c +3 -1
- data/examples/neighbourhood/example01.c +6 -4
- data/examples/neighbourhood/example02.c +6 -4
- data/examples/neighbourhood/example03.c +6 -4
- data/examples/neighbourhood/example04.c +5 -3
- data/examples/neighbourhood/example05.c +3 -1
- data/examples/shared/example01.c +6 -4
- data/examples/shared/example02.c +6 -4
- data/examples/shared/example03.c +6 -4
- data/examples/shared/example04.c +6 -4
- data/examples/shared/example05.c +6 -4
- data/lib/adarwin/engine.rb +16 -5
- data/lib/adarwin/memorycopies.rb +21 -9
- data/lib/adarwin/nest.rb +18 -1
- data/lib/adarwin/preprocessor.rb +5 -2
- data/lib/adarwin/reference.rb +71 -6
- data/lib/bones/algorithm.rb +20 -5
- data/lib/bones/copy.rb +3 -2
- data/lib/bones/engine.rb +12 -9
- data/lib/bones/preprocessor.rb +170 -120
- data/lib/bones/variablelist.rb +1 -1
- data/lib/cast.rb +11 -0
- data/lib/castaddon.rb +23 -6
- data/lib/castaddon/node_adarwin.rb +17 -0
- data/lib/castaddon/node_common.rb +6 -0
- data/lib/castaddon/transformations.rb +13 -9
- data/skeletons/CPU-C/common/epilogue.c +0 -0
- data/skeletons/CPU-C/common/globals.c +0 -0
- data/skeletons/CPU-C/common/globals_kernel.c +0 -0
- data/skeletons/CPU-C/common/header.c +0 -0
- data/skeletons/CPU-C/common/mem_copy_D2H.c +0 -0
- data/skeletons/CPU-C/common/mem_copy_H2D.c +0 -0
- data/skeletons/CPU-C/common/mem_epilogue.c +0 -0
- data/skeletons/CPU-C/common/mem_global.c +0 -0
- data/skeletons/CPU-C/common/mem_prologue.c +0 -0
- data/skeletons/CPU-C/common/prologue.c +0 -0
- data/skeletons/CPU-C/common/timer_1_start.c +0 -0
- data/skeletons/CPU-C/common/timer_1_stop.c +0 -0
- data/skeletons/CPU-C/common/timer_2_start.c +0 -0
- data/skeletons/CPU-C/common/timer_2_stop.c +0 -0
- data/skeletons/CPU-C/common/timer_globals.c +5 -0
- data/skeletons/CPU-C/kernel/default.host.c +0 -0
- data/skeletons/CPU-C/kernel/default.kernel.c +0 -0
- data/skeletons/CPU-C/skeletons.txt +0 -0
- data/skeletons/CPU-OPENCL-AMD/common/epilogue.c +0 -0
- data/skeletons/CPU-OPENCL-AMD/common/globals.c +0 -0
- data/skeletons/CPU-OPENCL-AMD/common/globals_kernel.c +0 -0
- data/skeletons/CPU-OPENCL-AMD/common/header.c +0 -0
- data/skeletons/CPU-OPENCL-AMD/common/mem_copy_D2H.c +0 -0
- data/skeletons/CPU-OPENCL-AMD/common/mem_copy_H2D.c +0 -0
- data/skeletons/CPU-OPENCL-AMD/common/mem_epilogue.c +0 -0
- data/skeletons/CPU-OPENCL-AMD/common/mem_prologue.c +0 -0
- data/skeletons/CPU-OPENCL-AMD/common/prologue.c +0 -0
- data/skeletons/CPU-OPENCL-AMD/common/timer_1_start.c +0 -0
- data/skeletons/CPU-OPENCL-AMD/common/timer_1_stop.c +0 -0
- data/skeletons/CPU-OPENCL-AMD/common/timer_2_start.c +0 -0
- data/skeletons/CPU-OPENCL-AMD/common/timer_2_stop.c +0 -0
- data/skeletons/CPU-OPENCL-AMD/kernel/D-element-to-1-shared.host.c +0 -0
- data/skeletons/CPU-OPENCL-AMD/kernel/D-element-to-1-shared.kernel.cl +0 -0
- data/skeletons/CPU-OPENCL-AMD/kernel/default.host.c +0 -0
- data/skeletons/CPU-OPENCL-AMD/kernel/default.kernel.cl +0 -0
- data/skeletons/CPU-OPENCL-AMD/skeletons.txt +0 -0
- data/skeletons/CPU-OPENCL-INTEL/common/epilogue.c +0 -0
- data/skeletons/CPU-OPENCL-INTEL/common/globals.c +0 -0
- data/skeletons/CPU-OPENCL-INTEL/common/globals_kernel.c +0 -0
- data/skeletons/CPU-OPENCL-INTEL/common/header.c +0 -0
- data/skeletons/CPU-OPENCL-INTEL/common/mem_copy_D2H.c +0 -0
- data/skeletons/CPU-OPENCL-INTEL/common/mem_copy_H2D.c +0 -0
- data/skeletons/CPU-OPENCL-INTEL/common/mem_epilogue.c +0 -0
- data/skeletons/CPU-OPENCL-INTEL/common/mem_global.c +0 -0
- data/skeletons/CPU-OPENCL-INTEL/common/mem_prologue.c +0 -0
- data/skeletons/CPU-OPENCL-INTEL/common/prologue.c +0 -0
- data/skeletons/CPU-OPENCL-INTEL/common/timer_1_start.c +0 -0
- data/skeletons/CPU-OPENCL-INTEL/common/timer_1_stop.c +0 -0
- data/skeletons/CPU-OPENCL-INTEL/common/timer_2_start.c +0 -0
- data/skeletons/CPU-OPENCL-INTEL/common/timer_2_stop.c +0 -0
- data/skeletons/CPU-OPENCL-INTEL/common/timer_globals.c +5 -0
- data/skeletons/CPU-OPENCL-INTEL/kernel/D-element-to-1-shared.host.c +0 -0
- data/skeletons/CPU-OPENCL-INTEL/kernel/D-element-to-1-shared.kernel.cl +0 -0
- data/skeletons/CPU-OPENCL-INTEL/kernel/default.host.c +0 -0
- data/skeletons/CPU-OPENCL-INTEL/kernel/default.kernel.cl +0 -0
- data/skeletons/CPU-OPENCL-INTEL/skeletons.txt +0 -0
- data/skeletons/CPU-OPENMP/common/epilogue.c +0 -0
- data/skeletons/CPU-OPENMP/common/globals.c +0 -0
- data/skeletons/CPU-OPENMP/common/globals_kernel.c +0 -0
- data/skeletons/CPU-OPENMP/common/header.c +0 -0
- data/skeletons/CPU-OPENMP/common/mem_copy_D2H.c +0 -0
- data/skeletons/CPU-OPENMP/common/mem_copy_H2D.c +0 -0
- data/skeletons/CPU-OPENMP/common/mem_epilogue.c +0 -0
- data/skeletons/CPU-OPENMP/common/mem_global.c +0 -0
- data/skeletons/CPU-OPENMP/common/mem_prologue.c +0 -0
- data/skeletons/CPU-OPENMP/common/prologue.c +0 -0
- data/skeletons/CPU-OPENMP/common/timer_1_start.c +0 -0
- data/skeletons/CPU-OPENMP/common/timer_1_stop.c +0 -0
- data/skeletons/CPU-OPENMP/common/timer_2_start.c +0 -0
- data/skeletons/CPU-OPENMP/common/timer_2_stop.c +0 -0
- data/skeletons/CPU-OPENMP/common/timer_globals.c +2 -0
- data/skeletons/CPU-OPENMP/kernel/D-element-to-1-shared.host.c +0 -0
- data/skeletons/CPU-OPENMP/kernel/D-element-to-1-shared.kernel.c +3 -3
- data/skeletons/CPU-OPENMP/kernel/default.host.c +0 -0
- data/skeletons/CPU-OPENMP/kernel/default.kernel.c +0 -0
- data/skeletons/CPU-OPENMP/skeletons.txt +0 -0
- data/skeletons/GPU-CUDA/common/epilogue.c +0 -0
- data/skeletons/GPU-CUDA/common/globals.c +0 -0
- data/skeletons/GPU-CUDA/common/globals_kernel.c +0 -0
- data/skeletons/GPU-CUDA/common/header.c +0 -0
- data/skeletons/GPU-CUDA/common/mem_async_alloc.c +0 -0
- data/skeletons/GPU-CUDA/common/mem_async_copyin.c +0 -0
- data/skeletons/GPU-CUDA/common/mem_async_copyout.c +0 -0
- data/skeletons/GPU-CUDA/common/mem_async_free.c +0 -0
- data/skeletons/GPU-CUDA/common/mem_copy_D2H.c +0 -0
- data/skeletons/GPU-CUDA/common/mem_copy_H2D.c +0 -0
- data/skeletons/GPU-CUDA/common/mem_epilogue.c +0 -0
- data/skeletons/GPU-CUDA/common/mem_global.c +0 -0
- data/skeletons/GPU-CUDA/common/mem_prologue.c +0 -0
- data/skeletons/GPU-CUDA/common/prologue.c +0 -0
- data/skeletons/GPU-CUDA/common/scheduler.c +2 -2
- data/skeletons/GPU-CUDA/common/timer_1_start.c +0 -0
- data/skeletons/GPU-CUDA/common/timer_1_stop.c +0 -0
- data/skeletons/GPU-CUDA/common/timer_2_start.c +0 -0
- data/skeletons/GPU-CUDA/common/timer_2_stop.c +0 -0
- data/skeletons/GPU-CUDA/common/timer_globals.c +0 -0
- data/skeletons/GPU-CUDA/kernel/2xN-N-chunk-1-N-to-D-element.host.c +0 -0
- data/skeletons/GPU-CUDA/kernel/2xN-N-chunk-1-N-to-D-element.kernel.cu +0 -0
- data/skeletons/GPU-CUDA/kernel/D-element-to-1-shared.host.c +0 -0
- data/skeletons/GPU-CUDA/kernel/D-element-to-1-shared.kernel.cu +0 -0
- data/skeletons/GPU-CUDA/kernel/D-element-to-N-shared.host.c +0 -0
- data/skeletons/GPU-CUDA/kernel/D-element-to-N-shared.kernel.cu +0 -0
- data/skeletons/GPU-CUDA/kernel/N-N-chunk-1-N-to-D-element.host.c +0 -0
- data/skeletons/GPU-CUDA/kernel/N-N-chunk-1-N-to-D-element.kernel.cu +0 -0
- data/skeletons/GPU-CUDA/kernel/N-neighbourhood-N-to-N-element.host.c +0 -0
- data/skeletons/GPU-CUDA/kernel/N-neighbourhood-N-to-N-element.kernel.cu +0 -0
- data/skeletons/GPU-CUDA/kernel/default.host.c +0 -0
- data/skeletons/GPU-CUDA/kernel/default.kernel.cu +0 -0
- data/skeletons/GPU-CUDA/skeletons.txt +4 -2
- data/skeletons/GPU-OPENCL-AMD/common/epilogue.c +0 -0
- data/skeletons/GPU-OPENCL-AMD/common/globals.c +0 -0
- data/skeletons/GPU-OPENCL-AMD/common/globals_kernel.c +0 -0
- data/skeletons/GPU-OPENCL-AMD/common/header.c +0 -0
- data/skeletons/GPU-OPENCL-AMD/common/mem_copy_D2H.c +0 -0
- data/skeletons/GPU-OPENCL-AMD/common/mem_copy_H2D.c +0 -0
- data/skeletons/GPU-OPENCL-AMD/common/mem_epilogue.c +0 -0
- data/skeletons/GPU-OPENCL-AMD/common/mem_prologue.c +0 -0
- data/skeletons/GPU-OPENCL-AMD/common/prologue.c +0 -0
- data/skeletons/GPU-OPENCL-AMD/common/timer_1_start.c +0 -0
- data/skeletons/GPU-OPENCL-AMD/common/timer_1_stop.c +0 -0
- data/skeletons/GPU-OPENCL-AMD/common/timer_2_start.c +0 -0
- data/skeletons/GPU-OPENCL-AMD/common/timer_2_stop.c +0 -0
- data/skeletons/GPU-OPENCL-AMD/kernel/D-element-to-1-shared.host.c +0 -0
- data/skeletons/GPU-OPENCL-AMD/kernel/D-element-to-1-shared.kernel.cl +0 -0
- data/skeletons/GPU-OPENCL-AMD/kernel/default.host.c +0 -0
- data/skeletons/GPU-OPENCL-AMD/kernel/default.kernel.cl +0 -0
- data/skeletons/GPU-OPENCL-AMD/skeletons.txt +0 -0
- data/skeletons/verification/header.c +0 -0
- data/skeletons/verification/timer_start.c +0 -0
- data/skeletons/verification/timer_stop.c +0 -0
- data/skeletons/verification/verify_results.c +0 -0
- data/test/bones/test_algorithm.rb +0 -0
- data/test/bones/test_common.rb +0 -0
- data/test/bones/test_preprocessor.rb +0 -0
- data/test/bones/test_species.rb +0 -0
- data/test/bones/test_variable.rb +0 -0
- data/test/examples/benchmarks/PolyBench/2mm_species.c +1 -1
- data/test/examples/benchmarks/PolyBench/3mm_species.c +0 -0
- data/test/examples/benchmarks/PolyBench/adi_species.c +0 -0
- data/test/examples/benchmarks/PolyBench/atax_species.c +0 -0
- data/test/examples/benchmarks/PolyBench/bicg_species.c +0 -0
- data/test/examples/benchmarks/PolyBench/cholesky_species.c +0 -0
- data/test/examples/benchmarks/PolyBench/correlation_species.c +0 -0
- data/test/examples/benchmarks/PolyBench/covariance_species.c +0 -0
- data/test/examples/benchmarks/PolyBench/doitgen_species.c +0 -0
- data/test/examples/benchmarks/PolyBench/durbin_species.c +0 -0
- data/test/examples/benchmarks/PolyBench/dynprog_species.c +0 -0
- data/test/examples/benchmarks/PolyBench/fdtd-2d-apml_species.c +0 -0
- data/test/examples/benchmarks/PolyBench/fdtd-2d_species.c +0 -0
- data/test/examples/benchmarks/PolyBench/floyd-warshall_species.c +0 -0
- data/test/examples/benchmarks/PolyBench/gemm_species.c +0 -0
- data/test/examples/benchmarks/PolyBench/gemver_species.c +0 -0
- data/test/examples/benchmarks/PolyBench/gesummv_species.c +0 -0
- data/test/examples/benchmarks/PolyBench/gramschmidt_species.c +0 -0
- data/test/examples/benchmarks/PolyBench/jacobi-1d-imper_species.c +0 -0
- data/test/examples/benchmarks/PolyBench/jacobi-2d-imper_species.c +0 -0
- data/test/examples/benchmarks/PolyBench/lu_species.c +0 -0
- data/test/examples/benchmarks/PolyBench/ludcmp_species.c +0 -0
- data/test/examples/benchmarks/PolyBench/mvt_species.c +0 -0
- data/test/examples/benchmarks/PolyBench/reg_detect_species.c +0 -0
- data/test/examples/benchmarks/PolyBench/seidel-2d_species.c +0 -0
- data/test/examples/benchmarks/PolyBench/symm_species.c +0 -0
- data/test/examples/benchmarks/PolyBench/syr2k_species.c +0 -0
- data/test/examples/benchmarks/PolyBench/syrk_species.c +0 -0
- data/test/examples/benchmarks/PolyBench/trisolv_species.c +0 -0
- data/test/examples/benchmarks/PolyBench/trmm_species.c +0 -0
- data/test/examples/chunk/example01_species.c +3 -3
- data/test/examples/chunk/example02_species.c +3 -3
- data/test/examples/chunk/example03_species.c +3 -3
- data/test/examples/chunk/example04_species.c +3 -3
- data/test/examples/chunk/example05_species.c +3 -3
- data/test/examples/chunk/example06_species.c +1 -1
- data/test/examples/chunk/example07_species.c +3 -2
- data/test/examples/dependences/example01_species.c +1 -1
- data/test/examples/dependences/example02_species.c +1 -1
- data/test/examples/dependences/example03_species.c +1 -1
- data/test/examples/dependences/example04_species.c +1 -1
- data/test/examples/dependences/example05_species.c +1 -1
- data/test/examples/element/example01_species.c +3 -3
- data/test/examples/element/example02_species.c +3 -3
- data/test/examples/element/example03_species.c +7 -7
- data/test/examples/element/example04_species.c +3 -3
- data/test/examples/element/example05_species.c +3 -3
- data/test/examples/element/example06_species.c +3 -3
- data/test/examples/element/example07_species.c +3 -3
- data/test/examples/element/example08_species.c +3 -3
- data/test/examples/element/example09_species.c +3 -3
- data/test/examples/element/example10_species.c +1 -1
- data/test/examples/element/example11_species.c +1 -1
- data/test/examples/element/example12_species.c +1 -1
- data/test/examples/element/example13_species.c +1 -1
- data/test/examples/neighbourhood/example01_species.c +3 -3
- data/test/examples/neighbourhood/example02_species.c +3 -3
- data/test/examples/neighbourhood/example03_species.c +3 -3
- data/test/examples/neighbourhood/example04_species.c +3 -3
- data/test/examples/neighbourhood/example05_species.c +1 -1
- data/test/examples/shared/example01_species.c +3 -3
- data/test/examples/shared/example02_species.c +3 -3
- data/test/examples/shared/example03_species.c +3 -3
- data/test/examples/shared/example04_species.c +3 -3
- data/test/examples/shared/example05_species.c +3 -3
- data/test/test_helper.rb +2 -2
- metadata +266 -252
- checksums.yaml +0 -15
- data/examples/benchmarks/Rodinia/cfd.c +0 -180
data/lib/adarwin/preprocessor.rb
CHANGED
@@ -20,7 +20,7 @@ module Adarwin
|
|
20
20
|
@header_code = ''
|
21
21
|
@parsed_code = ''
|
22
22
|
@target_code = ''
|
23
|
-
@scop_code =
|
23
|
+
@scop_code = []
|
24
24
|
end
|
25
25
|
|
26
26
|
# This is the method to perform the actual preprocessing. This method takes
|
@@ -30,6 +30,7 @@ module Adarwin
|
|
30
30
|
# could have a commented-out SCoP or define or include.
|
31
31
|
def process
|
32
32
|
scop = false
|
33
|
+
scop_code = ''
|
33
34
|
scop_in_code = false
|
34
35
|
|
35
36
|
# Process the file line by line
|
@@ -55,12 +56,14 @@ module Adarwin
|
|
55
56
|
# Found the end of a SCoP
|
56
57
|
elsif line =~ /^#{WHITESPACE}#{SCOP_END}/
|
57
58
|
scop = false
|
59
|
+
@scop_code.push(scop_code)
|
60
|
+
scop_code = ''
|
58
61
|
@parsed_code += '}'+NL
|
59
62
|
end
|
60
63
|
|
61
64
|
# Nothing special in the code going on here
|
62
65
|
else
|
63
|
-
|
66
|
+
scop_code += line if scop
|
64
67
|
@parsed_code += line
|
65
68
|
@target_code += line
|
66
69
|
end
|
data/lib/adarwin/reference.rb
CHANGED
@@ -28,7 +28,7 @@ module Adarwin
|
|
28
28
|
# * It constructs the sets of loops (all,inner,outer) for this reference
|
29
29
|
# * It computes the bounds based on loop data and on if-statements
|
30
30
|
# * It computes the domain (D), number of elements (E), and step (S)
|
31
|
-
def initialize(reference,id,inner_loops,outer_loops,verbose)
|
31
|
+
def initialize(reference,id,inner_loops,outer_loops,var_declarations,verbose)
|
32
32
|
@id = id
|
33
33
|
|
34
34
|
# Initialise the 5-tuple (already fill in N and A)
|
@@ -44,6 +44,9 @@ module Adarwin
|
|
44
44
|
@all_loops = reference[:loop_data]
|
45
45
|
@inner_loops = inner_loops & @all_loops
|
46
46
|
@outer_loops = outer_loops
|
47
|
+
|
48
|
+
# Set the list of all local variables
|
49
|
+
@var_declarations = var_declarations
|
47
50
|
|
48
51
|
# Set the indices of the array reference (e.g. 2*i+4). The size of this
|
49
52
|
# array is equal to the number of dimensions of the array.
|
@@ -56,11 +59,11 @@ module Adarwin
|
|
56
59
|
@all_loops.each do |loop_data|
|
57
60
|
conditions = [loop_data[:min],loop_data[:max]]
|
58
61
|
reference[:if_statements].each do |if_statement|
|
59
|
-
|
60
|
-
|
61
|
-
max(conditions[0],condition_if[0])
|
62
|
-
min(conditions[1],condition_if[1])
|
63
|
-
|
62
|
+
if !array_includes_local_vars(if_statement,loop_vars)
|
63
|
+
condition_if = if_statement.map{ |c| solve(c,loop_data[:var],loop_vars) }
|
64
|
+
conditions[0] = max(conditions[0],condition_if[0])
|
65
|
+
conditions[1] = min(conditions[1],condition_if[1])
|
66
|
+
end
|
64
67
|
end
|
65
68
|
@bounds << { :var => loop_data[:var], :min => conditions[0], :max => conditions[1] }
|
66
69
|
end
|
@@ -103,6 +106,47 @@ module Adarwin
|
|
103
106
|
@tS[index] = '0'
|
104
107
|
end
|
105
108
|
end
|
109
|
+
|
110
|
+
# Check for local variables in the domain. If they exist ask the user to fill
|
111
|
+
# in the bounds.
|
112
|
+
# TODO: Make this a command-line question asked to the user. For now, several
|
113
|
+
# known values are simply put here - for ease of automated testing.
|
114
|
+
@tD.each do |bounds|
|
115
|
+
|
116
|
+
# Bounds are equal (e.g. [t:t])
|
117
|
+
if bounds.a == bounds.b && string_includes_local_vars(bounds.a)
|
118
|
+
|
119
|
+
# Default (assume 'char')
|
120
|
+
a = '0'
|
121
|
+
b = '255'
|
122
|
+
|
123
|
+
# Overrides (see notice above)
|
124
|
+
b = 'NUM_CLUSTERS-1' if bounds.a == 'cluster_index'
|
125
|
+
b = 'no_of_nodes-1' if bounds.b == 'id'
|
126
|
+
|
127
|
+
# Output a warning
|
128
|
+
puts WARNING+"Bounds of '#{bounds.a}' variable unknown, assuming #{a}:#{b}"
|
129
|
+
bounds.a = a
|
130
|
+
bounds.b = b
|
131
|
+
|
132
|
+
# Not equal but both problematic
|
133
|
+
elsif string_includes_local_vars(bounds.a) && string_includes_local_vars(bounds.b)
|
134
|
+
|
135
|
+
# Default (assume 'char')
|
136
|
+
a = '0'
|
137
|
+
b = '255'
|
138
|
+
|
139
|
+
# Overrides (see notice above)
|
140
|
+
b = 'no_of_nodes-1' if bounds.a == 'val2'
|
141
|
+
|
142
|
+
# Output a warning
|
143
|
+
puts WARNING+"Bounds of '#{bounds.a}' and '#{bounds.b}' variables unknown, assuming #{a}:#{b}"
|
144
|
+
bounds.a = a
|
145
|
+
bounds.b = b
|
146
|
+
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
106
150
|
|
107
151
|
# Print the result
|
108
152
|
puts MESSAGE+"Found: #{to_arc}" if verbose
|
@@ -256,6 +300,27 @@ module Adarwin
|
|
256
300
|
end
|
257
301
|
return false
|
258
302
|
end
|
303
|
+
|
304
|
+
# Method to find if local variables are included
|
305
|
+
def array_includes_local_vars(array, loop_vars)
|
306
|
+
vars = @var_declarations - loop_vars
|
307
|
+
array.each do |string|
|
308
|
+
vars.each do |decl|
|
309
|
+
if string =~ /\b#{decl}\b/
|
310
|
+
return true
|
311
|
+
end
|
312
|
+
end
|
313
|
+
end
|
314
|
+
return false
|
315
|
+
end
|
316
|
+
def string_includes_local_vars(string)
|
317
|
+
@var_declarations.each do |decl|
|
318
|
+
if string =~ /\b#{decl}\b/
|
319
|
+
return true
|
320
|
+
end
|
321
|
+
end
|
322
|
+
return false
|
323
|
+
end
|
259
324
|
|
260
325
|
end
|
261
326
|
end
|
data/lib/bones/algorithm.rb
CHANGED
@@ -40,7 +40,7 @@ module Bones
|
|
40
40
|
@lists = {:host_name => [],:host_definition => [], :argument_name => [], :argument_definition => [], :golden_name => []}
|
41
41
|
@arrays = Variablelist.new()
|
42
42
|
@constants = Variablelist.new()
|
43
|
-
@merge_factor =
|
43
|
+
@merge_factor = 0
|
44
44
|
@register_caching_enabled = 1
|
45
45
|
@function_code = ''
|
46
46
|
@function_name = ''
|
@@ -64,6 +64,7 @@ module Bones
|
|
64
64
|
@function_name = function.name
|
65
65
|
end
|
66
66
|
end
|
67
|
+
raise_error("Incorrect code found in body of #{@name}, something wrong with the classification?") if @function_code == ""
|
67
68
|
end
|
68
69
|
|
69
70
|
# This method performs the code transformations according
|
@@ -146,12 +147,17 @@ module Bones
|
|
146
147
|
|
147
148
|
# Perform transformations for reduction operations (conditionally do this)
|
148
149
|
if transformation[1,1].to_i >= 1
|
149
|
-
|
150
|
+
input = @arrays.select(INPUT)[0]
|
151
|
+
@arrays.select(OUTPUT).each do |output|
|
152
|
+
if output.species.shared?
|
153
|
+
new_code = new_code.transform_reduction(input,output,transformation[1,1].to_i)
|
154
|
+
end
|
155
|
+
end
|
150
156
|
end
|
151
157
|
|
152
158
|
# Perform thread-merging (experimental)
|
153
159
|
# TODO: Solve the problem related to constants (e.g chunk/example1.c)
|
154
|
-
if @merge_factor ==
|
160
|
+
if @merge_factor == 0
|
155
161
|
if transformation[0,1] == '4' && @hash[:parallelism].to_i >= 1024*1024
|
156
162
|
@merge_factor = 4
|
157
163
|
else
|
@@ -159,7 +165,7 @@ module Bones
|
|
159
165
|
end
|
160
166
|
end
|
161
167
|
if @merge_factor > 1
|
162
|
-
puts @hash[:parallelism]
|
168
|
+
#puts @hash[:parallelism]
|
163
169
|
if new_code.has_conditional_statements?
|
164
170
|
puts MESSAGE+'Not coarsening ('+@merge_factor.to_s+'x) because of conditional statements in kernel body.'
|
165
171
|
# TODO: Fix this temporary hack for multiple loops with mismatching bounds
|
@@ -405,7 +411,11 @@ module Bones
|
|
405
411
|
|
406
412
|
DIRECTIONS.each do |direction|
|
407
413
|
species = @species.structures(direction)
|
408
|
-
|
414
|
+
if direction == INPUT && @species.shared?
|
415
|
+
arrays = @arrays.inputs_only
|
416
|
+
else
|
417
|
+
arrays = @arrays.select(direction)
|
418
|
+
end
|
409
419
|
if !arrays.empty?
|
410
420
|
|
411
421
|
# Check if the amount of input/ouput arrays is equal to the amount of input/output species
|
@@ -439,6 +449,11 @@ module Bones
|
|
439
449
|
array = free_array if structure.name == free_array.name
|
440
450
|
end
|
441
451
|
end
|
452
|
+
|
453
|
+
# Still haven't found anything, raise an error
|
454
|
+
if !array
|
455
|
+
raise_error("Could not find a matching array in C-code for a species with name '#{species.first.name}'")
|
456
|
+
end
|
442
457
|
|
443
458
|
# Process the assignment
|
444
459
|
array.species = structure
|
data/lib/bones/copy.rb
CHANGED
@@ -3,9 +3,10 @@ module Bones
|
|
3
3
|
|
4
4
|
# Class copyin/out
|
5
5
|
class Copy
|
6
|
-
attr_accessor :name, :domain, :deadline, :direction, :id
|
6
|
+
attr_accessor :scop, :name, :domain, :deadline, :direction, :id
|
7
7
|
|
8
|
-
def initialize(name,domain,deadline,direction,id)
|
8
|
+
def initialize(scop,name,domain,deadline,direction,id)
|
9
|
+
@scop = scop
|
9
10
|
@name = name
|
10
11
|
@domain = domain
|
11
12
|
@deadline = deadline
|
data/lib/bones/engine.rb
CHANGED
@@ -91,16 +91,16 @@ module Bones
|
|
91
91
|
opt :measurements, 'Enable/disable timers', :short => 'm', :default => false
|
92
92
|
opt :verify, 'Verify correctness of the generated code', :short => 'c', :default => false
|
93
93
|
opt :only_alg_number, 'Only generate code for the x-th species (99 -> all)', :short => 'o', :type => Integer, :default => 99
|
94
|
-
opt :merge_factor, 'Thread merge factor, default is 1 (==disabled)', :short => 'f', :type => Integer, :default =>
|
94
|
+
opt :merge_factor, 'Thread merge factor, default is 1 (==disabled)', :short => 'f', :type => Integer, :default => 0
|
95
95
|
opt :register_caching,'Enable register caching: 1:enabled (default), 0:disabled', :short => 'r', :type => Integer, :default => 1
|
96
96
|
opt :zero_copy ,'Enable OpenCL zero-copy: 1:enabled (default), 0:disabled', :short => 'z', :type => Integer, :default => 1
|
97
97
|
opt :skeletons ,'Enable non-default skeletons: 1:enabled (default), 0:disabled', :short => 's', :type => Integer, :default => 1
|
98
98
|
end
|
99
99
|
Trollop::die 'no input file supplied (use: --application)' if !@options[:application_given]
|
100
100
|
Trollop::die 'no target supplied (use: --target)' if !@options[:target_given]
|
101
|
-
Trollop::die 'input file "'+@options[:application]+'"does not exist
|
101
|
+
Trollop::die 'input file "'+@options[:application]+'" does not exist' if !File.exists?(@options[:application])
|
102
102
|
Trollop::die 'target not supported, supported targets are: '+pp_targets if !targets.include?(@options[:target].upcase)
|
103
|
-
@options[:name] = @options[:application]
|
103
|
+
@options[:name] = File.basename(@options[:application], ".*")
|
104
104
|
@options[:target] = @options[:target].upcase
|
105
105
|
|
106
106
|
# Extension for the host files corresponding to the target.
|
@@ -204,9 +204,10 @@ module Bones
|
|
204
204
|
# Perform code generation (memory allocs)
|
205
205
|
allocs = []
|
206
206
|
preprocessor.copies.each do |copy|
|
207
|
-
|
207
|
+
name_scop = Set.new([copy.name, copy.scop])
|
208
|
+
if !allocs.include?(name_scop)
|
208
209
|
generate_memory('alloc',copy,arrays,0)
|
209
|
-
allocs <<
|
210
|
+
allocs << name_scop
|
210
211
|
end
|
211
212
|
end
|
212
213
|
|
@@ -219,9 +220,10 @@ module Bones
|
|
219
220
|
# Perform code generation (memory frees)
|
220
221
|
frees = []
|
221
222
|
preprocessor.copies.each do |copy|
|
222
|
-
|
223
|
+
name_scop = Set.new([copy.name, copy.scop])
|
224
|
+
if !frees.include?(name_scop)
|
223
225
|
generate_memory('free',copy,arrays,0)
|
224
|
-
frees <<
|
226
|
+
frees << name_scop
|
225
227
|
end
|
226
228
|
end
|
227
229
|
|
@@ -240,7 +242,7 @@ module Bones
|
|
240
242
|
def write_output
|
241
243
|
|
242
244
|
# Create a new directory for the output
|
243
|
-
directory = @options[:application].
|
245
|
+
directory = @options[:application].rpartition('.').first+'_'+@options[:target]
|
244
246
|
Dir.mkdir(directory,0744) unless File.directory?(directory)
|
245
247
|
|
246
248
|
parser = C::Parser.new
|
@@ -273,13 +275,14 @@ module Bones
|
|
273
275
|
end
|
274
276
|
|
275
277
|
# Populate the target file (host)
|
278
|
+
|
276
279
|
File.open(File.join(directory,@options[:name]+OUTPUT_HOST+@extension),'w') do |target|
|
277
280
|
target.puts '#include <cuda_runtime.h>'+NL if @options[:target] == 'GPU-CUDA'
|
278
281
|
target.puts "#define ZEROCOPY 0"+NL if @options[:zero_copy] == 0 && @options[:target] == 'CPU-OPENCL-INTEL'
|
279
282
|
target.puts "#define ZEROCOPY 1"+NL if @options[:zero_copy] == 1 && @options[:target] == 'CPU-OPENCL-INTEL'
|
280
283
|
target.puts @result[:header_code]
|
281
284
|
target.puts
|
282
|
-
target.puts @result[:host_device_mem_globals]
|
285
|
+
target.puts @result[:host_device_mem_globals].uniq
|
283
286
|
target.puts
|
284
287
|
target.puts @result[:algorithm_declarations]
|
285
288
|
target.puts @result[:host_code_lists]
|
data/lib/bones/preprocessor.rb
CHANGED
@@ -67,117 +67,147 @@ module Bones
|
|
67
67
|
species = nil
|
68
68
|
found = 0
|
69
69
|
alloc_index, free_index = 0, 0
|
70
|
+
block_comment = false
|
71
|
+
a_scop_was_found = false
|
72
|
+
scop = 0
|
73
|
+
scop_copies = []
|
70
74
|
|
71
75
|
# Process the file line by line
|
72
76
|
@source_code.each_line.with_index do |line,index|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
#
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
match = line.split(/\/\//)[0].scan(/^#{WHITESPACE}#define\s+(\w+)\s+(\S*)/)
|
87
|
-
@defines[match.first[0].to_sym] = match.first[1]
|
88
|
-
|
89
|
-
# Found the start of algorithm marker
|
90
|
-
elsif line =~ /^#{WHITESPACE}#{SPECIES_START}/
|
91
|
-
if found == 0
|
92
|
-
line = replace_defines(line,@defines)
|
93
|
-
prefix, input, output = marker_to_algorithm(line)
|
94
|
-
puts MESSAGE+'Found algorithm "'+(prefix+' '+input+' '+ARROW+' '+output).lstrip+'"' if VERBOSE
|
95
|
-
species = Bones::Species.new(prefix,input,output)
|
96
|
-
@found_algorithms = @found_algorithms + 1
|
97
|
-
end
|
98
|
-
found = found + 1
|
99
|
-
#@target_code << "int bones_temp_species_start = '#{line.gsub(NL,'')}';"+NL
|
100
|
-
|
101
|
-
# Found the end of algorithm marker
|
102
|
-
elsif line =~ /^#{WHITESPACE}#{SPECIES_END}/
|
103
|
-
if found == 1
|
104
|
-
name = line.strip.scan(/^#{WHITESPACE}#{SPECIES_END} (.+)/).join
|
105
|
-
name = DEFAULT_NAME if name == ''
|
106
|
-
@algorithms.push(Bones::Algorithm.new(name,@filename,index.to_s,species,algorithm_code))
|
107
|
-
algorithm_code = ''
|
108
|
-
end
|
109
|
-
found = found - 1
|
110
|
-
#@target_code << "int bones_temp_species_end = '#{line.gsub(NL,'')}';"+NL
|
111
|
-
|
112
|
-
# Found a sync marker
|
113
|
-
elsif @scheduler && line =~ /^#{WHITESPACE}#{SYNC}/
|
114
|
-
sync = line.strip.scan(/^#{WHITESPACE}#{SYNC} (.+)/).join
|
115
|
-
@target_code << "bones_synchronize(#{sync});"+NL
|
116
|
-
|
117
|
-
# Found a copyin marker
|
118
|
-
elsif @scheduler && line =~ /^#{WHITESPACE}#{COPYIN}/
|
119
|
-
copies = line.strip.scan(/^#{WHITESPACE}#{COPYIN} (.+)/).join.split(WEDGE).map{ |c| c.strip }
|
120
|
-
copies.each_with_index do |copy,copynum|
|
121
|
-
name = copy.split('[').first
|
122
|
-
domain = copy.scan(/\[(.+)\]/).join.split(DIM_SEP)
|
123
|
-
deadline = copy.split('|').last
|
124
|
-
@copies.push(Bones::Copy.new(name,domain,deadline,'in',"#{index*100+copynum}"))
|
125
|
-
@target_code << "bones_copyin_#{index*100+copynum}_#{name}(#{name});"+NL
|
77
|
+
|
78
|
+
# Don't consider one-line comments
|
79
|
+
if !(line =~ /^#{WHITESPACE}\/\//)
|
80
|
+
|
81
|
+
# Found the start of a block comment
|
82
|
+
if line =~ /\/\*/
|
83
|
+
block_comment = true
|
84
|
+
end
|
85
|
+
|
86
|
+
# Search for the end of the block comment
|
87
|
+
if block_comment
|
88
|
+
if line =~ /\*\//
|
89
|
+
block_comment = false
|
126
90
|
end
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
91
|
+
@target_code << line
|
92
|
+
|
93
|
+
# Not in a block-comment
|
94
|
+
else
|
95
|
+
|
96
|
+
if line =~ /^#{WHITESPACE}#/
|
97
|
+
|
98
|
+
# Keep 'include' statements as header code
|
99
|
+
if line =~ /^#{WHITESPACE}#include/
|
100
|
+
@header_code += line
|
101
|
+
if line =~ /"(.*)"/
|
102
|
+
process_header($1)
|
103
|
+
end
|
104
|
+
|
105
|
+
# Process 'define' statements for the algorithm code, but also keep as header code
|
106
|
+
elsif line =~ /^#{WHITESPACE}#define/
|
107
|
+
@header_code += line
|
108
|
+
@device_header += line
|
109
|
+
match = line.split(/\/\//)[0].scan(/^#{WHITESPACE}#define\s+(\w+)\s+(\S*)/)
|
110
|
+
@defines[match.first[0].to_sym] = match.first[1]
|
111
|
+
|
112
|
+
# Found the start of algorithm marker
|
113
|
+
elsif line =~ /^#{WHITESPACE}#{SPECIES_START}/
|
114
|
+
if found == 0
|
115
|
+
line = replace_defines(line,@defines)
|
116
|
+
prefix, input, output = marker_to_algorithm(line)
|
117
|
+
puts MESSAGE+'Found algorithm "'+(prefix+' '+input+' '+ARROW+' '+output).lstrip+'"' if VERBOSE
|
118
|
+
species = Bones::Species.new(prefix,input,output)
|
119
|
+
@found_algorithms = @found_algorithms + 1
|
120
|
+
end
|
121
|
+
found = found + 1
|
122
|
+
#@target_code << "int bones_temp_species_start = '#{line.gsub(NL,'')}';"+NL
|
123
|
+
|
124
|
+
# Found the end of algorithm marker
|
125
|
+
elsif line =~ /^#{WHITESPACE}#{SPECIES_END}/
|
126
|
+
if found == 1
|
127
|
+
name = line.strip.scan(/^#{WHITESPACE}#{SPECIES_END} (.+)/).join
|
128
|
+
name = DEFAULT_NAME if name == ''
|
129
|
+
@algorithms.push(Bones::Algorithm.new(name,@filename,index.to_s,species,algorithm_code))
|
130
|
+
algorithm_code = ''
|
131
|
+
end
|
132
|
+
found = found - 1
|
133
|
+
#@target_code << "int bones_temp_species_end = '#{line.gsub(NL,'')}';"+NL
|
134
|
+
|
135
|
+
# Found a sync marker
|
136
|
+
elsif @scheduler && line =~ /^#{WHITESPACE}#{SYNC}/
|
137
|
+
sync = line.strip.scan(/^#{WHITESPACE}#{SYNC} (.+)/).join
|
138
|
+
@target_code << "bones_synchronize(#{sync});"+NL
|
139
|
+
|
140
|
+
# Found a copyin marker
|
141
|
+
elsif @scheduler && line =~ /^#{WHITESPACE}#{COPYIN}/
|
142
|
+
copies = line.strip.scan(/^#{WHITESPACE}#{COPYIN} (.+)/).join.split(WEDGE).map{ |c| c.strip }
|
143
|
+
copies.each_with_index do |copy,copynum|
|
144
|
+
name = copy.split('[').first
|
145
|
+
domain = copy.scan(/\[(.+)\]/).join.split(DIM_SEP)
|
146
|
+
deadline = copy.split('|').last
|
147
|
+
@copies.push(Bones::Copy.new(scop,name,domain,deadline,'in',"#{index*100+copynum}"))
|
148
|
+
scop_copies.push(@copies[-1])
|
149
|
+
@target_code << "bones_copyin_#{index*100+copynum}_#{name}(#{name});"+NL
|
150
|
+
end
|
151
|
+
|
152
|
+
# Found a copyout marker
|
153
|
+
elsif @scheduler && line =~ /^#{WHITESPACE}#{COPYOUT}/
|
154
|
+
copies = line.strip.scan(/^#{WHITESPACE}#{COPYOUT} (.+)/).join.split(WEDGE).map{ |c| c.strip }
|
155
|
+
copies.each_with_index do |copy,copynum|
|
156
|
+
name = copy.split('[').first
|
157
|
+
domain = copy.scan(/\[(.+)\]/).join.split(DIM_SEP)
|
158
|
+
deadline = copy.split('|').last
|
159
|
+
@copies.push(Bones::Copy.new(scop,name,domain,deadline,'out',"#{index*100+copynum}"))
|
160
|
+
scop_copies.push(@copies[-1])
|
161
|
+
@target_code << "bones_copyout_#{index*100+copynum}_#{name}(#{name});"+NL
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
# Check if it was a 'pragma scop' / 'pragma endscop' line
|
166
|
+
if line =~ /^#{WHITESPACE}#{SCOP_START}/
|
167
|
+
scop += 1
|
168
|
+
scop_copies = []
|
169
|
+
alloc_index = @target_code.length
|
170
|
+
a_scop_was_found = true
|
171
|
+
@target_code << 'bones_timer_start();'+NL
|
172
|
+
elsif line =~ /^#{WHITESPACE}#{SCOP_END}/
|
173
|
+
free_index = @target_code.length
|
174
|
+
@target_code << 'bones_timer_stop();'+NL
|
175
|
+
|
176
|
+
# Add frees and mallocs
|
177
|
+
if @scheduler
|
178
|
+
alloc_code, free_code = '', ''
|
179
|
+
included_copies = []
|
180
|
+
scop_copies.each do |copy|
|
181
|
+
if !included_copies.include?(copy.name)
|
182
|
+
alloc_code += copy.get_function_call('alloc')+NL
|
183
|
+
free_code += copy.get_function_call('free')+NL
|
184
|
+
included_copies << copy.name
|
185
|
+
end
|
186
|
+
end
|
187
|
+
@target_code.insert(alloc_index, alloc_code)
|
188
|
+
@target_code << free_code
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
else
|
193
|
+
if found > 0
|
194
|
+
algorithm_line = replace_defines(line,@defines)
|
195
|
+
@target_code << algorithm_line
|
196
|
+
algorithm_code += algorithm_line if line !~ /^#{WHITESPACE}#/
|
197
|
+
else
|
198
|
+
@target_code << line
|
199
|
+
end
|
137
200
|
end
|
138
201
|
end
|
139
|
-
|
140
|
-
# Check if it was a 'pragma scop' / 'pragma endscop' line
|
141
|
-
if line =~ /^#{WHITESPACE}#{SCOP_START}/
|
142
|
-
alloc_index = index
|
143
|
-
elsif line =~ /^#{WHITESPACE}#{SCOP_END}/
|
144
|
-
free_index = @target_code.length
|
145
|
-
end
|
146
|
-
|
147
202
|
else
|
148
|
-
|
149
|
-
algorithm_line = replace_defines(line,@defines)
|
150
|
-
@target_code << algorithm_line
|
151
|
-
algorithm_code += algorithm_line if line !~ /^#{WHITESPACE}#/
|
152
|
-
else
|
153
|
-
@target_code << line
|
154
|
-
end
|
203
|
+
@target_code << line
|
155
204
|
end
|
156
205
|
end
|
157
206
|
puts WARNING+'Begin/end kernel mismatch ('+@found_algorithms.to_s+' versus '+@algorithms.length.to_s+'), probably missing a "'+SPECIES_END+'"' unless @algorithms.length == @found_algorithms
|
158
207
|
|
159
|
-
#
|
160
|
-
if
|
161
|
-
|
162
|
-
included_copies = []
|
163
|
-
copies.each do |copy|
|
164
|
-
if !included_copies.include?(copy.name)
|
165
|
-
alloc_code += copy.get_function_call('alloc')+NL
|
166
|
-
free_code += copy.get_function_call('free')+NL
|
167
|
-
included_copies << copy.name
|
168
|
-
end
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
# Add timers (whole scop timing) and frees/mallocs to the code
|
173
|
-
offset = @header_code.lines.count
|
174
|
-
@target_code.insert(alloc_index-offset, 'bones_timer_start();'+NL)
|
175
|
-
if @scheduler
|
176
|
-
@target_code.insert(alloc_index-offset+1, alloc_code)
|
177
|
-
@target_code.insert(free_index+2, free_code)
|
178
|
-
@target_code.insert(free_index+3, 'bones_timer_stop();'+NL)
|
179
|
-
else
|
180
|
-
@target_code.insert(free_index+2, 'bones_timer_stop();'+NL)
|
208
|
+
# Print warning if there is no SCoP found
|
209
|
+
if !a_scop_was_found
|
210
|
+
puts WARNING+'No "#pragma scop" and "#pragma endscop" found!'
|
181
211
|
end
|
182
212
|
|
183
213
|
# Join the array
|
@@ -191,28 +221,48 @@ module Bones
|
|
191
221
|
ifdefs = [true]
|
192
222
|
|
193
223
|
# Process the file line by line
|
224
|
+
block_comment = false
|
194
225
|
File.read(File.join(@directory,filename)).each_line.with_index do |line,index|
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
226
|
+
|
227
|
+
# Don't consider one-line comments
|
228
|
+
if !(line =~ /^#{WHITESPACE}\/\//)
|
229
|
+
|
230
|
+
# Found the start of a block comment
|
231
|
+
if line =~ /\/\*/
|
232
|
+
block_comment = true
|
233
|
+
end
|
234
|
+
|
235
|
+
# Search for the end of the block comment
|
236
|
+
if block_comment
|
237
|
+
if line =~ /\*\//
|
238
|
+
block_comment = false
|
239
|
+
end
|
240
|
+
|
241
|
+
# Not in a block-comment
|
242
|
+
else
|
243
|
+
if line =~ /^#{WHITESPACE}#/
|
244
|
+
|
245
|
+
# Process 'include' statements
|
246
|
+
if line =~ /^#{WHITESPACE}#include/ && ifdefs.last
|
247
|
+
if line =~ /"(.*)"/
|
248
|
+
process_header($1)
|
249
|
+
end
|
250
|
+
|
251
|
+
# Process 'define' statements
|
252
|
+
elsif line =~ /^#{WHITESPACE}#define/ && ifdefs.last
|
253
|
+
match = line.split(/\/\//)[0].scan(/^#{WHITESPACE}#define\s+(\w+)\s+(\S*)/)
|
254
|
+
@defines[match.first[0].to_sym] = match.first[1].strip
|
255
|
+
|
256
|
+
# Process 'ifdef' statements
|
257
|
+
elsif line =~ /^#{WHITESPACE}#ifdef#{WHITESPACE}(\w+)/
|
258
|
+
valid = (ifdefs.last) ? @defines.has_key?($1.to_sym) : false
|
259
|
+
ifdefs.push(valid)
|
260
|
+
|
261
|
+
# Process 'endif' statements
|
262
|
+
elsif line =~ /^#{WHITESPACE}#endif/
|
263
|
+
ifdefs.pop
|
264
|
+
end
|
201
265
|
end
|
202
|
-
|
203
|
-
# Process 'define' statements
|
204
|
-
elsif line =~ /^#{WHITESPACE}#define/ && ifdefs.last
|
205
|
-
match = line.split(/\/\//)[0].scan(/^#{WHITESPACE}#define\s+(\w+)\s+(\S*)/)
|
206
|
-
@defines[match.first[0].to_sym] = match.first[1].strip
|
207
|
-
|
208
|
-
# Process 'ifdef' statements
|
209
|
-
elsif line =~ /^#{WHITESPACE}#ifdef#{WHITESPACE}(\w+)/
|
210
|
-
valid = (ifdefs.last) ? @defines.has_key?($1.to_sym) : false
|
211
|
-
ifdefs.push(valid)
|
212
|
-
|
213
|
-
# Process 'endif' statements
|
214
|
-
elsif line =~ /^#{WHITESPACE}#endif/
|
215
|
-
ifdefs.pop
|
216
266
|
end
|
217
267
|
end
|
218
268
|
end
|