Class: BOAST::Set
- Extended by:
- Functor
- Includes:
- Arithmetic, Inspectable, Intrinsics, PrivateStateAccessor
- Defined in:
- lib/BOAST/Language/Operators.rb
Constant Summary
Constants included from Intrinsics
Intrinsics::CONVERSIONS, Intrinsics::INTRINSICS
Constants inherited from Operator
Instance Attribute Summary collapse
-
#return_type ⇒ Object
readonly
Returns the value of attribute return_type.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
-
#initialize(source, return_type) ⇒ Set
constructor
A new instance of Set.
- #pr ⇒ Object
- #to_s ⇒ Object
- #to_var ⇒ Object
- #type ⇒ Object
Methods included from Functor
Methods included from PrivateStateAccessor
private_boolean_state_accessor, private_state_accessor
Methods included from Inspectable
Methods included from Arithmetic
#!, #!=, #*, #**, #+, #+@, #-, #-@, #/, #<, #<=, #==, #===, #>, #>=, #and, #cast, #components, #dereference, #or, #reference
Methods included from Intrinsics
get_conversion_path, get_vector_decl, get_vector_decl_ARM, get_vector_decl_X86, get_vector_name, intrinsics, intrinsics_by_vector_name, type_name_ARM, type_name_X86, vector_type_name
Methods inherited from Operator
Constructor Details
#initialize(source, return_type) ⇒ Set
Returns a new instance of Set.
317 318 319 320 |
# File 'lib/BOAST/Language/Operators.rb', line 317 def initialize(source, return_type) @source = source @return_type = return_type end |
Instance Attribute Details
#return_type ⇒ Object (readonly)
Returns the value of attribute return_type.
315 316 317 |
# File 'lib/BOAST/Language/Operators.rb', line 315 def return_type @return_type end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
314 315 316 |
# File 'lib/BOAST/Language/Operators.rb', line 314 def source @source end |
Instance Method Details
#pr ⇒ Object
359 360 361 362 363 364 365 366 |
# File 'lib/BOAST/Language/Operators.rb', line 359 def pr s="" s += indent s += to_s s += ";" if [C, CL, CUDA].include?( lang ) output.puts s return self end |
#to_s ⇒ Object
355 356 357 |
# File 'lib/BOAST/Language/Operators.rb', line 355 def to_s return to_var.to_s end |
#to_var ⇒ Object
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 |
# File 'lib/BOAST/Language/Operators.rb', line 326 def to_var if lang == C or lang == CL and @return_type.type.vector_length > 1 then if @source.kind_of?( Array ) then raise OperatorError, "Invalid array length!" unless @source.length == @return_type.type.vector_length return @return_type.copy("(#{@return_type.type.decl})( #{@source.join(", ")} )", DISCARD_OPTIONS) if lang == CL begin instruction = intrinsics(:SET, @return_type.type) return @return_type.copy("#{instruction}( #{@source.join(", ")} )", DISCARD_OPTIONS) rescue IntrinsicsError instruction = intrinsics(:SET_LANE, @return_type.type) s = Set(0, @return_type).to_s @source.each_with_index { |v,i| s = "#{instruction}(#{v}, #{s}, #{i})" } return @return_type.copy(s, DISCARD_OPTIONS) end elsif @source.class != Variable or @source.type.vector_length == 1 then return @return_type.copy("(#{@return_type.type.decl})( #{@source} )", DISCARD_OPTIONS) if lang == CL instruction = intrinsics(:SET1, @return_type.type) return @return_type.copy("#{instruction}( #{@source} )", DISCARD_OPTIONS) elsif @return_type.type != @source.type return @return_type.copy("#{Operator.convert(@source, @return_type.type)}", DISCARD_OPTIONS) end end return @return_type.copy("#{@source}", DISCARD_OPTIONS) end |
#type ⇒ Object
322 323 324 |
# File 'lib/BOAST/Language/Operators.rb', line 322 def type return @return_type.type end |