Shuffle files and functions around for more consistent naming and smaller files
This commit is contained in:
11
src/task/compare.jl
Normal file
11
src/task/compare.jl
Normal file
@@ -0,0 +1,11 @@
|
||||
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
|
4
src/task/print.jl
Normal file
4
src/task/print.jl
Normal file
@@ -0,0 +1,4 @@
|
||||
function show(io::IO, t::FusedComputeTask)
|
||||
(T1, T2) = get_types(t)
|
||||
print(io, "ComputeFuse(", T1(), ", ", T2(), ")")
|
||||
end
|
33
src/task/properties.jl
Normal file
33
src/task/properties.jl
Normal file
@@ -0,0 +1,33 @@
|
||||
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
|
||||
|
||||
function compute_effort(t::FusedComputeTask)
|
||||
(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
|
12
src/task/type.jl
Normal file
12
src/task/type.jl
Normal file
@@ -0,0 +1,12 @@
|
||||
abstract type AbstractTask end
|
||||
|
||||
abstract type AbstractComputeTask <: AbstractTask end
|
||||
abstract type AbstractDataTask <: AbstractTask 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::AbstractComputeTask) = typeof(t)()
|
Reference in New Issue
Block a user