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
|
|
|
|
|
|
|
|
# define compute_efforts tasks computation
|
|
|
|
# put some "random" numbers here for now
|
|
|
|
compute_effort(t::ComputeTaskS1) = 10
|
|
|
|
compute_effort(t::ComputeTaskS2) = 10
|
|
|
|
compute_effort(t::ComputeTaskU) = 6
|
|
|
|
compute_effort(t::ComputeTaskV) = 20
|
|
|
|
compute_effort(t::ComputeTaskP) = 15
|
2023-06-08 01:39:01 +02:00
|
|
|
compute_effort(t::ComputeTaskSum) = 1
|
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::DataTask)
|
|
|
|
print(io, "Data", t.data)
|
|
|
|
end
|
|
|
|
|
|
|
|
show(io::IO, t::ComputeTaskS1) = print("ComputeS1")
|
|
|
|
show(io::IO, t::ComputeTaskS2) = print("ComputeS2")
|
|
|
|
show(io::IO, t::ComputeTaskP) = print("ComputeP")
|
|
|
|
show(io::IO, t::ComputeTaskU) = print("ComputeU")
|
|
|
|
show(io::IO, t::ComputeTaskV) = print("ComputeV")
|
2023-06-08 01:39:01 +02:00
|
|
|
show(io::IO, t::ComputeTaskSum) = print("ComputeSum")
|
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
|
|
|
|
|
|
|
copy(t::DataTask) = DataTask(t.data)
|
|
|
|
copy(t::AbstractComputeTask) = typeof(t)()
|