Class: BOAST::Real
Instance Attribute Summary collapse
-
#getters ⇒ Object
readonly
Returns the value of attribute getters.
-
#setters ⇒ Object
readonly
Returns the value of attribute setters.
-
#signed ⇒ Object
readonly
Returns the value of attribute signed.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#total_size ⇒ Object
readonly
Returns the value of attribute total_size.
-
#vector_length ⇒ Object
readonly
Returns the value of attribute vector_length.
Instance Method Summary collapse
- #==(t) ⇒ Object
- #copy(options = {}) ⇒ Object
- #decl ⇒ Object
-
#initialize(hash = {}) ⇒ Real
constructor
A new instance of Real.
- #signed? ⇒ Boolean
- #suffix ⇒ Object
- #to_hash ⇒ Object
Methods inherited from DataType
Methods included from PrivateStateAccessor
private_boolean_state_accessor, private_state_accessor
Constructor Details
#initialize(hash = {}) ⇒ Real
Returns a new instance of Real.
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/BOAST/DataTypes.rb', line 77 def initialize(hash={}) if hash[:size] then @size = hash[:size] else @size = get_default_real_size end # @getters = {} # @setters = {} if hash[:vector_length] and hash[:vector_length] > 1 then @vector_length = hash[:vector_length] # @vector_length.times{ |indx| # @getters["s#{indx}"] = indx # @setters["s#{indx}="] = indx # } else @vector_length = 1 end @total_size = @vector_length*@size @signed = true end |
Instance Attribute Details
#getters ⇒ Object (readonly)
Returns the value of attribute getters.
69 70 71 |
# File 'lib/BOAST/DataTypes.rb', line 69 def getters @getters end |
#setters ⇒ Object (readonly)
Returns the value of attribute setters.
70 71 72 |
# File 'lib/BOAST/DataTypes.rb', line 70 def setters @setters end |
#signed ⇒ Object (readonly)
Returns the value of attribute signed.
66 67 68 |
# File 'lib/BOAST/DataTypes.rb', line 66 def signed @signed end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
65 66 67 |
# File 'lib/BOAST/DataTypes.rb', line 65 def size @size end |
#total_size ⇒ Object (readonly)
Returns the value of attribute total_size.
68 69 70 |
# File 'lib/BOAST/DataTypes.rb', line 68 def total_size @total_size end |
#vector_length ⇒ Object (readonly)
Returns the value of attribute vector_length.
67 68 69 |
# File 'lib/BOAST/DataTypes.rb', line 67 def vector_length @vector_length end |
Instance Method Details
#==(t) ⇒ Object
72 73 74 75 |
# File 'lib/BOAST/DataTypes.rb', line 72 def ==(t) return true if t.class == self.class and t.size == size and t.vector_length == vector_length return false end |
#copy(options = {}) ⇒ Object
106 107 108 109 110 111 112 |
# File 'lib/BOAST/DataTypes.rb', line 106 def copy(={}) hash = to_hash .each { |k,v| hash[k] = v } return Real::new(hash) end |
#decl ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/BOAST/DataTypes.rb', line 114 def decl return "real(kind=#{@size})" if lang == FORTRAN if [C, CL, CUDA].include?( lang ) and @vector_length == 1 then return "float" if @size == 4 return "double" if @size == 8 elsif lang == C and @vector_length > 1 then if get_architecture == X86 then return "__m#{@total_size*8}" if @size == 4 return "__m#{@total_size*8}d" if @size == 8 elsif get_architecture == ARM then raise "Unsupported data type in NEON: double!" if @size == 8 raise "Unsupported vector length in NEON: #{@total_size} (#{@size} x 8 x #{@vector_length})!" if @total_size * 8 != 64 or @total_size * 8 != 128 return "float#{@size*8}x#{@vector_length}_t" else raise "Unsupported architecture!" end elsif [CL, CUDA].include?( lang ) and @vector_length > 1 then return "float#{@vector_length}" if @size == 4 return "double#{@vector_length}" if @size == 8 end end |
#signed? ⇒ Boolean
98 99 100 |
# File 'lib/BOAST/DataTypes.rb', line 98 def signed? return !!signed end |
#suffix ⇒ Object
136 137 138 139 140 141 142 143 144 |
# File 'lib/BOAST/DataTypes.rb', line 136 def suffix s = "" if [C, CL, CUDA].include?( lang ) then s += "f" if @size == 4 elsif lang == FORTRAN then s += "_wp" if @size == 8 end return s end |
#to_hash ⇒ Object
102 103 104 |
# File 'lib/BOAST/DataTypes.rb', line 102 def to_hash return { :size => @size, :vector_length => @vector_length } end |