BOAST 2.0.0 → 2.0.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b7f276c1688e0a9ba92d4292b2f99c008e264821
4
- data.tar.gz: d8c603a75c17ab5535c69156dcab3faecdd69826
3
+ metadata.gz: 12d3019064fc0609d6be8218867a2e5f96d36be8
4
+ data.tar.gz: 7c461ebad9ad23314f8fc531d89a680008422828
5
5
  SHA512:
6
- metadata.gz: 64dbe9f8d71796a2cbe626e2f7fe400ac90c491fdaa56b9d0e8cdcbf7696eb4df94cfaebf10cd80e43b886828d927a3f3e2c21988f6e9338b9f10be4eb5cbfca
7
- data.tar.gz: 8c069701fce7b32127bdf26930587eb7644658f844161dc84ffcecc5d1d67bf42fa8c560702bc06b77c8b72b2250a188e964b46d2b8718ce0a0164b9de711a06
6
+ metadata.gz: c92be2673de5ac581c069c91641beb11327bbf64c406b1af262c78c942763395c3f28b256b6cc395fdee83841e8e90688d4eff114fb22238cb8d451b47c08385
7
+ data.tar.gz: 496596256bb9a9ab2f29257001327a40a49484c2c8bc0d965f6d4c66a1634c2b95ca2c5bff6b121b4f2cb705a0a77f291cb0489d11b30fafdbae7886a10584ad
data/BOAST.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'BOAST'
3
- s.version = "2.0.0"
3
+ s.version = "2.0.1"
4
4
  s.author = "Brice Videau"
5
5
  s.email = "brice.videau@imag.fr"
6
6
  s.homepage = "https://github.com/Nanosim-LIG/boast"
@@ -47,6 +47,11 @@ module BOAST
47
47
  BOAST::annotate_number(name)
48
48
  end
49
49
 
50
+ # (see BOAST#reset_annotate_numbers
51
+ def reset_annotate_numbers
52
+ BOAST::reset_annotate_numbers
53
+ end
54
+
50
55
  end
51
56
 
52
57
  module_function
@@ -132,6 +137,11 @@ module BOAST
132
137
  return num
133
138
  end
134
139
 
140
+ # Resets the annotate_numbers to an empty Hash
141
+ def reset_annotate_numbers
142
+ @@annotate_numbers = Hash::new { |h,k| h[k] = 0 }
143
+ end
144
+
135
145
  # Annotates an Object by inlining a YAML structure in a comment.
136
146
  # If object's class is part of the annotate list an indepth version of the annotation
137
147
  # will be generated.
@@ -6,7 +6,7 @@ module BOAST
6
6
  # @param [#to_var] value to return
7
7
  # @return [Expression]
8
8
  def Return(value)
9
- return Expression::new("return",nil, value)
9
+ return Expression::new("return",nil, value ? value : "" )
10
10
  end
11
11
 
12
12
  # Creates an Expression using the boolean And Operator
@@ -4,10 +4,31 @@ module BOAST
4
4
  attr_reader :source
5
5
  attr_reader :indexes
6
6
  attr_accessor :alignment
7
+ attr_accessor :vector_index
8
+
9
+ def method_missing(m, *a, &b)
10
+ var = to_var
11
+ if var.type.methods.include?(:members) and var.type.members[m.to_s] then
12
+ return struct_reference(type.members[m.to_s])
13
+ elsif var.vector? and m.to_s[0] == 's' and lang != CUDA then
14
+ required_set = m.to_s[1..-1].chars.to_a
15
+ existing_set = [*('0'..'9'),*('a'..'z')].first(var.type.vector_length)
16
+ if required_set.length == required_set.uniq.length and (required_set - existing_set).empty? then
17
+ return var.copy(var.name+"."+m.to_s, :vector_length => m.to_s[1..-1].length) if lang == CL
18
+ @vector_index = existing_set.index(required_set[0])
19
+ return self
20
+ else
21
+ return super
22
+ end
23
+ else
24
+ return super
25
+ end
26
+ end
7
27
 
8
28
  def initialize(source, *indexes)
9
29
  @source = source
10
30
  @indexes = indexes
31
+ @vector_index = nil
11
32
  end
12
33
 
13
34
  def align?
@@ -20,7 +41,9 @@ module BOAST
20
41
  end
21
42
 
22
43
  def to_var
23
- var = @source.copy("#{self}", :const => nil, :constant => nil, :dim => nil, :dimension => nil, :direction => nil, :dir => nil, :align => alignment)
44
+ options = { :const => nil, :constant => nil, :dim => nil, :dimension => nil, :direction => nil, :dir => nil, :align => alignment }
45
+ options[:vector_length] = 1 if @vector_index
46
+ var = @source.copy("#{self}", options)
24
47
  return var
25
48
  end
26
49
 
@@ -79,7 +102,7 @@ module BOAST
79
102
  end
80
103
  }
81
104
  s = ""
82
- s += "#{@source}(#{@source.vector? ? ":, " : "" }#{indexes_dup.join(", ")})"
105
+ s += "#{@source}(#{@source.vector? ? (@vector_index ? "#{@vector_index+1}, " : ":, ") : "" }#{indexes_dup.join(", ")})"
83
106
  return s
84
107
  end
85
108
 
@@ -171,6 +194,9 @@ module BOAST
171
194
  sub = to_s_c_reversed
172
195
  end
173
196
  s = "#{@source}[" + sub + "]"
197
+ if @vector_index then
198
+ s += "[#{@vector_index}]"
199
+ end
174
200
  return s
175
201
  end
176
202
 
@@ -6,11 +6,12 @@ module BOAST
6
6
  include Inspectable
7
7
  extend Functor
8
8
  include Annotation
9
- ANNOTATIONS = [ :name, :parameters, :constants ]
9
+ ANNOTATIONS = [ :name, :parameters, :constants, :locals ]
10
10
 
11
11
  attr_reader :name
12
12
  attr_reader :parameters
13
13
  attr_reader :constants
14
+ attr_reader :locals
14
15
  attr_reader :properties
15
16
  attr_reader :headers
16
17
 
@@ -27,6 +28,8 @@ module BOAST
27
28
  @parameters = parameters
28
29
  @constants = properties[:constants]
29
30
  @constants = [] unless @constants
31
+ @locals = properties[:locals]
32
+ @locals = [] unless @locals
30
33
  @block = block
31
34
  @properties = properties
32
35
  @headers = properties[:headers]
@@ -148,9 +151,9 @@ module BOAST
148
151
  s += "void "
149
152
  end
150
153
  s += "#{@name}("
151
- if parameters.first then
152
- s += parameters.first.send(:decl_c_s, @properties[:local])
153
- parameters[1..-1].each { |p|
154
+ if @parameters.first then
155
+ s += @parameters.first.send(:decl_c_s, @properties[:local])
156
+ @parameters[1..-1].each { |p|
154
157
  s += ", "+p.send(:decl_c_s, @properties[:local])
155
158
  }
156
159
  end
@@ -172,7 +175,7 @@ module BOAST
172
175
  s += "SUBROUTINE "
173
176
  end
174
177
  s += "#{@name}("
175
- s += parameters.collect(&:name).join(", ")
178
+ s += @parameters.collect(&:name).join(", ")
176
179
  s += ")"
177
180
  end
178
181
 
@@ -180,18 +183,23 @@ module BOAST
180
183
  s = indent + decl_c_s + "{"
181
184
  output.puts s
182
185
  increment_indent_level
183
- constants.each { |c|
186
+ @constants.each { |c|
184
187
  BOAST::decl c
185
188
  }
186
189
  if lang == C then
187
- parameters.each { |p|
190
+ @parameters.each { |p|
188
191
  align = p.align
189
- BOAST::pr align if align
192
+ BOAST::pr align if align and not p.send(:__attr_align?)
190
193
  }
191
194
  end
192
195
  if @properties[:return] then
193
196
  BOAST::decl @properties[:return]
194
197
  end
198
+ @locals.each { |l|
199
+ BOAST::decl l
200
+ align = l.align
201
+ BOAST::pr align if align and not l.send(:__attr_align?)
202
+ }
195
203
  return self
196
204
  end
197
205
 
@@ -201,7 +209,7 @@ module BOAST
201
209
  increment_indent_level
202
210
  tmp_buff = StringIO::new
203
211
  push_env( :output => tmp_buff ) {
204
- parameters.each { |p|
212
+ @parameters.each { |p|
205
213
  p.type.define if p.type.kind_of? CStruct
206
214
  }
207
215
  }
@@ -209,13 +217,18 @@ module BOAST
209
217
  s += tmp_buff.read
210
218
  s += indent + "integer, parameter :: wp=kind(1.0d0)"
211
219
  output.puts s
212
- constants.each { |c|
220
+ @constants.each { |c|
213
221
  BOAST::decl c
214
222
  }
215
- parameters.each { |p|
223
+ @parameters.each { |p|
216
224
  BOAST::decl p
217
- align = p.align
218
- BOAST::pr align if align
225
+ # align = p.align
226
+ # BOAST::pr align if align
227
+ }
228
+ @locals.each { |l|
229
+ BOAST::decl l
230
+ # align = l.align
231
+ # BOAST::pr align if align
219
232
  }
220
233
  if @properties[:functions] then
221
234
  @properties[:functions].each { |f|
@@ -225,6 +238,10 @@ module BOAST
225
238
  if @properties[:return] then
226
239
  BOAST::decl @properties[:return]
227
240
  end
241
+ (@parameters + @locals).each { |v|
242
+ align = v.align
243
+ BOAST::pr align if align and not v.send(:__attr_align?)
244
+ }
228
245
  return self
229
246
  end
230
247
 
@@ -274,9 +291,9 @@ module BOAST
274
291
  s += "void "
275
292
  end
276
293
  s += "#{@name}#{trailer}("
277
- if parameters.first then
278
- s += parameters.first.boast_header(lang)
279
- parameters[1..-1].each { |p|
294
+ if @parameters.first then
295
+ s += @parameters.first.boast_header(lang)
296
+ @parameters[1..-1].each { |p|
280
297
  s += ", "
281
298
  s += p.boast_header(lang)
282
299
  }
@@ -328,7 +328,7 @@ module BOAST
328
328
  end
329
329
 
330
330
  def to_s
331
- if force_replace_constant? or ( replace_constant? and constant? and replace_constants? and not dimension? ) then
331
+ if force_replace_constant? or ( ( replace_constant? or replace_constants? ) and constant? and not dimension? ) then
332
332
  s = @constant.to_s + @type.suffix
333
333
  return s
334
334
  end
@@ -486,6 +486,10 @@ module BOAST
486
486
  return ( @type.vector? and @type.vector_length > 1 )
487
487
  end
488
488
 
489
+ def __attr_align?
490
+ return ( __align? or ( vector? and not @direction ) )
491
+ end
492
+
489
493
  def decl_c_s(device = false)
490
494
  return decl_texture_s if texture?
491
495
  s = ""
@@ -32,15 +32,22 @@ module BOAST
32
32
  narray_path = nil
33
33
  begin
34
34
  spec = Gem::Specification::find_by_name('narray')
35
- narray_path = spec.full_gem_path
35
+ narray_path = spec.require_path
36
+ if narray_path == "." then
37
+ narray_path = spec.full_gem_path
38
+ end
36
39
  rescue Gem::LoadError => e
37
40
  rescue NoMethodError => e
38
41
  spec = Gem::available?('narray')
39
42
  if spec then
40
- require 'narray'
41
- narray_path = Gem.loaded_specs['narray'].full_gem_path
43
+ require 'narray'
44
+ narray_path = Gem.loaded_specs['narray'].require_path
45
+ if narray_path == "." then
46
+ narray_path = Gem.loaded_specs['narray'].full_gem_path
47
+ end
42
48
  end
43
49
  end
50
+ return narray_path
44
51
  end
45
52
 
46
53
  def setup_c_compiler(options, includes, narray_path, runner, probes)
@@ -168,7 +175,12 @@ module BOAST
168
175
  def setup_linker(options, probes)
169
176
  ldflags = options[:LDFLAGS]
170
177
  ldflags += " -march=#{get_model}"
171
- ldflags += " -L#{RbConfig::CONFIG["libdir"]} #{RbConfig::CONFIG["LIBRUBYARG"]}"
178
+ ldflags += " -L#{RbConfig::CONFIG["libdir"]}"
179
+ if RbConfig::CONFIG["ENABLE_SHARED"] != "no" then
180
+ ldflags += " #{RbConfig::CONFIG["LIBRUBYARG"]}"
181
+ else
182
+ ldflags += " -Wl,-R#{RbConfig::CONFIG["libdir"]}"
183
+ end
172
184
  probes.each { |p|
173
185
  ldflags += " #{p.ldflags}" if p.respond_to?(:ldflags)
174
186
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: BOAST
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brice Videau
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-30 00:00:00.000000000 Z
11
+ date: 2017-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: narray