Start adding code generation

This commit is contained in:
Anton Reinhard
2023-08-31 18:24:48 +02:00
parent 32fcd069d7
commit f1edce258a
6 changed files with 251 additions and 10 deletions

View File

@ -7,6 +7,24 @@ function compute(t::AbstractTask; data...)
return error("Need to implement compute()")
end
"""
compute(t::FusedComputeTask; data...)
Compute a fused compute task.
"""
function compute(t::FusedComputeTask; data...)
(T1, T2) = collect(typeof(t).parameters)
return compute(T2(), compute(T1(), data))
end
"""
compute(t::AbstractDataTask; data...)
The compute function of a data task, always the identity function, regardless of the specific task.
"""
compute(t::AbstractDataTask; data...) = data
"""
compute_effort(t::AbstractTask)
@ -33,13 +51,6 @@ Return the compute effort of a data task, always zero, regardless of the specifi
"""
compute_effort(t::AbstractDataTask) = 0
"""
compute(t::AbstractDataTask; data...)
The compute function of a data task, always the identity function, regardless of the specific task.
"""
compute(t::AbstractDataTask; data...) = data
"""
data(t::AbstractDataTask)
@ -64,12 +75,32 @@ function compute_effort(t::FusedComputeTask)
return compute_effort(T1()) + compute_effort(T2())
end
# actual compute functions for the tasks can stay undefined for now
# compute(t::ComputeTaskU, data::Any) = mycomputation(data)
"""
get_types(::FusedComputeTask{T1, T2})
Return a tuple of a the fused compute task's components' types.
"""
get_types(::FusedComputeTask{T1, T2}) where {T1, T2} = (T1, T2)
"""
get_expression(t::AbstractTask)
Return an expression evaluating the given task on the :dataIn symbol
"""
function get_expression(t::AbstractTask)
return quote
dataOut = compute($t, dataIn)
end
end
"""
get_expression()
"""
function get_expression(t::FusedComputeTask, inSymbol::Symbol, outSymbol::Symbol)
#TODO
computeExp = quote
$outSymbol = compute($t, $inSymbol)
end
return computeExp
end