BOAST 1.2.2 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/BOAST.gemspec +2 -2
  3. data/lib/BOAST.rb +1 -0
  4. data/lib/BOAST/Language/Algorithm.rb +68 -30
  5. data/lib/BOAST/Language/Annotation.rb +1 -0
  6. data/lib/BOAST/Language/Architectures.rb +1 -0
  7. data/lib/BOAST/Language/Arithmetic.rb +15 -9
  8. data/lib/BOAST/Language/BOAST_OpenCL.rb +94 -87
  9. data/lib/BOAST/Language/CPUID_by_name.rb +1 -0
  10. data/lib/BOAST/Language/Case.rb +6 -0
  11. data/lib/BOAST/Language/CodeBlock.rb +1 -0
  12. data/lib/BOAST/Language/Comment.rb +14 -11
  13. data/lib/BOAST/Language/Config.rb +23 -15
  14. data/lib/BOAST/Language/ControlStructure.rb +10 -2
  15. data/lib/BOAST/Language/DataTypes.rb +23 -15
  16. data/lib/BOAST/Language/Expression.rb +3 -0
  17. data/lib/BOAST/Language/For.rb +31 -26
  18. data/lib/BOAST/Language/FuncCall.rb +7 -0
  19. data/lib/BOAST/Language/Functors.rb +56 -19
  20. data/lib/BOAST/Language/If.rb +3 -0
  21. data/lib/BOAST/Language/Index.rb +11 -9
  22. data/lib/BOAST/Language/Intrinsics.rb +2 -0
  23. data/lib/BOAST/Language/OpenMP.rb +57 -40
  24. data/lib/BOAST/Language/Operators.rb +27 -19
  25. data/lib/BOAST/Language/Pragma.rb +1 -0
  26. data/lib/BOAST/Language/Print.rb +3 -0
  27. data/lib/BOAST/Language/Procedure.rb +81 -76
  28. data/lib/BOAST/Language/Slice.rb +16 -14
  29. data/lib/BOAST/Language/State.rb +126 -55
  30. data/lib/BOAST/Language/Transitions.rb +26 -26
  31. data/lib/BOAST/Language/Variable.rb +89 -58
  32. data/lib/BOAST/Language/While.rb +3 -0
  33. data/lib/BOAST/Runtime/AffinityProbe.rb +65 -0
  34. data/lib/BOAST/Runtime/CKernel.rb +44 -1
  35. data/lib/BOAST/Runtime/CRuntime.rb +3 -0
  36. data/lib/BOAST/Runtime/CUDARuntime.rb +3 -0
  37. data/lib/BOAST/Runtime/CompiledRuntime.rb +4 -0
  38. data/lib/BOAST/Runtime/Compilers.rb +6 -5
  39. data/lib/BOAST/Runtime/Config.rb +1 -1
  40. data/lib/BOAST/Runtime/FFIRuntime.rb +3 -0
  41. data/lib/BOAST/Runtime/FORTRANRuntime.rb +3 -0
  42. data/lib/BOAST/Runtime/MPPARuntime.rb +2 -0
  43. data/lib/BOAST/Runtime/NonRegression.rb +5 -3
  44. data/lib/BOAST/Runtime/OpenCLRuntime.rb +7 -10
  45. data/lib/BOAST/Runtime/Probe.rb +2 -0
  46. metadata +7 -6
@@ -5672,4 +5672,5 @@ X86CPUID_by_name ={"_m_from_int64"=>["MMX"],
5672
5672
  "_mm_mask_permutex2var_epi8"=>["AVX512VBMI", "AVX512VL"],
5673
5673
  "_mm_mask2_permutex2var_epi8"=>["AVX512VBMI", "AVX512VL"],
5674
5674
  "_mm_maskz_permutex2var_epi8"=>["AVX512VBMI", "AVX512VL"]}
5675
+ private_constant :X86CPUID_by_name
5675
5676
  end
@@ -1,5 +1,6 @@
1
1
  module BOAST
2
2
 
3
+ # @!parse module Functors; functorize CaseCondition; end
3
4
  class CaseCondition < ControlStructure
4
5
  attr_reader :block
5
6
  attr_reader :constants
@@ -21,6 +22,8 @@ module BOAST
21
22
  :break => 'nil' }
22
23
  end
23
24
 
25
+ private :get_c_strings, :get_fortran_strings
26
+
24
27
  alias get_cl_strings get_c_strings
25
28
  alias get_cuda_strings get_c_strings
26
29
 
@@ -70,6 +73,7 @@ module BOAST
70
73
 
71
74
  end
72
75
 
76
+ # @!parse module Functors; functorize Case; end
73
77
  class Case < ControlStructure
74
78
 
75
79
  attr_reader :expression
@@ -96,6 +100,8 @@ module BOAST
96
100
  :end => '"end select"' }
97
101
  end
98
102
 
103
+ private :get_c_strings, :get_fortran_strings
104
+
99
105
  alias get_cl_strings get_c_strings
100
106
  alias get_cuda_strings get_c_strings
101
107
 
@@ -1,5 +1,6 @@
1
1
  module BOAST
2
2
 
3
+ # @!parse module Functors; functorize CodeBlock; end
3
4
  class CodeBlock < Proc
4
5
  include PrivateStateAccessor
5
6
  include Inspectable
@@ -1,5 +1,6 @@
1
1
  module BOAST
2
2
 
3
+ # @!parse module Functors; functorize Comment; end
3
4
  class Comment
4
5
  extend Functor
5
6
  include PrivateStateAccessor
@@ -10,6 +11,19 @@ module BOAST
10
11
  @comment = string
11
12
  end
12
13
 
14
+ def to_s
15
+ return to_s_fortran if get_lang == FORTRAN
16
+ return to_s_c if [C,CL,CUDA].include?(get_lang)
17
+ end
18
+
19
+ def pr
20
+ s = to_s
21
+ output.puts s
22
+ return self
23
+ end
24
+
25
+ private
26
+
13
27
  def to_s_fortran
14
28
  s = ""
15
29
  @comment.each_line { |l| s += "! #{l}" }
@@ -22,17 +36,6 @@ module BOAST
22
36
  return s
23
37
  end
24
38
 
25
- def to_s
26
- return to_s_fortran if get_lang == FORTRAN
27
- return to_s_c if [C,CL,CUDA].include?(get_lang)
28
- end
29
-
30
- def pr
31
- s = to_s
32
- output.puts s
33
- return self
34
- end
35
-
36
39
  end
37
40
 
38
41
  end
@@ -14,6 +14,8 @@ module BOAST
14
14
  :fortran_line_length => 72
15
15
  }
16
16
 
17
+ module_function
18
+
17
19
  def assert_boast_config_dir
18
20
  home_config_dir = ENV["XDG_CONFIG_HOME"]
19
21
  home_config_dir = "#{Dir.home}/.config" if not home_config_dir
@@ -25,8 +27,6 @@ module BOAST
25
27
  return boast_config_dir
26
28
  end
27
29
 
28
- module_function :assert_boast_config_dir
29
-
30
30
  def read_boast_config
31
31
  boast_config_dir = assert_boast_config_dir
32
32
  return unless boast_config_dir
@@ -42,17 +42,21 @@ module BOAST
42
42
  end
43
43
  end
44
44
 
45
- module_function :read_boast_config
46
-
47
45
  read_boast_config
48
46
 
49
47
  module PrivateStateAccessor
50
48
 
51
- private_state_accessor :output, :lang, :architecture, :model, :address_size
52
- private_state_accessor :default_int_size, :default_real_size
49
+ private_state_accessor :output
50
+ private_state_accessor :lang
51
+ private_state_accessor :architecture
52
+ private_state_accessor :model
53
+ private_state_accessor :address_size
54
+ private_state_accessor :default_int_size
55
+ private_state_accessor :default_real_size
53
56
  private_state_accessor :default_align
54
57
  private_state_accessor :array_start
55
- private_state_accessor :indent_level, :indent_increment
58
+ private_state_accessor :indent_level
59
+ private_state_accessor :indent_increment
56
60
  private_state_accessor :annotate_list
57
61
  private_state_accessor :annotate_indepth_list
58
62
  private_state_accessor :annotate_level
@@ -70,11 +74,17 @@ module BOAST
70
74
 
71
75
  end
72
76
 
73
- state_accessor :output, :lang, :architecture, :model, :address_size
74
- state_accessor :default_int_size, :default_real_size
77
+ state_accessor :output
78
+ state_accessor :lang
79
+ state_accessor :architecture
80
+ state_accessor :model
81
+ state_accessor :address_size
82
+ state_accessor :default_int_size
83
+ state_accessor :default_real_size
75
84
  state_accessor :default_align
76
85
  state_accessor :array_start
77
- state_accessor :indent_level, :indent_increment
86
+ state_accessor :indent_level
87
+ state_accessor :indent_increment
78
88
  state_accessor :annotate_list
79
89
  state_accessor :annotate_indepth_list
80
90
  state_accessor :annotate_level
@@ -114,18 +124,18 @@ module BOAST
114
124
  default_state_getter :disable_openmp, false
115
125
  default_state_getter :boast_inspect, false, nil, :INSPECT
116
126
 
117
- alias use_vla_old? use_vla?
118
127
  class << self
119
128
  alias use_vla_old? use_vla?
129
+ private :use_vla_old?
120
130
  end
121
131
 
132
+ # @return the boolean evaluation of the *use_vla* state. false if lang is CL or CUDA.
122
133
  def use_vla?
123
134
  return false if [CL,CUDA].include?(lang)
124
135
  return use_vla_old?
125
136
  end
126
137
 
127
- module_function :use_vla?
128
-
138
+ # @private
129
139
  def get_default_architecture
130
140
  architecture = const_get(ENV["ARCHITECTURE"]) if ENV["ARCHITECTURE"]
131
141
  architecture = const_get(ENV["ARCH"]) if not architecture and ENV["ARCH"]
@@ -134,8 +144,6 @@ module BOAST
134
144
  return X86
135
145
  end
136
146
 
137
- module_function :get_default_architecture
138
-
139
147
  @@architecture = get_default_architecture
140
148
 
141
149
  end
@@ -17,12 +17,20 @@ module BOAST
17
17
  FORTRAN => get_fortran_strings }
18
18
  end
19
19
 
20
- def self.token_string_generator(name, *args)
20
+ private :get_strings
21
+
22
+ class << self
23
+
24
+ def token_string_generator(name, *args)
21
25
  s = <<EOF
22
26
  def #{name}_string(#{args.join(",")})
23
- return eval get_strings[get_lang][:#{name}]
27
+ return eval get_strings[get_lang][:#{name}]
24
28
  end
25
29
  EOF
30
+ end
31
+
32
+ private :token_string_generator
33
+
26
34
  end
27
35
 
28
36
  def [](*args)
@@ -1,5 +1,6 @@
1
1
  module BOAST
2
2
 
3
+ # Base class for BOAST data types. Inherited class will define a functor.
3
4
  class DataType
4
5
  include Intrinsics
5
6
  include PrivateStateAccessor
@@ -10,6 +11,7 @@ module BOAST
10
11
 
11
12
  end
12
13
 
14
+ # @!parse module VarFunctors; var_functorize Sizet; end
13
15
  class Sizet < DataType
14
16
 
15
17
  attr_reader :signed
@@ -60,6 +62,7 @@ module BOAST
60
62
 
61
63
  end
62
64
 
65
+ # @!parse module VarFunctors; var_functorize Real; end
63
66
  class Real < DataType
64
67
 
65
68
  attr_reader :size
@@ -135,6 +138,7 @@ module BOAST
135
138
 
136
139
  end
137
140
 
141
+ # @!parse module VarFunctors; var_functorize Int; end
138
142
  class Int < DataType
139
143
 
140
144
  attr_reader :size
@@ -246,6 +250,7 @@ module BOAST
246
250
 
247
251
  end
248
252
 
253
+ # @!parse module VarFunctors; var_functorize CStruct; end
249
254
  class CStruct < DataType
250
255
 
251
256
  attr_reader :name, :members, :members_array
@@ -261,31 +266,26 @@ module BOAST
261
266
  }
262
267
  end
263
268
 
264
- def decl_c
265
- return "struct #{@name}" if [C, CL, CUDA].include?( lang )
266
- end
267
-
268
- def decl_fortran
269
- return "TYPE(#{@name})" if lang == FORTRAN
270
- end
271
-
272
269
  def decl
273
270
  return decl_c if [C, CL, CUDA].include?( lang )
274
271
  return decl_fortran if lang == FORTRAN
275
272
  end
276
273
 
277
- def finalize
278
- s = ""
279
- s += ";" if [C, CL, CUDA].include?( lang )
280
- s+="\n"
281
- return s
282
- end
283
-
284
274
  def define
285
275
  return define_c if [C, CL, CUDA].include?( lang )
286
276
  return define_fortran if lang == FORTRAN
287
277
  end
288
278
 
279
+ private
280
+
281
+ def decl_c
282
+ return "struct #{@name}" if [C, CL, CUDA].include?( lang )
283
+ end
284
+
285
+ def decl_fortran
286
+ return "TYPE(#{@name})" if lang == FORTRAN
287
+ end
288
+
289
289
  def define_c
290
290
  s = indent
291
291
  s += decl_c + " {"
@@ -318,8 +318,16 @@ module BOAST
318
318
  return self
319
319
  end
320
320
 
321
+ def finalize
322
+ s = ""
323
+ s += ";" if [C, CL, CUDA].include?( lang )
324
+ s+="\n"
325
+ return s
326
+ end
327
+
321
328
  end
322
329
 
330
+ # @!parse module VarFunctors; var_functorize CustomType; end
323
331
  class CustomType < DataType
324
332
 
325
333
  attr_reader :size, :name, :vector_length
@@ -2,6 +2,7 @@ module BOAST
2
2
 
3
3
  module_function
4
4
 
5
+ # @!parse module Functors; functorize Expression; end
5
6
  class Expression
6
7
  include PrivateStateAccessor
7
8
  include Arithmetic
@@ -39,6 +40,8 @@ module BOAST
39
40
  end
40
41
  return s
41
42
  end
43
+
44
+ private :to_s_base
42
45
 
43
46
  def to_var
44
47
  op1 = nil
@@ -1,12 +1,13 @@
1
1
  module BOAST
2
2
 
3
+ # @!parse module Functors; functorize For; end
3
4
  class For < ControlStructure
4
5
  include Annotation
5
- ANNOTATIONS = [ :iterator, :begin, :end, :step, :operator ]
6
+ ANNOTATIONS = [ :iterator, :first, :last, :step, :operator ]
6
7
 
7
8
  attr_reader :iterator
8
- attr_reader :begin
9
- attr_reader :end
9
+ attr_reader :first
10
+ attr_reader :last
10
11
  attr_reader :step
11
12
  attr_accessor :block
12
13
 
@@ -18,13 +19,13 @@ module BOAST
18
19
  @unroll = val
19
20
  end
20
21
 
21
- def initialize(i, b, e, options={}, &block)
22
+ def initialize(iterator, first, last, options={}, &block)
22
23
  default_options = {:step => 1}
23
24
  default_options.update( options )
24
25
  @options = options
25
- @iterator = i
26
- @begin = b
27
- @end = e
26
+ @iterator = iterator
27
+ @first = first
28
+ @last = last
28
29
  @step = default_options[:step]
29
30
  @operator = "<="
30
31
  @block = block
@@ -65,6 +66,8 @@ module BOAST
65
66
  :end => '"end do"' }
66
67
  end
67
68
 
69
+ private :get_c_strings, :get_fortran_strings
70
+
68
71
  alias get_cl_strings get_c_strings
69
72
  alias get_cuda_strings get_c_strings
70
73
 
@@ -72,19 +75,14 @@ module BOAST
72
75
  eval token_string_generator( * %w{end})
73
76
 
74
77
  def to_s
75
- s = for_string(@iterator, @begin, @end, @step, @operator)
78
+ s = for_string(@iterator, @first, @last, @step, @operator)
76
79
  return s
77
80
  end
78
81
 
79
- # def u(s = 2)
80
- # return [For::new(@iterator, @begin, @end - (@step*s - 1), @options.dup.update( { :step => (@step*s) } ), &@block),
81
- # For::new(@iterator, @begin.to_var + ((@end - @begin + 1)/(@step*s))*(@step*s), @end, @options, &@block) ]
82
- # end
83
- #
84
82
  def unroll
85
83
  opts = @options.clone
86
84
  opts[:unroll] = true
87
- return For::new(@iterator, @begin, @end, opts, &block)
85
+ return For::new(@iterator, @first, @last, opts, &block)
88
86
  end
89
87
 
90
88
  def pr_unroll(*args)
@@ -92,19 +90,19 @@ module BOAST
92
90
  begin
93
91
  begin
94
92
  push_env( :replace_constants => true )
95
- if @begin.kind_of?(Variable) then
96
- start = @begin.constant
97
- elsif @begin.kind_of?(Expression) then
98
- start = eval "#{@begin}"
93
+ if @first.kind_of?(Variable) then
94
+ first = @first.constant
95
+ elsif @first.kind_of?(Expression) then
96
+ first = eval "#{@first}"
99
97
  else
100
- start = @begin.to_i
98
+ first = @first.to_i
101
99
  end
102
- if @end.kind_of?(Variable) then
103
- e = @end.constant
104
- elsif @end.kind_of?(Expression) then
105
- e = eval "#{@end}"
100
+ if @last.kind_of?(Variable) then
101
+ last = @last.constant
102
+ elsif @last.kind_of?(Expression) then
103
+ last = eval "#{@last}"
106
104
  else
107
- e = @end.to_i
105
+ last = @last.to_i
108
106
  end
109
107
  if @step.kind_of?(Variable) then
110
108
  step = @step.constant
@@ -113,7 +111,7 @@ module BOAST
113
111
  else
114
112
  step = @step.to_i
115
113
  end
116
- raise "Invalid bounds (not constants)!" if not ( start and e and step )
114
+ raise "Invalid bounds (not constants)!" if not ( first and last and step )
117
115
  ensure
118
116
  pop_env( :replace_constants )
119
117
  end
@@ -125,7 +123,7 @@ module BOAST
125
123
  end
126
124
  return self
127
125
  end
128
- range = start..e
126
+ range = first..last
129
127
  @iterator.force_replace_constant = true
130
128
  range.step(step) { |i|
131
129
  @iterator.constant = i
@@ -135,6 +133,8 @@ module BOAST
135
133
  @iterator.constant = nil
136
134
  end
137
135
 
136
+ private :pr_unroll
137
+
138
138
  def open
139
139
  @openmp.open if @openmp
140
140
  s=""
@@ -166,6 +166,11 @@ module BOAST
166
166
  return self
167
167
  end
168
168
 
169
+ # def u(s = 2)
170
+ # return [For::new(@iterator, @first, @last - (@step*s - 1), @options.dup.update( { :step => (@step*s) } ), &@block),
171
+ # For::new(@iterator, @first.to_var + ((@last - @first + 1)/(@step*s))*(@step*s), @last, @options, &@block) ]
172
+ # end
173
+
169
174
  end
170
175
 
171
176
  end