49 lines
1.2 KiB
Julia
49 lines
1.2 KiB
Julia
|
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
|
||
|
|
||
|
# actual compute functions for the tasks can stay undefined for now
|
||
|
# compute(t::ComputeTaskU, data::Any) = mycomputation(data)
|
||
|
|
||
|
function computation_intensity(t::AbstractTask)::UInt32
|
||
|
if data(t) == 0
|
||
|
return typemax(UInt32)
|
||
|
end
|
||
|
return compute_effort(t) / data(t)
|
||
|
end
|
||
|
|
||
|
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
|