2023-05-25 17:20:16 +02:00
|
|
|
function compute(t::AbstractTask; data...)
|
|
|
|
error("Need to implement compute()")
|
|
|
|
end
|
|
|
|
|
|
|
|
function compute_effort(t::AbstractTask)
|
|
|
|
# default implementation using compute
|
|
|
|
error("Need to implement compute_effort()")
|
|
|
|
end
|
|
|
|
|
|
|
|
function data(t::AbstractTask)
|
|
|
|
error("Need to implement data()")
|
|
|
|
end
|
|
|
|
|
|
|
|
compute_effort(t::AbstractDataTask) = 0
|
|
|
|
compute(t::AbstractDataTask; data...) = data
|
|
|
|
data(t::AbstractDataTask) = getfield(t, :data)
|
|
|
|
|
|
|
|
data(t::AbstractComputeTask) = 0
|
|
|
|
|
2023-05-26 17:07:08 +02:00
|
|
|
function compute_effort(t::FusedComputeTask)
|
|
|
|
(T1, T2) = collect(typeof(t).parameters)
|
|
|
|
return compute_effort(T1()) + compute_effort(T2())
|
|
|
|
end
|
2023-05-25 17:20:16 +02:00
|
|
|
|
|
|
|
# actual compute functions for the tasks can stay undefined for now
|
|
|
|
# compute(t::ComputeTaskU, data::Any) = mycomputation(data)
|
|
|
|
|
2023-05-26 19:25:21 +02:00
|
|
|
function compute_intensity(t::AbstractTask)::UInt64
|
2023-05-25 17:20:16 +02:00
|
|
|
if data(t) == 0
|
2023-05-26 19:25:21 +02:00
|
|
|
return typemax(UInt64)
|
2023-05-25 17:20:16 +02:00
|
|
|
end
|
|
|
|
return compute_effort(t) / data(t)
|
|
|
|
end
|
|
|
|
|
2023-05-26 19:25:21 +02:00
|
|
|
function show(io::IO, t::FusedComputeTask)
|
2023-05-30 19:10:44 +02:00
|
|
|
(T1, T2) = get_types(t)
|
2023-05-26 19:25:21 +02:00
|
|
|
print(io, "ComputeFuse(", T1(), ", ", T2(), ")")
|
|
|
|
end
|
|
|
|
|
2023-05-25 17:20:16 +02:00
|
|
|
function ==(t1::AbstractTask, t2::AbstractTask)
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
|
|
|
function ==(t1::AbstractComputeTask, t2::AbstractComputeTask)
|
|
|
|
return typeof(t1) == typeof(t2)
|
|
|
|
end
|
|
|
|
|
|
|
|
function ==(t1::AbstractDataTask, t2::AbstractDataTask)
|
|
|
|
return data(t1) == data(t2)
|
|
|
|
end
|
2023-06-27 20:05:27 +02:00
|
|
|
|
2023-06-29 13:57:45 +02:00
|
|
|
copy(t::AbstractDataTask) = error("Need to implement copying for your data tasks!")
|
2023-06-27 20:05:27 +02:00
|
|
|
copy(t::AbstractComputeTask) = typeof(t)()
|