Class: BOAST::Int
Instance Attribute Summary collapse
-
#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 = {}) ⇒ Int
constructor
A new instance of Int.
- #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 = {}) ⇒ Int
Returns a new instance of Int.
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
# File 'lib/BOAST/DataTypes.rb', line 160 def initialize(hash={}) if hash[:size] then @size = hash[:size] else @size = get_default_int_size end if hash[:signed] != nil then @signed = hash[:signed] else @signed = get_default_int_signed 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 end |
Instance Attribute Details
#signed ⇒ Object (readonly)
Returns the value of attribute signed.
151 152 153 |
# File 'lib/BOAST/DataTypes.rb', line 151 def signed @signed end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
150 151 152 |
# File 'lib/BOAST/DataTypes.rb', line 150 def size @size end |
#total_size ⇒ Object (readonly)
Returns the value of attribute total_size.
153 154 155 |
# File 'lib/BOAST/DataTypes.rb', line 153 def total_size @total_size end |
#vector_length ⇒ Object (readonly)
Returns the value of attribute vector_length.
152 153 154 |
# File 'lib/BOAST/DataTypes.rb', line 152 def vector_length @vector_length end |
Instance Method Details
#==(t) ⇒ Object
155 156 157 158 |
# File 'lib/BOAST/DataTypes.rb', line 155 def ==(t) return true if t.class == self.class and t.signed == signed and t.size == size and t.vector_length == vector_length return false end |
#copy(options = {}) ⇒ Object
189 190 191 192 193 194 195 |
# File 'lib/BOAST/DataTypes.rb', line 189 def copy(={}) hash = to_hash .each { |k,v| hash[k] = v } return Int::new(hash) end |
#decl ⇒ Object
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
# File 'lib/BOAST/DataTypes.rb', line 201 def decl return "integer(kind=#{@size})" if lang == FORTRAN if lang == C then if @vector_length == 1 then s = "" s += "u" if not @signed return s+"int#{8*@size}_t" elsif @vector_length > 1 then if get_architecture == X86 then return "__m#{@total_size*8}#{@total_size*8>64 ? "i" : ""}" elsif get_architecture == ARM then raise "Unsupported vector length in NEON: #{@total_size*8} (#{@size} x 8 x #{@vector_length})!" if @total_size * 8 != 64 and @total_size * 8 != 128 return "#{ @signed ? "" : "u"}int#{@size*8}x#{@vector_length}_t" else raise "Unsupported architecture!" end end elsif lang == CL then #char="cl_" char="" char += "u" if not @signed case @size when 1 char += "char" when 2 char += "short" when 4 char += "int" when 8 char += "long" else raise "Unsupported integer size!" end if @vector_length > 1 then char += "#{@vector_length}" end return char elsif lang == CUDA then if @vector_length > 1 then char="" char += "u" if not @signed case @size when 1 char += "char" when 2 char += "short" when 4 char += "int" when 8 char += "longlong" else raise "Unsupported integer size!" end return char + "#{@vector_length}" else char = "" char += "unsigned " if not @signed return char += "char" if @size==1 return char += "short" if @size==2 return char += "int" if @size==4 return char += "long long" if @size==8 end end end |
#signed? ⇒ Boolean
197 198 199 |
# File 'lib/BOAST/DataTypes.rb', line 197 def signed? return !!@signed end |
#suffix ⇒ Object
266 267 268 269 |
# File 'lib/BOAST/DataTypes.rb', line 266 def suffix s = "" return s end |
#to_hash ⇒ Object
185 186 187 |
# File 'lib/BOAST/DataTypes.rb', line 185 def to_hash return { :size => @size, :vector_length => @vector_length, :signed => @signed } end |