module Ikra::Translator::KernelLaunchArgumentGenerator

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.

Public Class Methods

generate_arg(input_command, relative_command, command_expr) click to toggle source
# 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) click to toggle source
# 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