BOAST 2.0.2 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/BOAST.gemspec +4 -3
  3. data/lib/BOAST.rb +1 -0
  4. data/lib/BOAST/Language/Arithmetic.rb +5 -1
  5. data/lib/BOAST/Language/BOAST_OpenCL.rb +6 -6
  6. data/lib/BOAST/Language/Case.rb +11 -11
  7. data/lib/BOAST/Language/Comment.rb +2 -2
  8. data/lib/BOAST/Language/Config.rb +5 -5
  9. data/lib/BOAST/Language/DataTypes.rb +31 -29
  10. data/lib/BOAST/Language/Expression.rb +16 -16
  11. data/lib/BOAST/Language/For.rb +6 -6
  12. data/lib/BOAST/Language/FuncCall.rb +7 -7
  13. data/lib/BOAST/Language/HighLevelOperators.rb +6 -6
  14. data/lib/BOAST/Language/If.rb +7 -7
  15. data/lib/BOAST/Language/Index.rb +31 -31
  16. data/lib/BOAST/Language/Intrinsics.rb +27 -27
  17. data/lib/BOAST/Language/OpenMP.rb +19 -19
  18. data/lib/BOAST/Language/Operators.rb +62 -50
  19. data/lib/BOAST/Language/Pragma.rb +4 -4
  20. data/lib/BOAST/Language/Procedure.rb +47 -47
  21. data/lib/BOAST/Language/Slice.rb +14 -14
  22. data/lib/BOAST/Language/State.rb +1 -1
  23. data/lib/BOAST/Language/Transitions.rb +1 -1
  24. data/lib/BOAST/Language/Variable.rb +83 -90
  25. data/lib/BOAST/Language/While.rb +4 -4
  26. data/lib/BOAST/Optimization/Optimization.rb +61 -37
  27. data/lib/BOAST/Runtime/AffinityProbe.rb +99 -15
  28. data/lib/BOAST/Runtime/CRuntime.rb +18 -6
  29. data/lib/BOAST/Runtime/CUDARuntime.rb +11 -7
  30. data/lib/BOAST/Runtime/CoExecute.rb +77 -0
  31. data/lib/BOAST/Runtime/CompiledRuntime.rb +274 -110
  32. data/lib/BOAST/Runtime/Compilers.rb +15 -15
  33. data/lib/BOAST/Runtime/Config.rb +3 -0
  34. data/lib/BOAST/Runtime/EnergyProbe.rb +86 -71
  35. data/lib/BOAST/Runtime/FFIRuntime.rb +1 -1
  36. data/lib/BOAST/Runtime/FORTRANRuntime.rb +15 -5
  37. data/lib/BOAST/Runtime/MPPARuntime.rb +30 -19
  38. data/lib/BOAST/Runtime/OpenCLRuntime.rb +2 -2
  39. data/lib/BOAST/Runtime/Probe.rb +122 -41
  40. metadata +29 -8
@@ -47,23 +47,23 @@ module BOAST
47
47
 
48
48
  def to_s_fortran
49
49
  s = ""
50
- s += @prefix if @prefix
51
- s += "#{func_name}(#{@args.collect(&:to_s).join(", ")})"
50
+ s << @prefix if @prefix
51
+ s << "#{func_name}(#{@args.collect(&:to_s).join(", ")})"
52
52
  end
53
53
 
54
54
  def to_s_c
55
55
  s = ""
56
- s += @prefix if @prefix
57
- s += "#{func_name}(#{@args.collect(&:to_s).join(", ")})"
56
+ s << @prefix if @prefix
57
+ s << "#{func_name}(#{@args.collect(&:to_s).join(", ")})"
58
58
  end
59
59
 
60
60
  private :to_s_fortran, :to_s_c
61
61
 
62
62
  def pr
63
63
  s=""
64
- s += indent
65
- s += to_s
66
- s += ";" if [C, CL, CUDA].include?( lang )
64
+ s << indent
65
+ s << to_s
66
+ s << ";" if [C, CL, CUDA].include?( lang )
67
67
  output.puts s
68
68
  return self
69
69
  end
@@ -68,9 +68,9 @@ module BOAST
68
68
 
69
69
  def pr
70
70
  s=""
71
- s += indent
72
- s += to_s
73
- s += ";" if [C, CL, CUDA].include?( lang )
71
+ s << indent
72
+ s << to_s
73
+ s << ";" if [C, CL, CUDA].include?( lang )
74
74
  output.puts s
75
75
  return self
76
76
  end
@@ -126,9 +126,9 @@ module BOAST
126
126
 
127
127
  def pr
128
128
  s=""
129
- s += indent
130
- s += to_s
131
- s += ";" if [C, CL, CUDA].include?( lang )
129
+ s << indent
130
+ s << to_s
131
+ s << ";" if [C, CL, CUDA].include?( lang )
132
132
  output.puts s
133
133
  return self
134
134
  end
@@ -61,12 +61,12 @@ module BOAST
61
61
  def to_s(condition_number = 0)
62
62
  s = ""
63
63
  if condition_number == 0 then
64
- s += if_string(@conditions.first)
64
+ s << if_string(@conditions.first)
65
65
  else
66
66
  if @conditions[condition_number] then
67
- s += elsif_string(@conditions[condition_number])
67
+ s << elsif_string(@conditions[condition_number])
68
68
  else
69
- s += else_string
69
+ s << else_string
70
70
  end
71
71
  end
72
72
  return s
@@ -78,8 +78,8 @@ module BOAST
78
78
  def open(condition_number = 0)
79
79
  decrement_indent_level if condition_number > 0
80
80
  s = ""
81
- s += indent
82
- s += to_s(condition_number)
81
+ s << indent
82
+ s << to_s(condition_number)
83
83
  output.puts s
84
84
  increment_indent_level
85
85
  return self
@@ -108,8 +108,8 @@ module BOAST
108
108
  def close
109
109
  decrement_indent_level
110
110
  s = ""
111
- s += indent
112
- s += end_string
111
+ s << indent
112
+ s << end_string
113
113
  output.puts s
114
114
  return self
115
115
  end
@@ -8,7 +8,7 @@ module BOAST
8
8
 
9
9
  def method_missing(m, *a, &b)
10
10
  var = to_var
11
- if var.type.methods.include?(:members) and var.type.members[m.to_s] then
11
+ if var.type.kind_of?(CStruct) and var.type.members[m.to_s] then
12
12
  return struct_reference(type.members[m.to_s])
13
13
  elsif var.vector? and m.to_s[0] == 's' and lang != CUDA then
14
14
  required_set = m.to_s[1..-1].chars.to_a
@@ -32,7 +32,7 @@ module BOAST
32
32
  end
33
33
 
34
34
  def align?
35
- return !!@alignment
35
+ return @alignment
36
36
  end
37
37
 
38
38
  def set_align(align)
@@ -68,7 +68,7 @@ module BOAST
68
68
  (0...dims.length).each { |indx|
69
69
  dim = dims[indx]
70
70
  s = "#{indxs[indx]}"
71
- s += " - (#{dim.start})" unless 0.equal?(dim.start)
71
+ s << " - (#{dim.start})" unless 0.equal?(dim.start)
72
72
  ind = Empty.empty_binding.eval(s)
73
73
  ind = ind.to_i
74
74
  const = const[ind]
@@ -83,9 +83,9 @@ module BOAST
83
83
 
84
84
  def pr
85
85
  s=""
86
- s += indent
87
- s += to_s
88
- s += ";" if [C, CL, CUDA].include?( lang )
86
+ s << indent
87
+ s << to_s
88
+ s << ";" if [C, CL, CUDA].include?( lang )
89
89
  output.puts s
90
90
  return self
91
91
  end
@@ -102,13 +102,13 @@ module BOAST
102
102
  end
103
103
  }
104
104
  s = ""
105
- s += "#{@source}(#{@source.vector? ? (@vector_index ? "#{@vector_index+1}, " : ":, ") : "" }#{indexes_dup.join(", ")})"
105
+ s << "#{@source}(#{@source.vector? ? (@vector_index ? "#{@vector_index+1}, " : ":, ") : "" }#{indexes_dup.join(", ")})"
106
106
  return s
107
107
  end
108
108
 
109
109
  def to_s_texture
110
- raise LanguageError, "Unsupported language #{lang} for texture!" if not [CL, CUDA].include?( lang )
111
- raise "Write is unsupported for textures!" if not ( @source.constant or @source.direction == :in )
110
+ raise LanguageError, "Unsupported language #{lang} for texture!" unless [CL, CUDA].include?( lang )
111
+ raise "Write is unsupported for textures!" unless ( @source.constant or @source.direction == :in )
112
112
  dim_number = 1
113
113
  if @source.dimension then
114
114
  dim_number == @source.dimension.size
@@ -116,38 +116,38 @@ module BOAST
116
116
  raise "Unsupported number of dimension: #{dim_number}!" if dim_number > 3
117
117
  s = ""
118
118
  if lang == CL then
119
- s += "as_#{@source.type.decl}("
120
- s += "read_imageui(#{@source}, #{@source.sampler}, "
119
+ s << "as_#{@source.type.decl}("
120
+ s << "read_imageui(#{@source}, #{@source.sampler}, "
121
121
  if dim_number == 1 then
122
- s += "int2(#{@indexes[0]},0)"
122
+ s << "int2(#{@indexes[0]},0)"
123
123
  else
124
124
  if dim_number == 2 then
125
- s += "int2("
125
+ s << "int2("
126
126
  else
127
- s += "int3("
127
+ s << "int3("
128
128
  end
129
- s += "#{@indexes.join(", ")})"
129
+ s << "#{@indexes.join(", ")})"
130
130
  end
131
- s += ")"
131
+ s << ")"
132
132
  if @source.type.size == 4 then
133
- s += ".x"
133
+ s << ".x"
134
134
  elsif @source.type.size == 8 then
135
- s += ".xy"
135
+ s << ".xy"
136
136
  end
137
- s += ")"
137
+ s << ")"
138
138
  else
139
- s += "tex#{dim_number}Dfetch(#{@source},"
139
+ s << "tex#{dim_number}Dfetch(#{@source},"
140
140
  if dim_number == 1 then
141
- s += "#{@indexes[0]}"
141
+ s << "#{@indexes[0]}"
142
142
  else
143
143
  if dim_number == 2 then
144
- s += "int2("
144
+ s << "int2("
145
145
  else
146
- s += "int3("
146
+ s << "int3("
147
147
  end
148
- s += "#{@indexes.join(", ")})"
148
+ s << "#{@indexes.join(", ")})"
149
149
  end
150
- s += ")"
150
+ s << ")"
151
151
  end
152
152
  return s
153
153
  end
@@ -158,7 +158,7 @@ module BOAST
158
158
  t = (0...dims.length).collect { |indx|
159
159
  s = "#{indxs[indx]}"
160
160
  dim = dims[indx]
161
- s += " - (#{dim.start})" unless 0.equal?(dim.start)
161
+ s << " - (#{dim.start})" unless 0.equal?(dim.start)
162
162
  s
163
163
  }
164
164
  return t.join("][")
@@ -171,15 +171,15 @@ module BOAST
171
171
  (0...dims.length).each { |indx|
172
172
  s = ""
173
173
  dim = dims[indx]
174
- s += "#{indxs[indx]}"
175
- s += " - (#{dim.start})" unless 0.equal?(dim.start)
174
+ s << "#{indxs[indx]}"
175
+ s << " - (#{dim.start})" unless 0.equal?(dim.start)
176
176
  if ss then
177
177
  if dim.size then
178
- s += " + (#{dim.size}) * "
178
+ s << " + (#{dim.size}) * "
179
179
  else
180
180
  raise "Unkwown dimension size!"
181
181
  end
182
- s += "(#{ss})"
182
+ s << "(#{ss})"
183
183
  end
184
184
  ss = s
185
185
  }
@@ -195,7 +195,7 @@ module BOAST
195
195
  end
196
196
  s = "#{@source}[" + sub + "]"
197
197
  if @vector_index then
198
- s += "[#{@vector_index}]"
198
+ s << "[#{@vector_index}]"
199
199
  end
200
200
  return s
201
201
  end
@@ -79,14 +79,14 @@ module BOAST
79
79
  end
80
80
  }
81
81
  # supported = (INSTRUCTIONS[instruction.to_s] & MODELS[get_model.to_s]).size > 0
82
- if not supported then
82
+ unless supported then
83
83
  required = ""
84
84
  INSTRUCTIONS[get_architecture][instruction.to_s].each { |cpuid|
85
- required += " or " if required != ""
85
+ required << " or " if required != ""
86
86
  if cpuid.kind_of?( Array ) then
87
- required += "( #{cpuid.join(" and ")} )"
87
+ required << "( #{cpuid.join(" and ")} )"
88
88
  else
89
- required += "#{cpuid}"
89
+ required << "#{cpuid}"
90
90
  end
91
91
  }
92
92
  raise IntrinsicsError, "Unsupported operation #{intr_symbol} for #{type}#{type2 ? " and #{type2}" : ""} on #{get_model}! (requires #{required})"
@@ -116,10 +116,10 @@ module BOAST
116
116
  case data_type
117
117
  when Int
118
118
  raise IntrinsicsError, "Unsupported data size for int vector on X86: #{data_type.size*8}!" unless [1,2,4,8].include?( data_type.size )
119
- return s+= "#{data_type.total_size*8>64 ? "i" : ""}"
119
+ return s << "#{data_type.total_size*8>64 ? "i" : ""}"
120
120
  when Real
121
121
  return s if data_type.size == 4
122
- return s += "d" if data_type.size == 8
122
+ return s << "d" if data_type.size == 8
123
123
  raise IntrinsicsError, "Unsupported data size for real vector on X86: #{data_type.size*8}!"
124
124
  else
125
125
  raise IntrinsicsError, "Unsupported data type #{data_type} for vector on X86!"
@@ -161,15 +161,15 @@ module BOAST
161
161
  s = ""
162
162
  case type
163
163
  when Int
164
- s += "u" unless type.signed?
165
- s += "int"
164
+ s << "u" unless type.signed?
165
+ s << "int"
166
166
  when Real
167
- s += "float"
167
+ s << "float"
168
168
  else
169
169
  raise InternalIntrinsicsError, "Undefined vector type!"
170
170
  end
171
- s += "#{type.size*8}"
172
- s += "x#{type.vector_length}_t"
171
+ s << "#{type.size*8}"
172
+ s << "x#{type.vector_length}_t"
173
173
  return s.to_sym
174
174
  end
175
175
 
@@ -181,19 +181,19 @@ module BOAST
181
181
  when :int
182
182
  case sign
183
183
  when :signed
184
- s += "int"
184
+ s << "int"
185
185
  when :unsigned
186
- s += "uint"
186
+ s << "uint"
187
187
  else
188
188
  raise InternalIntrinsicsError, "Invalid sign!"
189
189
  end
190
190
  when :float
191
- s += "float"
191
+ s << "float"
192
192
  else
193
193
  raise InternalIntrinsicsError, "Invalid type!"
194
194
  end
195
- s += "#{size}"
196
- s += "x#{vector_size/size}_t"
195
+ s << "#{size}"
196
+ s << "x#{vector_size/size}_t"
197
197
  return s.to_sym
198
198
  end
199
199
 
@@ -205,18 +205,18 @@ module BOAST
205
205
  when :int
206
206
  case sign
207
207
  when :signed
208
- s += "s"
208
+ s << "s"
209
209
  when :unsigned
210
- s += "u"
210
+ s << "u"
211
211
  else
212
212
  raise InternalIntrinsicsError, "Invalid sign!"
213
213
  end
214
214
  when :float
215
- s += "f"
215
+ s << "f"
216
216
  else
217
217
  raise InternalIntrinsicsError, "Invalid type!"
218
218
  end
219
- s += "#{size}"
219
+ s << "#{size}"
220
220
  return s
221
221
  end
222
222
 
@@ -227,23 +227,23 @@ module BOAST
227
227
  case type
228
228
  when :int
229
229
  e = ( vector_size > 64 ? "e" : "" )
230
- s += "#{e}p"
230
+ s << "#{e}p"
231
231
  case sign
232
232
  when :signed
233
- s += "i"
233
+ s << "i"
234
234
  when :unsigned
235
- s += "u"
235
+ s << "u"
236
236
  else
237
237
  raise InternalIntrinsicsError, "Invalid sign!"
238
238
  end
239
- s += "#{size}"
239
+ s << "#{size}"
240
240
  when :float
241
- s += "p"
241
+ s << "p"
242
242
  case size
243
243
  when 32
244
- s += "s"
244
+ s << "s"
245
245
  when 64
246
- s += "d"
246
+ s << "d"
247
247
  else
248
248
  raise InternalIntrinsicsError, "Invalid size!"
249
249
  end
@@ -7,9 +7,9 @@ module BOAST
7
7
  def openmp_pragma_to_s
8
8
  s = ""
9
9
  if lang == FORTRAN then
10
- s += "!$omp"
10
+ s << "!$omp"
11
11
  elsif lang == C then
12
- s += "#pragma omp"
12
+ s << "#pragma omp"
13
13
  else
14
14
  raise LanguageError, "Language does not support OpenMP!"
15
15
  end
@@ -23,37 +23,37 @@ module BOAST
23
23
  EOF
24
24
  case arg_type
25
25
  when :none
26
- s += <<EOF
26
+ s << <<EOF
27
27
  return " #{name}"
28
28
  EOF
29
29
  when :option
30
- s += <<EOF
30
+ s << <<EOF
31
31
  return " \#{c}"
32
32
  EOF
33
33
  when :option_list
34
- s += <<EOF
34
+ s << <<EOF
35
35
  return " (\#{[c].flatten.collect(&:to_s).join(", ")})"
36
36
  EOF
37
37
  when :simple
38
- s += <<EOF
38
+ s << <<EOF
39
39
  return " #{name}(\#{c})"
40
40
  EOF
41
41
  when :list
42
- s += <<EOF
42
+ s << <<EOF
43
43
  return " #{name}(\#{[c].flatten.collect(&:to_s).join(", ")})"
44
44
  EOF
45
45
  when :multilist
46
- s += <<EOF
46
+ s << <<EOF
47
47
  s = ""
48
48
  c.each { |id, list|
49
- s += " #{name}(\#{id}: \#{[list].flatten.collect(&:to_s).join(", ")})"
49
+ s << " #{name}(\#{id}: \#{[list].flatten.collect(&:to_s).join(", ")})"
50
50
  }
51
51
  return s
52
52
  EOF
53
53
  else
54
54
  raise "Unknown argument type!"
55
55
  end
56
- s += <<EOF
56
+ s << <<EOF
57
57
  end
58
58
  EOF
59
59
  eval s
@@ -96,11 +96,11 @@ EOF
96
96
  def openmp_open_clauses_to_s
97
97
  s = ""
98
98
  get_open_clauses.each { |c|
99
- s += self.send( "openmp_clause_#{c}", @openmp_clauses[c] ) if @openmp_clauses[c]
99
+ s << self.send( "openmp_clause_#{c}", @openmp_clauses[c] ) if @openmp_clauses[c]
100
100
  }
101
101
  if lang == C then
102
102
  get_end_clauses.each { |c|
103
- s += self.send( c, @openmp_clauses[c] ) if @openmp_clauses[c]
103
+ s << self.send( c, @openmp_clauses[c] ) if @openmp_clauses[c]
104
104
  }
105
105
  end
106
106
  return s
@@ -110,7 +110,7 @@ EOF
110
110
  s = ""
111
111
  if lang == FORTRAN then
112
112
  get_end_clauses.each { |c|
113
- s += self.send( c, @openmp_clauses[c] ) if @openmp_clauses[c]
113
+ s << self.send( c, @openmp_clauses[c] ) if @openmp_clauses[c]
114
114
  }
115
115
  end
116
116
  return s
@@ -206,30 +206,30 @@ EOF
206
206
  return { :begin => '"#pragma omp #{c_name} #{ open_clauses.length + end_clauses.length > 0 ? "\#{c}" : "" }#{ options[:block] ? "\\n{" : "" }"',
207
207
  EOF
208
208
  if options[:c_end] then
209
- s += <<EOF
209
+ s << <<EOF
210
210
  :end => '"#pragma omp end #{c_name}"' }
211
211
  EOF
212
212
  else
213
- s += <<EOF
213
+ s << <<EOF
214
214
  :end => '"#{ options[:block] ? "}" : "" }"' }
215
215
  EOF
216
216
  end
217
- s += <<EOF
217
+ s << <<EOF
218
218
  end
219
219
 
220
220
  def get_fortran_strings
221
221
  return { :begin => '"!$omp #{fortran_name}#{ open_clauses.length > 0 ? " \#{c}" : "" }#{ options[:fortran_block] ? "(" : "" }"',
222
222
  EOF
223
223
  if options[:fortran_no_end] then
224
- s += <<EOF
224
+ s << <<EOF
225
225
  :end => '"#{ options[:fortran_block] ? ")" : "" }"' }
226
226
  EOF
227
227
  else
228
- s += <<EOF
228
+ s << <<EOF
229
229
  :end => '"!$omp end #{fortran_name} #{ end_clauses.length > 0 ? "\#{c}" : "" }"' }
230
230
  EOF
231
231
  end
232
- s += <<EOF
232
+ s << <<EOF
233
233
  end
234
234
 
235
235
  def self.get_open_clauses