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.
Class Method Summary collapse
Instance Method Summary collapse
- #==(t) ⇒ Object
- #copy(options = {}) ⇒ Object
- #decl ⇒ Object
-
#initialize(hash = {}) ⇒ Real
constructor
A new instance of Real.
- #to_hash ⇒ Object
Constructor Details
#initialize(hash = {}) ⇒ Real
Returns a new instance of Real.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/BOAST/DataTypes.rb', line 58 def initialize(hash={}) if hash[:size] then @size = hash[:size] else @size = BOAST::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.
50 51 52 |
# File 'lib/BOAST/DataTypes.rb', line 50 def getters @getters end |
#setters ⇒ Object (readonly)
Returns the value of attribute setters.
51 52 53 |
# File 'lib/BOAST/DataTypes.rb', line 51 def setters @setters end |
#signed ⇒ Object (readonly)
Returns the value of attribute signed.
47 48 49 |
# File 'lib/BOAST/DataTypes.rb', line 47 def signed @signed end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
46 47 48 |
# File 'lib/BOAST/DataTypes.rb', line 46 def size @size end |
#total_size ⇒ Object (readonly)
Returns the value of attribute total_size.
49 50 51 |
# File 'lib/BOAST/DataTypes.rb', line 49 def total_size @total_size end |
#vector_length ⇒ Object (readonly)
Returns the value of attribute vector_length.
48 49 50 |
# File 'lib/BOAST/DataTypes.rb', line 48 def vector_length @vector_length end |
Class Method Details
Instance Method Details
#==(t) ⇒ Object
53 54 55 56 |
# File 'lib/BOAST/DataTypes.rb', line 53 def ==(t) return true if t.class == self.class and t.size == self.size and t.vector_length == self.vector_length return false end |
#copy(options = {}) ⇒ Object
83 84 85 86 87 88 89 |
# File 'lib/BOAST/DataTypes.rb', line 83 def copy(={}) hash = to_hash .each { |k,v| hash[k] = v } return Real::new(hash) end |
#decl ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/BOAST/DataTypes.rb', line 91 def decl return "real(kind=#{@size})" if BOAST::get_lang == FORTRAN if [C, CL, CUDA].include?( BOAST::get_lang ) and @vector_length == 1 then return "float" if @size == 4 return "double" if @size == 8 elsif BOAST::get_lang == C and @vector_length > 1 then if BOAST::get_architecture == BOAST::X86 then return "__m#{@total_size*8}" if @size == 4 return "__m#{@total_size*8}d" if @size == 8 elsif BOAST::get_architecture == BOAST::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?( BOAST::get_lang ) and @vector_length > 1 then return "float#{@vector_length}" if @size == 4 return "double#{@vector_length}" if @size == 8 end end |
#to_hash ⇒ Object
79 80 81 |
# File 'lib/BOAST/DataTypes.rb', line 79 def to_hash return { :size => @size, :vector_length => @vector_length } end |