@@ -1,11 +1,11 @@
|
||||
function ==(t1::AbstractTask, t2::AbstractTask)
|
||||
return false
|
||||
return false
|
||||
end
|
||||
|
||||
function ==(t1::AbstractComputeTask, t2::AbstractComputeTask)
|
||||
return typeof(t1) == typeof(t2)
|
||||
return typeof(t1) == typeof(t2)
|
||||
end
|
||||
|
||||
function ==(t1::AbstractDataTask, t2::AbstractDataTask)
|
||||
return data(t1) == data(t2)
|
||||
return data(t1) == data(t2)
|
||||
end
|
||||
|
@@ -1,4 +1,4 @@
|
||||
function show(io::IO, t::FusedComputeTask)
|
||||
(T1, T2) = get_types(t)
|
||||
print(io, "ComputeFuse(", T1(), ", ", T2(), ")")
|
||||
(T1, T2) = get_types(t)
|
||||
return print(io, "ComputeFuse(", T1(), ", ", T2(), ")")
|
||||
end
|
||||
|
@@ -1,14 +1,14 @@
|
||||
function compute(t::AbstractTask; data...)
|
||||
error("Need to implement compute()")
|
||||
return error("Need to implement compute()")
|
||||
end
|
||||
|
||||
function compute_effort(t::AbstractTask)
|
||||
# default implementation using compute
|
||||
error("Need to implement compute_effort()")
|
||||
# default implementation using compute
|
||||
return error("Need to implement compute_effort()")
|
||||
end
|
||||
|
||||
function data(t::AbstractTask)
|
||||
error("Need to implement data()")
|
||||
return error("Need to implement data()")
|
||||
end
|
||||
|
||||
compute_effort(t::AbstractDataTask) = 0
|
||||
@@ -18,16 +18,16 @@ data(t::AbstractDataTask) = getfield(t, :data)
|
||||
data(t::AbstractComputeTask) = 0
|
||||
|
||||
function compute_effort(t::FusedComputeTask)
|
||||
(T1, T2) = collect(typeof(t).parameters)
|
||||
return compute_effort(T1()) + compute_effort(T2())
|
||||
(T1, T2) = collect(typeof(t).parameters)
|
||||
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)
|
||||
|
||||
function compute_intensity(t::AbstractTask)::UInt64
|
||||
if data(t) == 0
|
||||
return typemax(UInt64)
|
||||
end
|
||||
return compute_effort(t) / data(t)
|
||||
end
|
||||
if data(t) == 0
|
||||
return typemax(UInt64)
|
||||
end
|
||||
return compute_effort(t) / data(t)
|
||||
end
|
||||
|
@@ -1,12 +1,13 @@
|
||||
abstract type AbstractTask end
|
||||
|
||||
abstract type AbstractComputeTask <: AbstractTask end
|
||||
abstract type AbstractDataTask <: AbstractTask end
|
||||
abstract type AbstractComputeTask <: AbstractTask end
|
||||
abstract type AbstractDataTask <: AbstractTask end
|
||||
|
||||
struct FusedComputeTask{T1<:AbstractComputeTask, T2<:AbstractComputeTask} <: AbstractComputeTask
|
||||
end
|
||||
struct FusedComputeTask{T1 <: AbstractComputeTask, T2 <: AbstractComputeTask} <:
|
||||
AbstractComputeTask end
|
||||
|
||||
get_types(::FusedComputeTask{T1, T2}) where {T1, T2} = (T1, T2)
|
||||
|
||||
copy(t::AbstractDataTask) = error("Need to implement copying for your data tasks!")
|
||||
copy(t::AbstractDataTask) =
|
||||
error("Need to implement copying for your data tasks!")
|
||||
copy(t::AbstractComputeTask) = typeof(t)()
|
||||
|
Reference in New Issue
Block a user