Module: Ikra::Translator::KernelLaunchArgumentGenerator
- Defined in:
- lib/translator/array_command_struct_builder.rb
Overview
This class looks for ‘input_command` in the tree of commands (and inputs) provided by `relative_command`. It traverses this tree and generates and expression that can be used to access `input_command` from `relative_command`, which is represented by an array_command struct in the CUDA code and referenced with `command_expr`. TODO: This class should be a visitor, but we need to pass additional values (`path`) along the way.
Class Method Summary collapse
- .generate_arg(input_command, relative_command, command_expr) ⇒ Object
- .visit_array_command(input_command, command, path) ⇒ Object
Class Method Details
.generate_arg(input_command, relative_command, command_expr) ⇒ Object
10 11 12 |
# File 'lib/translator/array_command_struct_builder.rb', line 10 def self.generate_arg(input_command, relative_command, command_expr) return visit_array_command(input_command, relative_command, command_expr) end |
.visit_array_command(input_command, command, path) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/translator/array_command_struct_builder.rb', line 14 def self.visit_array_command(input_command, command, path) if command.is_a?(Symbolic::ArrayInHostSectionCommand) if command.equal?(input_command) # This should be passed as an argument return "((#{command.base_type.to_c_type} *) #{path}->input_0.content)" else # This is not the one we are looking for return nil end else command.input.each_with_index do |input, index| if input.command.is_a?(Symbolic::ArrayCommand) result = visit_array_command( input_command, input.command, "#{path}->input_#{index}") if result != nil return "((#{input_command.base_type.to_c_type} *) #{result})" end end end return nil end end |