Code Generation
Types
ComputableDAGs.FunctionCall — TypeFunctionCall{VAL_T<:Tuple,FUNC_T<:Union{Function,Expr}}Representation of a function call. Contains the function to call (or an expression of a value to assign), value arguments of type VAL_T, argument symbols, the return symbol(s) and type(s) and the device to execute on.
To support vectorization, i.e., calling the same function on multiple inputs (SIMD), the value arguments, arguments, and return symbols are each vectors of the actual inputs. In the non-vectorized case, these Vectors simply always have length 1. For this common case, a special constructor exists which automatically wraps each of these arguments in a Vector.
Type Arguments
VAL_T<:Tuple: A tuple of all the value arguments that are passed to the function when it's called.FUNC_T<:Union{Function, Expr}: The type of the function.Functionis the default, but in some cases, anExprof a value can be necessary to assign to the return symbol. In this case, no arguments are allowed.
Fields
func::FUNC_T: The function to be called, or an expression containing a value to assign to the return_symbol.value_arguments::Vector{VAL_T}: The value arguments for the function call. These are passed first to the function, in the order given here. TheVectorcontains the tuple of value arguments for each vectorization member.arguments::Vector{Vector{Symbol}}: The first vector represents the vectorization, the second layer represents the symbols that will be passed as arguments to the function call.return_symbols::Vector{Vector{Symbol}}: As with the arguments, the first vector level represents the vectorization, the second represents the symbols that the results of the function call are assigned to. For most function calls, there is only one return symbol. When using closures when generating a function body for aTape, the option to have multiple return symbols is necessary.device::AbstractDevice: The device that this function call is scheduled on.
ComputableDAGs.Tape — TypeTape{INPUT}Lowered representation of a computation, generated from a DAG through gen_tape.
INPUTthe input type of the problem instance, see also the interface functioninput_type
Fields
input_assign_code::Vector{FunctionCall}: TheFunctionCalls representing the input assignments, mapping part of the input of the computation to each DAG entry node. These functions are generated using the interface functioninput_expr.schedule::Vector{FunctionCall}: TheFunctionCalls representing the function body of the computation. There is one function call for each node in theDAG.output_symbol::Symbol: The symbol of the final calculated value, which is returned.instance::Any: The instance that this tape is generated for.machine::Machine: TheMachinethat this tape is generated for.
Function Generation
ComputableDAGs.compute_function — Functioncompute_function(
dag::DAG,
instance,
machine::Machine,
context_module::Module,
scheduler::AbstractScheduler = GreedyScheduler(),
)Return a function of signature compute_<id>(input::input_type(instance)), which will return the result of the DAG computation on the given input. The final argument context_module should always be @__MODULE__ to be able to use functions defined in the caller's environment.
ComputableDAGs.compute_function_expr — Methodcompute_function_expr(
dag::DAG,
instance,
machine::Machine,
scheduler::AbstractScheduler
)Helper function, returning the complete function expression.
Tape Machine
ComputableDAGs.gen_function_body — Methodgen_function_body(tape::Tape)Generate the function body from the given Tape.
ComputableDAGs.gen_input_assignment_code — Methodgen_input_assignment_code(
input_symbols::Dict{String, Vector{Symbol}},
instance::Any,
machine::Machine
)Return a Vector{FunctionCall} doing the input assignments from the given problem_input onto the input_symbols.
ComputableDAGs.gen_tape — Methodgen_tape(
dag::DAG,
instance::Any,
machine::Machine,
scheduler::AbstractScheduler,
)Generate the code for a given graph. The return value is a Tape.