BOAST 1.2.2 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/BOAST.gemspec +2 -2
- data/lib/BOAST.rb +1 -0
- data/lib/BOAST/Language/Algorithm.rb +68 -30
- data/lib/BOAST/Language/Annotation.rb +1 -0
- data/lib/BOAST/Language/Architectures.rb +1 -0
- data/lib/BOAST/Language/Arithmetic.rb +15 -9
- data/lib/BOAST/Language/BOAST_OpenCL.rb +94 -87
- data/lib/BOAST/Language/CPUID_by_name.rb +1 -0
- data/lib/BOAST/Language/Case.rb +6 -0
- data/lib/BOAST/Language/CodeBlock.rb +1 -0
- data/lib/BOAST/Language/Comment.rb +14 -11
- data/lib/BOAST/Language/Config.rb +23 -15
- data/lib/BOAST/Language/ControlStructure.rb +10 -2
- data/lib/BOAST/Language/DataTypes.rb +23 -15
- data/lib/BOAST/Language/Expression.rb +3 -0
- data/lib/BOAST/Language/For.rb +31 -26
- data/lib/BOAST/Language/FuncCall.rb +7 -0
- data/lib/BOAST/Language/Functors.rb +56 -19
- data/lib/BOAST/Language/If.rb +3 -0
- data/lib/BOAST/Language/Index.rb +11 -9
- data/lib/BOAST/Language/Intrinsics.rb +2 -0
- data/lib/BOAST/Language/OpenMP.rb +57 -40
- data/lib/BOAST/Language/Operators.rb +27 -19
- data/lib/BOAST/Language/Pragma.rb +1 -0
- data/lib/BOAST/Language/Print.rb +3 -0
- data/lib/BOAST/Language/Procedure.rb +81 -76
- data/lib/BOAST/Language/Slice.rb +16 -14
- data/lib/BOAST/Language/State.rb +126 -55
- data/lib/BOAST/Language/Transitions.rb +26 -26
- data/lib/BOAST/Language/Variable.rb +89 -58
- data/lib/BOAST/Language/While.rb +3 -0
- data/lib/BOAST/Runtime/AffinityProbe.rb +65 -0
- data/lib/BOAST/Runtime/CKernel.rb +44 -1
- data/lib/BOAST/Runtime/CRuntime.rb +3 -0
- data/lib/BOAST/Runtime/CUDARuntime.rb +3 -0
- data/lib/BOAST/Runtime/CompiledRuntime.rb +4 -0
- data/lib/BOAST/Runtime/Compilers.rb +6 -5
- data/lib/BOAST/Runtime/Config.rb +1 -1
- data/lib/BOAST/Runtime/FFIRuntime.rb +3 -0
- data/lib/BOAST/Runtime/FORTRANRuntime.rb +3 -0
- data/lib/BOAST/Runtime/MPPARuntime.rb +2 -0
- data/lib/BOAST/Runtime/NonRegression.rb +5 -3
- data/lib/BOAST/Runtime/OpenCLRuntime.rb +7 -10
- data/lib/BOAST/Runtime/Probe.rb +2 -0
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca2740cb851da646fa30581de14043280bd95ffe
|
4
|
+
data.tar.gz: edafed822810e02453fc6418cea1da470ad47c8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ae1bcaf2964999e45ba8ca1aab3642425f8c24dba9aff508106cf65d5b4baadd0709b3ef12349388dc6e8ea89ca6281de32df3a15bb29ebc87a1780291114da
|
7
|
+
data.tar.gz: b0b4d95e68c5395a9d9740f7f59c900babfa419b261cd000add8d5238899c3178d2953ea073d4721ba397e6cb6678e17e040e1e8e90c82bef02fb7716c941ab9
|
data/BOAST.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'BOAST'
|
3
|
-
s.version = "1.
|
3
|
+
s.version = "1.3.0"
|
4
4
|
s.author = "Brice Videau"
|
5
5
|
s.email = "brice.videau@imag.fr"
|
6
6
|
s.homepage = "https://github.com/Nanosim-LIG/boast"
|
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.required_ruby_version = '>= 1.9.3'
|
13
13
|
s.add_dependency 'narray', '~> 0.6.0', '>=0.6.0.8'
|
14
14
|
s.add_dependency 'narray_ffi', '~> 1.2', '>=1.2.0'
|
15
|
-
s.add_dependency 'opencl_ruby_ffi', '~> 1.
|
15
|
+
s.add_dependency 'opencl_ruby_ffi', '~> 1.3', '>=1.3.2'
|
16
16
|
s.add_dependency 'systemu', '~> 2', '>=2.2.0'
|
17
17
|
s.add_dependency 'os', '~> 0.9', '>=0.9.6'
|
18
18
|
s.add_dependency 'PAPI', '~> 0', '>=0.101'
|
data/lib/BOAST.rb
CHANGED
@@ -29,6 +29,7 @@ require 'BOAST/Language/While.rb'
|
|
29
29
|
require 'BOAST/Language/Pragma.rb'
|
30
30
|
require 'BOAST/Runtime/Config.rb'
|
31
31
|
require 'BOAST/Runtime/Probe.rb'
|
32
|
+
require 'BOAST/Runtime/AffinityProbe.rb'
|
32
33
|
require 'BOAST/Runtime/Compilers.rb'
|
33
34
|
require 'BOAST/Runtime/OpenCLRuntime.rb'
|
34
35
|
require 'BOAST/Runtime/CompiledRuntime.rb'
|
@@ -1,46 +1,57 @@
|
|
1
1
|
module BOAST
|
2
2
|
|
3
3
|
extend TypeTransition
|
4
|
+
|
5
|
+
EXTENDED.push TypeTransition
|
4
6
|
|
5
7
|
module PrivateStateAccessor
|
6
8
|
|
7
9
|
private
|
8
|
-
|
9
|
-
|
10
|
+
# (see BOAST#push_env)
|
11
|
+
def push_env(vars, &block)
|
12
|
+
BOAST::push_env(vars, &block)
|
10
13
|
end
|
11
14
|
|
12
|
-
|
13
|
-
|
15
|
+
# (see BOAST#pop_env)
|
16
|
+
def pop_env(*vars)
|
17
|
+
BOAST::pop_env(*vars)
|
14
18
|
end
|
15
19
|
|
16
|
-
|
17
|
-
|
20
|
+
# (see BOAST#increment_indent_level)
|
21
|
+
def increment_indent_level(increment = get_indent_increment)
|
22
|
+
BOAST::increment_indent_level(increment)
|
18
23
|
end
|
19
24
|
|
20
|
-
|
21
|
-
|
25
|
+
# (see BOAST#decrement_indent_level)
|
26
|
+
def decrement_indent_level(increment = get_indent_increment)
|
27
|
+
BOAST::decrement_indent_level(increment)
|
22
28
|
end
|
23
29
|
|
30
|
+
# (see BOAST#indent)
|
24
31
|
def indent
|
25
32
|
BOAST::indent
|
26
33
|
end
|
27
34
|
|
35
|
+
# (see BOAST#get_architecture_name)
|
28
36
|
def get_architecture_name
|
29
37
|
BOAST::get_architecture_name
|
30
38
|
end
|
31
39
|
|
40
|
+
# (see BOAST#get_lang_name)
|
32
41
|
def get_lang_name
|
33
42
|
BOAST::get_lang_name
|
34
43
|
end
|
35
44
|
|
36
|
-
|
37
|
-
|
45
|
+
# (see BOAST#annotate_number)
|
46
|
+
def annotate_number(name)
|
47
|
+
BOAST::annotate_number(name)
|
38
48
|
end
|
39
49
|
|
40
50
|
end
|
41
51
|
|
42
52
|
module_function
|
43
53
|
|
54
|
+
# Returns the symbol corresponding to the active architecture
|
44
55
|
def get_architecture_name
|
45
56
|
case architecture
|
46
57
|
when X86
|
@@ -54,6 +65,7 @@ module BOAST
|
|
54
65
|
end
|
55
66
|
end
|
56
67
|
|
68
|
+
# Returns the symbol corresponding to the active language
|
57
69
|
def get_lang_name
|
58
70
|
case lang
|
59
71
|
when C
|
@@ -76,7 +88,12 @@ module BOAST
|
|
76
88
|
|
77
89
|
@@env = Hash::new{|h, k| h[k] = []}
|
78
90
|
|
79
|
-
|
91
|
+
# Updates states and stores their value in a stack for later retrieval
|
92
|
+
# @overload push_env( vars )
|
93
|
+
# @overload push_env( vars, &block )
|
94
|
+
# @param [Hash] vars contains state symbols and values pairs
|
95
|
+
# @yield states will be popped after the given block is called
|
96
|
+
def push_env(vars, &block)
|
80
97
|
keys = []
|
81
98
|
vars.each { |key, value|
|
82
99
|
var = nil
|
@@ -99,6 +116,8 @@ module BOAST
|
|
99
116
|
end
|
100
117
|
end
|
101
118
|
|
119
|
+
# Pops the specified states values
|
120
|
+
# @param vars a list of state symbols
|
102
121
|
def pop_env(*vars)
|
103
122
|
vars.each { |key|
|
104
123
|
raise "Unknown module variable #{key}!" unless @@env.has_key?(key)
|
@@ -108,24 +127,35 @@ module BOAST
|
|
108
127
|
}
|
109
128
|
end
|
110
129
|
|
130
|
+
# Increments the indent level
|
131
|
+
# @param [Integer] increment number of space to add
|
111
132
|
def increment_indent_level(increment = get_indent_increment)
|
112
133
|
set_indent_level( get_indent_level + increment )
|
113
134
|
end
|
114
|
-
|
135
|
+
|
136
|
+
# Decrements the indent level
|
137
|
+
# @param [Integer] increment number of space to remove
|
115
138
|
def decrement_indent_level(increment = get_indent_increment)
|
116
139
|
set_indent_level( get_indent_level - increment )
|
117
140
|
end
|
118
141
|
|
142
|
+
# Returns a string with as many space as the indent level.
|
143
|
+
def indent
|
144
|
+
return " "*get_indent_level
|
145
|
+
end
|
146
|
+
|
147
|
+
# Returns an annotation number for the given name. The number
|
148
|
+
# is incremented for a given name is incremented each time this name is called
|
119
149
|
def annotate_number(name)
|
120
150
|
num = @@annotate_numbers[name]
|
121
151
|
@@annotate_numbers[name] = num + 1
|
122
152
|
return num
|
123
153
|
end
|
124
154
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
155
|
+
# Annotates an Object by inlining a YAML structure in a comment.
|
156
|
+
# If object's class is part of the annotate list an indepth version of the annotation
|
157
|
+
# will be generated.
|
158
|
+
# @param [Object] a object to annotate
|
129
159
|
def pr_annotate(a)
|
130
160
|
name = a.class.name.gsub("BOAST::","")
|
131
161
|
if annotate_list.include?(name) then
|
@@ -138,33 +168,38 @@ module BOAST
|
|
138
168
|
end
|
139
169
|
end
|
140
170
|
|
171
|
+
|
172
|
+
# One of BOAST keywords: prints BOAST objects.
|
173
|
+
# Annotates the given object.
|
174
|
+
# Calls the given object pr method with the optional arguments.
|
175
|
+
# @param a a BOAST Expression, ControlStructure or Procedure
|
176
|
+
# @param args an optional list of parameters
|
141
177
|
def pr(a, *args)
|
142
178
|
pr_annotate(a) if annotate?
|
143
179
|
a.pr(*args)
|
144
180
|
end
|
145
181
|
|
146
|
-
|
147
|
-
|
182
|
+
# One of BOAST keywords: declares BOAST Variables and Procedures.
|
183
|
+
# Calls the decl method of each given objects.
|
184
|
+
# @param list a list of parameters do declare
|
185
|
+
def decl(*list)
|
186
|
+
list.each { |d|
|
148
187
|
d.decl
|
149
188
|
}
|
150
189
|
end
|
151
190
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
191
|
+
# One of BOAST keywords: opens a BOAST ControlStructure or Procedure.
|
192
|
+
# Calls the open method of the given object.
|
193
|
+
# @param a the BOAST object to open
|
156
194
|
def opn(a)
|
157
195
|
a.open
|
158
196
|
end
|
159
197
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
alias :Var :Variable
|
166
|
-
alias :Dim :Dimension
|
167
|
-
alias :Call :FuncCall
|
198
|
+
# One of BOAST keywords: closes a BOAST ControlStructure or Procedure.
|
199
|
+
# Calls the close method of the given object.
|
200
|
+
# @param a the BOAST object to close
|
201
|
+
def close(a)
|
202
|
+
a.close
|
168
203
|
end
|
169
204
|
|
170
205
|
Var = Variable
|
@@ -184,6 +219,8 @@ end
|
|
184
219
|
ConvolutionGenerator = BOAST
|
185
220
|
|
186
221
|
class Integer
|
222
|
+
# Creates a constant BOAST Int Variable with a name corresponding to its value.
|
223
|
+
# The variable is signed only when negative.
|
187
224
|
def to_var
|
188
225
|
if self < 0 then
|
189
226
|
v = BOAST::Variable::new("#{self}", BOAST::Int, :signed => true, :constant => self )
|
@@ -196,6 +233,7 @@ class Integer
|
|
196
233
|
end
|
197
234
|
|
198
235
|
class Float
|
236
|
+
# Creates a constant BOAST Real Variable with a name corresponding to its value.
|
199
237
|
def to_var
|
200
238
|
v = BOAST::Variable::new("#{self}", BOAST::Real, :constant => self )
|
201
239
|
v.force_replace_constant = true
|
@@ -1,19 +1,25 @@
|
|
1
1
|
module BOAST
|
2
2
|
|
3
|
-
|
3
|
+
module TopLevelExpressions
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
def Return(value)
|
6
|
+
return Expression::new("return",nil, value)
|
7
|
+
end
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
def And(a, b)
|
10
|
+
return Expression::new(And, a, b)
|
11
|
+
end
|
12
|
+
|
13
|
+
def Or(a, b)
|
14
|
+
return Expression::new(Or, a, b)
|
15
|
+
end
|
12
16
|
|
13
|
-
def Or(a, b)
|
14
|
-
return Expression::new(Or, a, b)
|
15
17
|
end
|
16
18
|
|
19
|
+
extend TopLevelExpressions
|
20
|
+
|
21
|
+
EXTENDED.push TopLevelExpressions
|
22
|
+
|
17
23
|
module Arithmetic
|
18
24
|
|
19
25
|
def **(x)
|
@@ -1,112 +1,119 @@
|
|
1
1
|
module BOAST
|
2
2
|
|
3
|
-
|
3
|
+
module OpenCLHelper
|
4
4
|
|
5
|
-
|
6
|
-
CUDA_BLOCKIDX = CStruct("blockIdx",:type_name => "cuda_blockIdx", :members => [Int("x", :signed => false),Int("y", :signed => false),Int("z", :signed => false)])
|
7
|
-
CUDA_BLOCKDIM = CStruct("blockDim",:type_name => "cuda_blockDim", :members => [Int("x", :signed => false),Int("y", :signed => false),Int("z", :signed => false)])
|
8
|
-
CUDA_GRIDDIM = CStruct("gridDim",:type_name => "cuda_gridDim", :members => [Int("x", :signed => false),Int("y", :signed => false),Int("z", :signed => false)])
|
5
|
+
OCL_CUDA_DIM_ASSOC = { 0 => "x", 1 => "y", 2 => "z" }
|
9
6
|
|
10
|
-
|
7
|
+
CUDA_THREADIDX = BOAST::CStruct("threadIdx",:type_name => "cuda_trheadIdx", :members => [BOAST::Int("x", :signed => false),BOAST::Int("y", :signed => false),BOAST::Int("z", :signed => false)])
|
8
|
+
CUDA_BLOCKIDX = BOAST::CStruct("blockIdx",:type_name => "cuda_blockIdx", :members => [BOAST::Int("x", :signed => false),BOAST::Int("y", :signed => false),BOAST::Int("z", :signed => false)])
|
9
|
+
CUDA_BLOCKDIM = BOAST::CStruct("blockDim",:type_name => "cuda_blockDim", :members => [BOAST::Int("x", :signed => false),BOAST::Int("y", :signed => false),BOAST::Int("z", :signed => false)])
|
10
|
+
CUDA_GRIDDIM = BOAST::CStruct("gridDim",:type_name => "cuda_gridDim", :members => [BOAST::Int("x", :signed => false),BOAST::Int("y", :signed => false),BOAST::Int("z", :signed => false)])
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
if
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
12
|
+
private_constant :OCL_CUDA_DIM_ASSOC, :CUDA_THREADIDX, :CUDA_BLOCKIDX, :CUDA_BLOCKDIM, :CUDA_GRIDDIM
|
13
|
+
|
14
|
+
def barrier(*locality)
|
15
|
+
if lang == CL then
|
16
|
+
loc=""
|
17
|
+
if locality.include?(:local) and locality.include?(:global) then
|
18
|
+
return FuncCall::new("barrier","CLK_LOCAL_MEM_FENCE | CLK_GLOBAL_MEM_FENCE")
|
19
|
+
elsif locality.include?(:local) then
|
20
|
+
return FuncCall::new("barrier","CLK_LOCAL_MEM_FENCE")
|
21
|
+
elsif locality.include?(:global) then
|
22
|
+
return FuncCall::new("barrier","CLK_GLOBAL_MEM_FENCE")
|
23
|
+
else
|
24
|
+
raise "Unsupported locality"
|
25
|
+
end
|
26
|
+
elsif lang == CUDA then
|
27
|
+
return FuncCall::new("__syncthreads")
|
21
28
|
else
|
22
|
-
raise "Unsupported
|
29
|
+
raise "Unsupported language!"
|
23
30
|
end
|
24
|
-
elsif lang == CUDA then
|
25
|
-
return FuncCall::new("__syncthreads")
|
26
|
-
else
|
27
|
-
raise "Unsupported language!"
|
28
31
|
end
|
29
|
-
end
|
30
32
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
def get_work_dim
|
34
|
+
if lang == CL then
|
35
|
+
return FuncCall::new("get_work_dim", :returns => Int("wd", :signed => false))
|
36
|
+
else
|
37
|
+
raise "Unsupported language!"
|
38
|
+
end
|
37
39
|
end
|
38
|
-
end
|
39
40
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
41
|
+
def get_global_size(dim)
|
42
|
+
if lang == CL then
|
43
|
+
return FuncCall::new("get_global_size", dim, :returns => Sizet)
|
44
|
+
elsif lang == CUDA then
|
45
|
+
d = OCL_CUDA_DIM_ASSOC[dim]
|
46
|
+
raise "Unsupported dimension!" if not d
|
47
|
+
return eval "CUDA_GRIDDIM.#{d}*CUDA_BLOCKDIM.#{d}"
|
48
|
+
else
|
49
|
+
raise "Unsupported language!"
|
50
|
+
end
|
49
51
|
end
|
50
|
-
end
|
51
52
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
53
|
+
def get_global_id(dim)
|
54
|
+
if lang == CL then
|
55
|
+
return FuncCall::new("get_global_id",dim, :returns => Sizet)
|
56
|
+
elsif lang == CUDA then
|
57
|
+
d = OCL_CUDA_DIM_ASSOC[dim]
|
58
|
+
raise "Unsupported dimension!" if not d
|
59
|
+
return eval "CUDA_THREADIDX.#{d}+CUDA_BLOCKIDX.#{d}*CUDA_BLOCKDIM.#{d}"
|
60
|
+
else
|
61
|
+
raise "Unsupported language!"
|
62
|
+
end
|
61
63
|
end
|
62
|
-
end
|
63
64
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
65
|
+
def get_local_size(dim)
|
66
|
+
if lang == CL then
|
67
|
+
return FuncCall::new("get_local_size",dim, :returns => Sizet)
|
68
|
+
elsif lang == CUDA then
|
69
|
+
d = OCL_CUDA_DIM_ASSOC[dim]
|
70
|
+
raise "Unsupported dimension!" if not d
|
71
|
+
return eval "CUDA_BLOCKDIM.#{d}"
|
72
|
+
else
|
73
|
+
raise "Unsupported language!"
|
74
|
+
end
|
73
75
|
end
|
74
|
-
end
|
75
76
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
77
|
+
def get_local_id(dim)
|
78
|
+
if lang == CL then
|
79
|
+
return FuncCall::new("get_local_id",dim, :returns => Sizet)
|
80
|
+
elsif lang == CUDA then
|
81
|
+
d = OCL_CUDA_DIM_ASSOC[dim]
|
82
|
+
raise "Unsupported dimension!" if not d
|
83
|
+
return eval "CUDA_THREADIDX.#{d}"
|
84
|
+
else
|
85
|
+
raise "Unsupported language!"
|
86
|
+
end
|
85
87
|
end
|
86
|
-
end
|
87
88
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
89
|
+
def get_num_groups(dim)
|
90
|
+
if lang == CL then
|
91
|
+
return FuncCall::new("get_num_groups",dim, :returns => Sizet)
|
92
|
+
elsif lang == CUDA then
|
93
|
+
d = OCL_CUDA_DIM_ASSOC[dim]
|
94
|
+
raise "Unsupported dimension!" if not d
|
95
|
+
return eval "CUDA_GRIDDIM.#{d}"
|
96
|
+
else
|
97
|
+
raise "Unsupported language!"
|
98
|
+
end
|
97
99
|
end
|
98
|
-
end
|
99
100
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
101
|
+
def get_group_id(dim)
|
102
|
+
if lang == CL then
|
103
|
+
return FuncCall::new("get_group_id",dim, :returns => Sizet)
|
104
|
+
elsif lang == CUDA then
|
105
|
+
d = OCL_CUDA_DIM_ASSOC[dim]
|
106
|
+
raise "Unsupported dimension!" if not d
|
107
|
+
return eval "CUDA_BLOCKIDX.#{d}"
|
108
|
+
else
|
109
|
+
raise "Unsupported language!"
|
110
|
+
end
|
109
111
|
end
|
112
|
+
|
110
113
|
end
|
111
114
|
|
115
|
+
extend OpenCLHelper
|
116
|
+
|
117
|
+
EXTENDED.push OpenCLHelper
|
118
|
+
|
112
119
|
end
|