BOAST 0.9996 → 0.9997

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.
data/BOAST.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'BOAST'
3
- s.version = "0.9996"
3
+ s.version = "0.9997"
4
4
  s.author = "Brice Videau"
5
5
  s.email = "brice.videau@imag.fr"
6
6
  s.homepage = "https://forge.imag.fr/projects/boast/"
@@ -61,5 +61,18 @@ module BOAST
61
61
  return Expression::new("*",nil,self)
62
62
  end
63
63
 
64
+ def and(x)
65
+ return Expression::new("&&", self, x)
66
+ end
67
+
68
+ def or(x)
69
+ return Expression::new("||", self, x)
70
+ end
71
+
72
+ def components( range )
73
+ existing_set = [*('0'..'9'),*('a'..'z')].first(self.type.vector_length)
74
+ eval "self.s#{existing_set[range].join("")}"
75
+ end
76
+
64
77
  end
65
78
  end
data/lib/BOAST/Index.rb CHANGED
@@ -71,40 +71,41 @@ module BOAST
71
71
  return s
72
72
  end
73
73
 
74
- def to_s_c
75
- return to_s_texture if @source.texture
76
- dim = @source.dimension.first
77
- if dim.val2 then
78
- start = dim.val1
79
- else
80
- start = get_array_start
81
- end
82
- sub = "#{@indexes.first} - (#{start})"
83
- i=1
84
- ss = ""
85
- @source.dimension[0..-2].each{ |d|
86
- if d.size then
87
- ss += " * (#{d.size})"
88
- elsif d.val2 then
89
- ss += " * (#{d.val2} - (#{d.val1}) + 1)"
90
- else
91
- raise "Unkwown dimension size!"
92
- end
93
- dim = @source.dimension[i]
74
+ def to_s_c_reversed
75
+ indxs = @indexes.reverse
76
+ dims = @source.dimension.reverse
77
+ ss = nil
78
+ (0...dims.length).each { |indx|
79
+ s = ""
80
+ dim = dims[indx]
81
+ s += "#{indxs[indx]}"
94
82
  if dim.val2 then
95
- start = dim.val1
96
- else
97
- start = get_array_start
83
+ s += " - (#{dim.val1})"
84
+ elsif 0 != get_array_start then
85
+ s += " - (#{get_array_start})"
98
86
  end
99
- sub += " + (#{@indexes[i]} - (#{start}))"+ss
100
- i+=1
87
+ if ss then
88
+ if dim.size then
89
+ s += " + (#{dim.size}) * "
90
+ elsif dim.val2 then
91
+ s += " + (#{dim.val2} - (#{dim.val1}) + 1) * "
92
+ else
93
+ raise "Unkwown dimension size!"
94
+ end
95
+ s += "(#{ss})"
96
+ end
97
+ ss = s
101
98
  }
99
+ return ss
100
+ end
101
+
102
+ def to_s_c
103
+ return to_s_texture if @source.texture
104
+ sub = to_s_c_reversed
102
105
  if get_replace_constants then
103
106
  begin
104
- # puts sub
105
107
  indx = eval(sub)
106
108
  indx = indx.to_i
107
- # puts indx
108
109
  return "#{@source.constant[indx]}"
109
110
  rescue Exception => e
110
111
  end
@@ -10,35 +10,25 @@ module BOAST
10
10
  attr_reader :size
11
11
 
12
12
  def initialize(v1=nil,v2=nil)
13
- @size = nil
14
- @val1 = nil
15
- @val2 = nil
16
- if v2.nil? and v1 then
17
- @val1 = get_array_start
18
- @val2 = v1 + get_array_start - 1
19
- @size = v1
13
+ if v1 then
14
+ if v2 then
15
+ @size = Expression::new(Substraction, v2, v1) + 1
16
+ else
17
+ @size = v1
18
+ end
20
19
  else
21
- @val1 = v1
22
- @val2 = v2
20
+ @size = nil
23
21
  end
22
+ @val1 = v1
23
+ @val2 = v2
24
24
  end
25
25
 
26
26
  def to_s
27
- s = ""
28
- if @val2 then
29
- if lang == FORTRAN then
30
- s += @val1.to_s
31
- s += ":"
32
- s += @val2.to_s
33
- elsif [C, CL, CUDA].include?( lang ) then
34
- s += (@val2 - @val1 + 1).to_s
35
- end
36
- elsif @val1.nil? then
37
- return nil
27
+ if lang == FORTRAN and @val2 then
28
+ return "#{@val1}:#{@val2}"
38
29
  else
39
- s += @val1.to_s
40
- end
41
- return s
30
+ return @size
31
+ end
42
32
  end
43
33
  end
44
34
 
@@ -92,6 +82,14 @@ module BOAST
92
82
  def method_missing(m, *a, &b)
93
83
  if @type.methods.include?(:members) and @type.members[m.to_s] then
94
84
  return struct_reference(type.members[m.to_s])
85
+ elsif @type.methods.include?(:vector_length) and @type.vector_length > 1 and m.to_s[0] == 's' and lang == CL then
86
+ required_set = m.to_s[1..-1].chars.to_a
87
+ existing_set = [*('0'..'9'),*('a'..'z')].first(@type.vector_length)
88
+ if required_set.length == required_set.uniq.length and (required_set - existing_set).empty? then
89
+ return self.copy(name+"."+m.to_s, :vector_length => m.to_s[1..-1].length)
90
+ else
91
+ return orig_method_missing(m, *a, &b)
92
+ end
95
93
  else
96
94
  return orig_method_missing(m, *a, &b)
97
95
  end
@@ -284,7 +282,7 @@ module BOAST
284
282
  end
285
283
  if dimension? and ((local? and not device) or (allocate? and not constant?)) then
286
284
  s +="["
287
- s += @dimension.reverse.join("*")
285
+ s += @dimension.collect{ |d| d.to_s }.reverse.join("*")
288
286
  s +="]"
289
287
  end
290
288
  s += " = #{@constant}" if constant?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: BOAST
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.9996'
4
+ version: '0.9997'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-09-11 00:00:00.000000000 Z
12
+ date: 2014-09-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: narray