Renaming of ABC Model things, add QEDprocesses/QEDbase types and use them
This commit is contained in:
parent
938bf216e5
commit
fcb7c992da
@ -12,6 +12,7 @@ JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
|
||||
KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c"
|
||||
NumaAllocators = "21436f30-1b4a-4f08-87af-e26101bb5379"
|
||||
QEDbase = "10e22c08-3ccb-4172-bfcf-7d7aa3d04d93"
|
||||
QEDprocesses = "46de9c38-1bb3-4547-a1ec-da24d767fdad"
|
||||
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
|
||||
Roots = "f2b01f46-fcfa-551c-844a-d8ac1e96c665"
|
||||
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
|
||||
|
42
README.md
42
README.md
@ -50,8 +50,8 @@ Problems:
|
||||
|
||||
For graphs AB->AB^n:
|
||||
- Number of Sums should always be 1
|
||||
- Number of ComputeTaskS2 should always be (n+1)!
|
||||
- Number of ComputeTaskU should always be (n+3)
|
||||
- Number of ComputeTaskABC_S2 should always be (n+1)!
|
||||
- Number of ComputeTaskABC_U should always be (n+3)
|
||||
|
||||
Times are from my home machine: AMD Ryzen 7900X3D, 64GB DDR5 RAM @ 6000MHz (not necessarily up to date, check Jupyter Notebooks in `notebooks/` instead)
|
||||
|
||||
@ -59,9 +59,9 @@ Times are from my home machine: AMD Ryzen 7900X3D, 64GB DDR5 RAM @ 6000MHz (not
|
||||
$ julia --project examples/import_bench.jl
|
||||
AB->AB:
|
||||
Graph:
|
||||
Nodes: Total: 34, DataTask: 19, ComputeTaskP: 4,
|
||||
ComputeTaskS2: 2, ComputeTaskV: 4, ComputeTaskU: 4,
|
||||
ComputeTaskSum: 1
|
||||
Nodes: Total: 34, DataTask: 19, ComputeTaskABC_P: 4,
|
||||
ComputeTaskABC_S2: 2, ComputeTaskABC_V: 4, ComputeTaskABC_U: 4,
|
||||
ComputeTaskABC_Sum: 1
|
||||
Edges: 37
|
||||
Total Compute Effort: 185
|
||||
Total Data Transfer: 102
|
||||
@ -71,9 +71,9 @@ Graph:
|
||||
|
||||
AB->ABBB:
|
||||
Graph:
|
||||
Nodes: Total: 280, DataTask: 143, ComputeTaskP: 6,
|
||||
ComputeTaskS2: 24, ComputeTaskV: 64, ComputeTaskU: 6,
|
||||
ComputeTaskSum: 1, ComputeTaskS1: 36
|
||||
Nodes: Total: 280, DataTask: 143, ComputeTaskABC_P: 6,
|
||||
ComputeTaskABC_S2: 24, ComputeTaskABC_V: 64, ComputeTaskABC_U: 6,
|
||||
ComputeTaskABC_Sum: 1, ComputeTaskABC_S1: 36
|
||||
Edges: 385
|
||||
Total Compute Effort: 2007
|
||||
Total Data Transfer: 828
|
||||
@ -83,9 +83,9 @@ Graph:
|
||||
|
||||
AB->ABBBBB:
|
||||
Graph:
|
||||
Nodes: Total: 7854, DataTask: 3931, ComputeTaskP: 8,
|
||||
ComputeTaskS2: 720, ComputeTaskV: 1956, ComputeTaskU: 8,
|
||||
ComputeTaskSum: 1, ComputeTaskS1: 1230
|
||||
Nodes: Total: 7854, DataTask: 3931, ComputeTaskABC_P: 8,
|
||||
ComputeTaskABC_S2: 720, ComputeTaskABC_V: 1956, ComputeTaskABC_U: 8,
|
||||
ComputeTaskABC_Sum: 1, ComputeTaskABC_S1: 1230
|
||||
Edges: 11241
|
||||
Total Compute Effort: 58789
|
||||
Total Data Transfer: 23244
|
||||
@ -95,9 +95,9 @@ Graph:
|
||||
|
||||
AB->ABBBBBBB:
|
||||
Graph:
|
||||
Nodes: Total: 438436, DataTask: 219223, ComputeTaskP: 10,
|
||||
ComputeTaskS2: 40320, ComputeTaskV: 109600, ComputeTaskU: 10,
|
||||
ComputeTaskSum: 1, ComputeTaskS1: 69272
|
||||
Nodes: Total: 438436, DataTask: 219223, ComputeTaskABC_P: 10,
|
||||
ComputeTaskABC_S2: 40320, ComputeTaskABC_V: 109600, ComputeTaskABC_U: 10,
|
||||
ComputeTaskABC_Sum: 1, ComputeTaskABC_S1: 69272
|
||||
Edges: 628665
|
||||
Total Compute Effort: 3288131
|
||||
Total Data Transfer: 1297700
|
||||
@ -107,7 +107,7 @@ Graph:
|
||||
|
||||
AB->ABBBBBBBBB:
|
||||
Graph:
|
||||
Nodes: Total: 39456442, DataTask: 19728227, ComputeTaskS1: 6235290, ComputeTaskP: 12, ComputeTaskU: 12, ComputeTaskV: 9864100, ComputeTaskS2: 3628800, ComputeTaskSum: 1
|
||||
Nodes: Total: 39456442, DataTask: 19728227, ComputeTaskABC_S1: 6235290, ComputeTaskABC_P: 12, ComputeTaskABC_U: 12, ComputeTaskABC_V: 9864100, ComputeTaskABC_S2: 3628800, ComputeTaskABC_Sum: 1
|
||||
Edges: 56578129
|
||||
Total Compute Effort: 295923153
|
||||
Total Data Transfer: 175407750
|
||||
@ -116,9 +116,9 @@ Graph:
|
||||
|
||||
ABAB->ABAB:
|
||||
Graph:
|
||||
Nodes: Total: 3218, DataTask: 1613, ComputeTaskP: 8,
|
||||
ComputeTaskS2: 288, ComputeTaskV: 796, ComputeTaskU: 8,
|
||||
ComputeTaskSum: 1, ComputeTaskS1: 504
|
||||
Nodes: Total: 3218, DataTask: 1613, ComputeTaskABC_P: 8,
|
||||
ComputeTaskABC_S2: 288, ComputeTaskABC_V: 796, ComputeTaskABC_U: 8,
|
||||
ComputeTaskABC_Sum: 1, ComputeTaskABC_S1: 504
|
||||
Edges: 4581
|
||||
Total Compute Effort: 24009
|
||||
Total Data Transfer: 9494
|
||||
@ -128,9 +128,9 @@ Graph:
|
||||
|
||||
ABAB->ABC:
|
||||
Graph:
|
||||
Nodes: Total: 817, DataTask: 412, ComputeTaskP: 7,
|
||||
ComputeTaskS2: 72, ComputeTaskV: 198, ComputeTaskU: 7,
|
||||
ComputeTaskSum: 1, ComputeTaskS1: 120
|
||||
Nodes: Total: 817, DataTask: 412, ComputeTaskABC_P: 7,
|
||||
ComputeTaskABC_S2: 72, ComputeTaskABC_V: 198, ComputeTaskABC_U: 7,
|
||||
ComputeTaskABC_Sum: 1, ComputeTaskABC_S1: 120
|
||||
Edges: 1151
|
||||
Total Compute Effort: 6028
|
||||
Total Data Transfer: 2411
|
||||
|
@ -39,9 +39,9 @@
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Graph:\n",
|
||||
" Nodes: Total: 7854, ComputeTaskP: 8, ComputeTaskS2: 720, \n",
|
||||
" ComputeTaskU: 8, ComputeTaskSum: 1, ComputeTaskS1: 1230, \n",
|
||||
" ComputeTaskV: 1956, DataTask: 3931\n",
|
||||
" Nodes: Total: 7854, ComputeTaskABC_P: 8, ComputeTaskABC_S2: 720, \n",
|
||||
" ComputeTaskABC_U: 8, ComputeTaskABC_Sum: 1, ComputeTaskABC_S1: 1230, \n",
|
||||
" ComputeTaskABC_V: 1956, DataTask: 3931\n",
|
||||
" Edges: 11241\n",
|
||||
" Total Compute Effort: 33915.0\n",
|
||||
" Total Data Transfer: 322464.0\n",
|
||||
@ -88,9 +88,9 @@
|
||||
"text": [
|
||||
" 0.140021 seconds (791.41 k allocations: 30.317 MiB, 9.74% gc time)\n",
|
||||
"Graph:\n",
|
||||
" Nodes: Total: 4998, ComputeTaskP: 8, ComputeTaskS2: 720, \n",
|
||||
" ComputeTaskU: 8, ComputeTaskSum: 1, ComputeTaskS1: 516, \n",
|
||||
" ComputeTaskV: 1242, DataTask: 2503\n",
|
||||
" Nodes: Total: 4998, ComputeTaskABC_P: 8, ComputeTaskABC_S2: 720, \n",
|
||||
" ComputeTaskABC_U: 8, ComputeTaskABC_Sum: 1, ComputeTaskABC_S1: 516, \n",
|
||||
" ComputeTaskABC_V: 1242, DataTask: 2503\n",
|
||||
" Edges: 7671\n",
|
||||
" Total Compute Effort: 21777.0\n",
|
||||
" Total Data Transfer: 219648.0\n",
|
||||
|
@ -97,7 +97,7 @@
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Total: 280, ComputeTaskP"
|
||||
"Total: 280, ComputeTaskABC_P"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -119,9 +119,9 @@
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
": 6, ComputeTaskU: 6, \n",
|
||||
" ComputeTaskV: 64, ComputeTaskSum: 1, ComputeTaskS2: 24, \n",
|
||||
" ComputeTaskS1: 36, DataTask: 143"
|
||||
": 6, ComputeTaskABC_U: 6, \n",
|
||||
" ComputeTaskABC_V: 64, ComputeTaskABC_Sum: 1, ComputeTaskABC_S2: 24, \n",
|
||||
" ComputeTaskABC_S1: 36, DataTask: 143"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
@ -4,8 +4,8 @@ Run with 32 Threads
|
||||
|
||||
AB->AB:
|
||||
Graph:
|
||||
Nodes: Total: 34, ComputeTaskS2: 2, ComputeTaskU: 4,
|
||||
ComputeTaskSum: 1, ComputeTaskV: 4, ComputeTaskP: 4,
|
||||
Nodes: Total: 34, ComputeTaskABC_S2: 2, ComputeTaskABC_U: 4,
|
||||
ComputeTaskABC_Sum: 1, ComputeTaskABC_V: 4, ComputeTaskABC_P: 4,
|
||||
DataTask: 19
|
||||
Edges: 37
|
||||
Total Compute Effort: 185
|
||||
@ -27,9 +27,9 @@ Waiting...
|
||||
|
||||
AB->ABBB:
|
||||
Graph:
|
||||
Nodes: Total: 280, ComputeTaskS2: 24, ComputeTaskU: 6,
|
||||
ComputeTaskV: 64, ComputeTaskSum: 1, ComputeTaskP: 6,
|
||||
ComputeTaskS1: 36, DataTask: 143
|
||||
Nodes: Total: 280, ComputeTaskABC_S2: 24, ComputeTaskABC_U: 6,
|
||||
ComputeTaskABC_V: 64, ComputeTaskABC_Sum: 1, ComputeTaskABC_P: 6,
|
||||
ComputeTaskABC_S1: 36, DataTask: 143
|
||||
Edges: 385
|
||||
Total Compute Effort: 2007
|
||||
Total Data Transfer: 1176
|
||||
@ -50,9 +50,9 @@ Waiting...
|
||||
|
||||
AB->ABBBBB:
|
||||
Graph:
|
||||
Nodes: Total: 7854, ComputeTaskS2: 720, ComputeTaskU: 8,
|
||||
ComputeTaskV: 1956, ComputeTaskSum: 1, ComputeTaskP: 8,
|
||||
ComputeTaskS1: 1230, DataTask: 3931
|
||||
Nodes: Total: 7854, ComputeTaskABC_S2: 720, ComputeTaskABC_U: 8,
|
||||
ComputeTaskABC_V: 1956, ComputeTaskABC_Sum: 1, ComputeTaskABC_P: 8,
|
||||
ComputeTaskABC_S1: 1230, DataTask: 3931
|
||||
Edges: 11241
|
||||
Total Compute Effort: 58789
|
||||
Total Data Transfer: 34826
|
||||
@ -73,9 +73,9 @@ Waiting...
|
||||
|
||||
AB->ABBBBBBB:
|
||||
Graph:
|
||||
Nodes: Total: 438436, ComputeTaskS2: 40320, ComputeTaskU: 10,
|
||||
ComputeTaskV: 109600, ComputeTaskSum: 1, ComputeTaskP: 10,
|
||||
ComputeTaskS1: 69272, DataTask: 219223
|
||||
Nodes: Total: 438436, ComputeTaskABC_S2: 40320, ComputeTaskABC_U: 10,
|
||||
ComputeTaskABC_V: 109600, ComputeTaskABC_Sum: 1, ComputeTaskABC_P: 10,
|
||||
ComputeTaskABC_S1: 69272, DataTask: 219223
|
||||
Edges: 628665
|
||||
Total Compute Effort: 3288131
|
||||
Total Data Transfer: 1949004
|
||||
@ -96,9 +96,9 @@ Waiting...
|
||||
|
||||
AB->ABBBBBBBBB:
|
||||
Graph:
|
||||
Nodes: Total: 39456442, ComputeTaskS2: 3628800, ComputeTaskU: 12,
|
||||
ComputeTaskV: 9864100, ComputeTaskSum: 1, ComputeTaskP: 12,
|
||||
ComputeTaskS1: 6235290, DataTask: 19728227
|
||||
Nodes: Total: 39456442, ComputeTaskABC_S2: 3628800, ComputeTaskABC_U: 12,
|
||||
ComputeTaskABC_V: 9864100, ComputeTaskABC_Sum: 1, ComputeTaskABC_P: 12,
|
||||
ComputeTaskABC_S1: 6235290, DataTask: 19728227
|
||||
Edges: 56578129
|
||||
Total Compute Effort: 295923153
|
||||
Total Data Transfer: 175407750
|
||||
@ -119,9 +119,9 @@ Waiting...
|
||||
|
||||
ABAB->ABAB:
|
||||
Graph:
|
||||
Nodes: Total: 3218, ComputeTaskS2: 288, ComputeTaskU: 8,
|
||||
ComputeTaskV: 796, ComputeTaskSum: 1, ComputeTaskP: 8,
|
||||
ComputeTaskS1: 504, DataTask: 1613
|
||||
Nodes: Total: 3218, ComputeTaskABC_S2: 288, ComputeTaskABC_U: 8,
|
||||
ComputeTaskABC_V: 796, ComputeTaskABC_Sum: 1, ComputeTaskABC_P: 8,
|
||||
ComputeTaskABC_S1: 504, DataTask: 1613
|
||||
Edges: 4581
|
||||
Total Compute Effort: 24009
|
||||
Total Data Transfer: 14144
|
||||
@ -142,9 +142,9 @@ Waiting...
|
||||
|
||||
ABAB->ABC:
|
||||
Graph:
|
||||
Nodes: Total: 817, ComputeTaskS2: 72, ComputeTaskU: 7,
|
||||
ComputeTaskV: 198, ComputeTaskSum: 1, ComputeTaskP: 7,
|
||||
ComputeTaskS1: 120, DataTask: 412
|
||||
Nodes: Total: 817, ComputeTaskABC_S2: 72, ComputeTaskABC_U: 7,
|
||||
ComputeTaskABC_V: 198, ComputeTaskABC_Sum: 1, ComputeTaskABC_P: 7,
|
||||
ComputeTaskABC_S1: 120, DataTask: 412
|
||||
Edges: 1151
|
||||
Total Compute Effort: 6028
|
||||
Total Data Transfer: 3538
|
||||
|
@ -5,6 +5,8 @@ A module containing tools to work on DAGs.
|
||||
"""
|
||||
module MetagraphOptimization
|
||||
|
||||
using QEDbase
|
||||
|
||||
# graph types
|
||||
export DAG
|
||||
export Node
|
||||
@ -53,12 +55,12 @@ export get_operations
|
||||
export ParticleValue
|
||||
export ParticleA, ParticleB, ParticleC
|
||||
export ABCProcessDescription, ABCProcessInput, ABCModel
|
||||
export ComputeTaskP
|
||||
export ComputeTaskS1
|
||||
export ComputeTaskS2
|
||||
export ComputeTaskV
|
||||
export ComputeTaskU
|
||||
export ComputeTaskSum
|
||||
export ComputeTaskABC_P
|
||||
export ComputeTaskABC_S1
|
||||
export ComputeTaskABC_S2
|
||||
export ComputeTaskABC_V
|
||||
export ComputeTaskABC_U
|
||||
export ComputeTaskABC_Sum
|
||||
|
||||
# code generation related
|
||||
export execute
|
||||
|
@ -1,46 +1,46 @@
|
||||
using AccurateArithmetic
|
||||
|
||||
"""
|
||||
compute(::ComputeTaskP, data::ParticleValue)
|
||||
compute(::ComputeTaskABC_P, data::ABCParticleValue)
|
||||
|
||||
Return the particle and value as is.
|
||||
|
||||
0 FLOP.
|
||||
"""
|
||||
function compute(::ComputeTaskP, data::ParticleValue{P})::ParticleValue{P} where {P <: ABCParticle}
|
||||
function compute(::ComputeTaskABC_P, data::ABCParticleValue{P})::ABCParticleValue{P} where {P <: ABCParticle}
|
||||
return data
|
||||
end
|
||||
|
||||
"""
|
||||
compute(::ComputeTaskU, data::ParticleValue)
|
||||
compute(::ComputeTaskABC_U, data::ABCParticleValue)
|
||||
|
||||
Compute an outer edge. Return the particle value with the same particle and the value multiplied by an outer_edge factor.
|
||||
|
||||
1 FLOP.
|
||||
"""
|
||||
function compute(::ComputeTaskU, data::ParticleValue{P})::ParticleValue{P} where {P <: ABCParticle}
|
||||
return ParticleValue(data.p, data.v * outer_edge(data.p))
|
||||
function compute(::ComputeTaskABC_U, data::ABCParticleValue{P})::ABCParticleValue{P} where {P <: ABCParticle}
|
||||
return ABCParticleValue{P}(data.p, data.v * outer_edge(data.p))
|
||||
end
|
||||
|
||||
"""
|
||||
compute(::ComputeTaskV, data1::ParticleValue, data2::ParticleValue)
|
||||
compute(::ComputeTaskABC_V, data1::ABCParticleValue, data2::ABCParticleValue)
|
||||
|
||||
Compute a vertex. Preserve momentum and particle types (AB->C etc.) to create resulting particle, multiply values together and times a vertex factor.
|
||||
|
||||
6 FLOP.
|
||||
"""
|
||||
function compute(
|
||||
::ComputeTaskV,
|
||||
data1::ParticleValue{P1},
|
||||
data2::ParticleValue{P2},
|
||||
)::ParticleValue where {P1 <: ABCParticle, P2 <: ABCParticle}
|
||||
::ComputeTaskABC_V,
|
||||
data1::ABCParticleValue{P1},
|
||||
data2::ABCParticleValue{P2},
|
||||
)::ABCParticleValue where {P1 <: ABCParticle, P2 <: ABCParticle}
|
||||
p3 = preserve_momentum(data1.p, data2.p)
|
||||
dataOut = ParticleValue(p3, data1.v * vertex() * data2.v)
|
||||
dataOut = ABCParticleValue{typeof(p3)}(p3, data1.v * vertex() * data2.v)
|
||||
return dataOut
|
||||
end
|
||||
|
||||
"""
|
||||
compute(::ComputeTaskS2, data1::ParticleValue, data2::ParticleValue)
|
||||
compute(::ComputeTaskABC_S2, data1::ABCParticleValue, data2::ABCParticleValue)
|
||||
|
||||
Compute a final inner edge (2 input particles, no output particle).
|
||||
|
||||
@ -48,7 +48,11 @@ For valid inputs, both input particles should have the same momenta at this poin
|
||||
|
||||
12 FLOP.
|
||||
"""
|
||||
function compute(::ComputeTaskS2, data1::ParticleValue{P}, data2::ParticleValue{P})::Float64 where {P <: ABCParticle}
|
||||
function compute(
|
||||
::ComputeTaskABC_S2,
|
||||
data1::ParticleValue{P},
|
||||
data2::ParticleValue{P},
|
||||
)::Float64 where {P <: ABCParticle}
|
||||
#=
|
||||
@assert isapprox(abs(data1.p.momentum.E), abs(data2.p.momentum.E), rtol = 0.001, atol = sqrt(eps())) "E: $(data1.p.momentum.E) vs. $(data2.p.momentum.E)"
|
||||
@assert isapprox(data1.p.momentum.px, -data2.p.momentum.px, rtol = 0.001, atol = sqrt(eps())) "px: $(data1.p.momentum.px) vs. $(data2.p.momentum.px)"
|
||||
@ -60,100 +64,100 @@ function compute(::ComputeTaskS2, data1::ParticleValue{P}, data2::ParticleValue{
|
||||
end
|
||||
|
||||
"""
|
||||
compute(::ComputeTaskS1, data::ParticleValue)
|
||||
compute(::ComputeTaskABC_S1, data::ABCParticleValue)
|
||||
|
||||
Compute inner edge (1 input particle, 1 output particle).
|
||||
|
||||
11 FLOP.
|
||||
"""
|
||||
function compute(::ComputeTaskS1, data::ParticleValue{P})::ParticleValue{P} where {P <: ABCParticle}
|
||||
return ParticleValue(data.p, data.v * inner_edge(data.p))
|
||||
function compute(::ComputeTaskABC_S1, data::ABCParticleValue{P})::ABCParticleValue{P} where {P <: ABCParticle}
|
||||
return ABCParticleValue{P}(data.p, data.v * inner_edge(data.p))
|
||||
end
|
||||
|
||||
"""
|
||||
compute(::ComputeTaskSum, data::Vector{Float64})
|
||||
compute(::ComputeTaskABC_Sum, data::Vector{Float64})
|
||||
|
||||
Compute a sum over the vector. Use an algorithm that accounts for accumulated errors in long sums with potentially large differences in magnitude of the summands.
|
||||
|
||||
Linearly many FLOP with growing data.
|
||||
"""
|
||||
function compute(::ComputeTaskSum, data::Vector{Float64})::Float64
|
||||
function compute(::ComputeTaskABC_Sum, data::Vector{Float64})::Float64
|
||||
return sum_kbn(data)
|
||||
end
|
||||
|
||||
"""
|
||||
get_expression(::ComputeTaskP, device::AbstractDevice, inExprs::Vector{Expr}, outExpr::Expr)
|
||||
get_expression(::ComputeTaskABC_P, device::AbstractDevice, inExprs::Vector{Expr}, outExpr::Expr)
|
||||
|
||||
Generate and return code evaluating [`ComputeTaskP`](@ref) on `inSyms`, providing the output on `outSym`.
|
||||
Generate and return code evaluating [`ComputeTaskABC_P`](@ref) on `inSyms`, providing the output on `outSym`.
|
||||
"""
|
||||
function get_expression(::ComputeTaskP, device::AbstractDevice, inExprs::Vector, outExpr)
|
||||
function get_expression(::ComputeTaskABC_P, device::AbstractDevice, inExprs::Vector, outExpr)
|
||||
in = [eval(inExprs[1])]
|
||||
out = eval(outExpr)
|
||||
|
||||
return Meta.parse("$out = compute(ComputeTaskP(), $(in[1]))")
|
||||
return Meta.parse("$out = compute(ComputeTaskABC_P(), $(in[1]))")
|
||||
end
|
||||
|
||||
"""
|
||||
get_expression(::ComputeTaskU, device::AbstractDevice, inExprs::Vector{Expr}, outExpr::Expr)
|
||||
get_expression(::ComputeTaskABC_U, device::AbstractDevice, inExprs::Vector{Expr}, outExpr::Expr)
|
||||
|
||||
Generate code evaluating [`ComputeTaskU`](@ref) on `inSyms`, providing the output on `outSym`.
|
||||
`inSyms` should be of type [`ParticleValue`](@ref), `outSym` will be of type [`ParticleValue`](@ref).
|
||||
Generate code evaluating [`ComputeTaskABC_U`](@ref) on `inSyms`, providing the output on `outSym`.
|
||||
`inSyms` should be of type [`ABCParticleValue`](@ref), `outSym` will be of type [`ABCParticleValue`](@ref).
|
||||
"""
|
||||
function get_expression(::ComputeTaskU, device::AbstractDevice, inExprs::Vector, outExpr)
|
||||
function get_expression(::ComputeTaskABC_U, device::AbstractDevice, inExprs::Vector, outExpr)
|
||||
in = [eval(inExprs[1])]
|
||||
out = eval(outExpr)
|
||||
|
||||
return Meta.parse("$out = compute(ComputeTaskU(), $(in[1]))")
|
||||
return Meta.parse("$out = compute(ComputeTaskABC_U(), $(in[1]))")
|
||||
end
|
||||
|
||||
"""
|
||||
get_expression(::ComputeTaskV, device::AbstractDevice, inExprs::Vector{Expr}, outExpr::Expr)
|
||||
get_expression(::ComputeTaskABC_V, device::AbstractDevice, inExprs::Vector{Expr}, outExpr::Expr)
|
||||
|
||||
Generate code evaluating [`ComputeTaskV`](@ref) on `inSyms`, providing the output on `outSym`.
|
||||
`inSym[1]` and `inSym[2]` should be of type [`ParticleValue`](@ref), `outSym` will be of type [`ParticleValue`](@ref).
|
||||
Generate code evaluating [`ComputeTaskABC_V`](@ref) on `inSyms`, providing the output on `outSym`.
|
||||
`inSym[1]` and `inSym[2]` should be of type [`ABCParticleValue`](@ref), `outSym` will be of type [`ABCParticleValue`](@ref).
|
||||
"""
|
||||
function get_expression(::ComputeTaskV, device::AbstractDevice, inExprs::Vector, outExpr)
|
||||
function get_expression(::ComputeTaskABC_V, device::AbstractDevice, inExprs::Vector, outExpr)
|
||||
in = [eval(inExprs[1]), eval(inExprs[2])]
|
||||
out = eval(outExpr)
|
||||
|
||||
return Meta.parse("$out = compute(ComputeTaskV(), $(in[1]), $(in[2]))")
|
||||
return Meta.parse("$out = compute(ComputeTaskABC_V(), $(in[1]), $(in[2]))")
|
||||
end
|
||||
|
||||
"""
|
||||
get_expression(::ComputeTaskS2, device::AbstractDevice, inExprs::Vector{Expr}, outExpr::Expr)
|
||||
get_expression(::ComputeTaskABC_S2, device::AbstractDevice, inExprs::Vector{Expr}, outExpr::Expr)
|
||||
|
||||
Generate code evaluating [`ComputeTaskS2`](@ref) on `inSyms`, providing the output on `outSym`.
|
||||
`inSyms[1]` and `inSyms[2]` should be of type [`ParticleValue`](@ref), `outSym` will be of type `Float64`.
|
||||
Generate code evaluating [`ComputeTaskABC_S2`](@ref) on `inSyms`, providing the output on `outSym`.
|
||||
`inSyms[1]` and `inSyms[2]` should be of type [`ABCParticleValue`](@ref), `outSym` will be of type `Float64`.
|
||||
"""
|
||||
function get_expression(::ComputeTaskS2, device::AbstractDevice, inExprs::Vector, outExpr)
|
||||
function get_expression(::ComputeTaskABC_S2, device::AbstractDevice, inExprs::Vector, outExpr)
|
||||
in = [eval(inExprs[1]), eval(inExprs[2])]
|
||||
out = eval(outExpr)
|
||||
|
||||
return Meta.parse("$out = compute(ComputeTaskS2(), $(in[1]), $(in[2]))")
|
||||
return Meta.parse("$out = compute(ComputeTaskABC_S2(), $(in[1]), $(in[2]))")
|
||||
end
|
||||
|
||||
"""
|
||||
get_expression(::ComputeTaskS1, device::AbstractDevice, inExprs::Vector{Expr}, outExpr::Expr)
|
||||
get_expression(::ComputeTaskABC_S1, device::AbstractDevice, inExprs::Vector{Expr}, outExpr::Expr)
|
||||
|
||||
Generate code evaluating [`ComputeTaskS1`](@ref) on `inSyms`, providing the output on `outSym`.
|
||||
`inSyms` should be of type [`ParticleValue`](@ref), `outSym` will be of type [`ParticleValue`](@ref).
|
||||
Generate code evaluating [`ComputeTaskABC_S1`](@ref) on `inSyms`, providing the output on `outSym`.
|
||||
`inSyms` should be of type [`ABCParticleValue`](@ref), `outSym` will be of type [`ABCParticleValue`](@ref).
|
||||
"""
|
||||
function get_expression(::ComputeTaskS1, device::AbstractDevice, inExprs::Vector, outExpr)
|
||||
function get_expression(::ComputeTaskABC_S1, device::AbstractDevice, inExprs::Vector, outExpr)
|
||||
in = [eval(inExprs[1])]
|
||||
out = eval(outExpr)
|
||||
|
||||
return Meta.parse("$out = compute(ComputeTaskS1(), $(in[1]))")
|
||||
return Meta.parse("$out = compute(ComputeTaskABC_S1(), $(in[1]))")
|
||||
end
|
||||
|
||||
"""
|
||||
get_expression(::ComputeTaskSum, device::AbstractDevice, inExprs::Vector{Expr}, outExpr::Expr)
|
||||
get_expression(::ComputeTaskABC_Sum, device::AbstractDevice, inExprs::Vector{Expr}, outExpr::Expr)
|
||||
|
||||
Generate code evaluating [`ComputeTaskSum`](@ref) on `inSyms`, providing the output on `outSym`.
|
||||
Generate code evaluating [`ComputeTaskABC_Sum`](@ref) on `inSyms`, providing the output on `outSym`.
|
||||
`inSyms` should be of type [`Float64`], `outSym` will be of type [`Float64`].
|
||||
"""
|
||||
function get_expression(::ComputeTaskSum, device::AbstractDevice, inExprs::Vector, outExpr)
|
||||
function get_expression(::ComputeTaskABC_Sum, device::AbstractDevice, inExprs::Vector, outExpr)
|
||||
in = eval.(inExprs)
|
||||
out = eval(outExpr)
|
||||
|
||||
return Meta.parse("$out = compute(ComputeTaskSum(), [$(unroll_symbol_vector(in))])")
|
||||
return Meta.parse("$out = compute(ComputeTaskABC_Sum(), [$(unroll_symbol_vector(in))])")
|
||||
end
|
||||
|
@ -3,7 +3,7 @@ using Random
|
||||
using Roots
|
||||
using ForwardDiff
|
||||
|
||||
ComputeTaskSum() = ComputeTaskSum(0)
|
||||
ComputeTaskABC_Sum() = ComputeTaskABC_Sum(0)
|
||||
|
||||
"""
|
||||
gen_process_input(processDescription::ABCProcessDescription)
|
||||
|
@ -63,7 +63,7 @@ function parse_dag(filename::AbstractString, model::ABCModel, verbose::Bool = fa
|
||||
end
|
||||
sizehint!(graph.nodes, estimate_no_nodes)
|
||||
|
||||
sum_node = insert_node!(graph, make_node(ComputeTaskSum(0)), track = false, invalidate_cache = false)
|
||||
sum_node = insert_node!(graph, make_node(ComputeTaskABC_Sum(0)), track = false, invalidate_cache = false)
|
||||
global_data_out = insert_node!(graph, make_node(DataTask(FLOAT_SIZE)), track = false, invalidate_cache = false)
|
||||
insert_edge!(graph, sum_node, global_data_out, track = false, invalidate_cache = false)
|
||||
|
||||
@ -92,12 +92,12 @@ function parse_dag(filename::AbstractString, model::ABCModel, verbose::Bool = fa
|
||||
track = false,
|
||||
invalidate_cache = false,
|
||||
) # read particle data node
|
||||
compute_P = insert_node!(graph, make_node(ComputeTaskP()), track = false, invalidate_cache = false) # compute P node
|
||||
compute_P = insert_node!(graph, make_node(ComputeTaskABC_P()), track = false, invalidate_cache = false) # compute P node
|
||||
data_Pu =
|
||||
insert_node!(graph, make_node(DataTask(PARTICLE_VALUE_SIZE)), track = false, invalidate_cache = false) # transfer data from P to u (one ParticleValue object)
|
||||
compute_u = insert_node!(graph, make_node(ComputeTaskU()), track = false, invalidate_cache = false) # compute U node
|
||||
insert_node!(graph, make_node(DataTask(PARTICLE_VALUE_SIZE)), track = false, invalidate_cache = false) # transfer data from P to u (one ABCParticleValue object)
|
||||
compute_u = insert_node!(graph, make_node(ComputeTaskABC_U()), track = false, invalidate_cache = false) # compute U node
|
||||
data_out =
|
||||
insert_node!(graph, make_node(DataTask(PARTICLE_VALUE_SIZE)), track = false, invalidate_cache = false) # transfer data out from u (one ParticleValue object)
|
||||
insert_node!(graph, make_node(DataTask(PARTICLE_VALUE_SIZE)), track = false, invalidate_cache = false) # transfer data out from u (one ABCParticleValue object)
|
||||
|
||||
insert_edge!(graph, data_in, compute_P, track = false, invalidate_cache = false)
|
||||
insert_edge!(graph, compute_P, data_Pu, track = false, invalidate_cache = false)
|
||||
@ -112,13 +112,13 @@ function parse_dag(filename::AbstractString, model::ABCModel, verbose::Bool = fa
|
||||
in1 = capt.captures[1]
|
||||
in2 = capt.captures[2]
|
||||
|
||||
compute_v = insert_node!(graph, make_node(ComputeTaskV()), track = false, invalidate_cache = false)
|
||||
compute_v = insert_node!(graph, make_node(ComputeTaskABC_V()), track = false, invalidate_cache = false)
|
||||
data_out =
|
||||
insert_node!(graph, make_node(DataTask(PARTICLE_VALUE_SIZE)), track = false, invalidate_cache = false)
|
||||
|
||||
if (occursin(regex_c, in1))
|
||||
# put an S node after this input
|
||||
compute_S = insert_node!(graph, make_node(ComputeTaskS1()), track = false, invalidate_cache = false)
|
||||
compute_S = insert_node!(graph, make_node(ComputeTaskABC_S1()), track = false, invalidate_cache = false)
|
||||
data_S_v = insert_node!(
|
||||
graph,
|
||||
make_node(DataTask(PARTICLE_VALUE_SIZE)),
|
||||
@ -137,7 +137,7 @@ function parse_dag(filename::AbstractString, model::ABCModel, verbose::Bool = fa
|
||||
if (occursin(regex_c, in2))
|
||||
# i think the current generator only puts the combined particles in the first space, so this case might never be entered
|
||||
# put an S node after this input
|
||||
compute_S = insert_node!(graph, make_node(ComputeTaskS1()), track = false, invalidate_cache = false)
|
||||
compute_S = insert_node!(graph, make_node(ComputeTaskABC_S1()), track = false, invalidate_cache = false)
|
||||
data_S_v = insert_node!(
|
||||
graph,
|
||||
make_node(DataTask(PARTICLE_VALUE_SIZE)),
|
||||
@ -164,7 +164,7 @@ function parse_dag(filename::AbstractString, model::ABCModel, verbose::Bool = fa
|
||||
in3 = capt.captures[3]
|
||||
|
||||
# in2 + in3 with a v
|
||||
compute_v = insert_node!(graph, make_node(ComputeTaskV()), track = false, invalidate_cache = false)
|
||||
compute_v = insert_node!(graph, make_node(ComputeTaskABC_V()), track = false, invalidate_cache = false)
|
||||
data_v =
|
||||
insert_node!(graph, make_node(DataTask(PARTICLE_VALUE_SIZE)), track = false, invalidate_cache = false)
|
||||
|
||||
@ -173,7 +173,7 @@ function parse_dag(filename::AbstractString, model::ABCModel, verbose::Bool = fa
|
||||
insert_edge!(graph, compute_v, data_v, track = false, invalidate_cache = false)
|
||||
|
||||
# combine with the v of the combined other input
|
||||
compute_S2 = insert_node!(graph, make_node(ComputeTaskS2()), track = false, invalidate_cache = false)
|
||||
compute_S2 = insert_node!(graph, make_node(ComputeTaskABC_S2()), track = false, invalidate_cache = false)
|
||||
data_out = insert_node!(graph, make_node(DataTask(FLOAT_SIZE)), track = false, invalidate_cache = false) # output of a S2 task is only a float
|
||||
|
||||
insert_edge!(graph, data_v, compute_S2, track = false, invalidate_cache = false)
|
||||
|
@ -1,5 +1,3 @@
|
||||
using QEDbase
|
||||
|
||||
import QEDbase.mass
|
||||
|
||||
"""
|
||||
@ -68,6 +66,8 @@ struct ABCProcessInput <: AbstractProcessInput
|
||||
outParticles::Vector{ABCParticle}
|
||||
end
|
||||
|
||||
ABCParticleValue{ParticleType <: ABCParticle} = ParticleValue{ParticleType, Float64}
|
||||
|
||||
"""
|
||||
PARTICLE_MASSES
|
||||
|
||||
|
@ -1,155 +1,132 @@
|
||||
"""
|
||||
compute_effort(t::ComputeTaskS1)
|
||||
compute_effort(t::ComputeTaskABC_S1)
|
||||
|
||||
Return the compute effort of an S1 task.
|
||||
"""
|
||||
compute_effort(t::ComputeTaskS1)::Float64 = 11.0
|
||||
compute_effort(t::ComputeTaskABC_S1)::Float64 = 11.0
|
||||
|
||||
"""
|
||||
compute_effort(t::ComputeTaskS2)
|
||||
compute_effort(t::ComputeTaskABC_S2)
|
||||
|
||||
Return the compute effort of an S2 task.
|
||||
"""
|
||||
compute_effort(t::ComputeTaskS2)::Float64 = 12.0
|
||||
compute_effort(t::ComputeTaskABC_S2)::Float64 = 12.0
|
||||
|
||||
"""
|
||||
compute_effort(t::ComputeTaskU)
|
||||
compute_effort(t::ComputeTaskABC_U)
|
||||
|
||||
Return the compute effort of a U task.
|
||||
"""
|
||||
compute_effort(t::ComputeTaskU)::Float64 = 1.0
|
||||
compute_effort(t::ComputeTaskABC_U)::Float64 = 1.0
|
||||
|
||||
"""
|
||||
compute_effort(t::ComputeTaskV)
|
||||
compute_effort(t::ComputeTaskABC_V)
|
||||
|
||||
Return the compute effort of a V task.
|
||||
"""
|
||||
compute_effort(t::ComputeTaskV)::Float64 = 6.0
|
||||
compute_effort(t::ComputeTaskABC_V)::Float64 = 6.0
|
||||
|
||||
"""
|
||||
compute_effort(t::ComputeTaskP)
|
||||
compute_effort(t::ComputeTaskABC_P)
|
||||
|
||||
Return the compute effort of a P task.
|
||||
"""
|
||||
compute_effort(t::ComputeTaskP)::Float64 = 0.0
|
||||
compute_effort(t::ComputeTaskABC_P)::Float64 = 0.0
|
||||
|
||||
"""
|
||||
compute_effort(t::ComputeTaskSum)
|
||||
compute_effort(t::ComputeTaskABC_Sum)
|
||||
|
||||
Return the compute effort of a Sum task.
|
||||
|
||||
Note: This is a constant compute effort, even though sum scales with the number of its inputs. Since there is only ever a single sum node in a graph generated from the ABC-Model,
|
||||
this doesn't matter.
|
||||
"""
|
||||
compute_effort(t::ComputeTaskSum)::Float64 = 1.0
|
||||
compute_effort(t::ComputeTaskABC_Sum)::Float64 = 1.0
|
||||
|
||||
"""
|
||||
show(io::IO, t::DataTask)
|
||||
|
||||
Print the data task to io.
|
||||
"""
|
||||
function show(io::IO, t::DataTask)
|
||||
return print(io, "Data", t.data)
|
||||
end
|
||||
|
||||
"""
|
||||
show(io::IO, t::ComputeTaskS1)
|
||||
show(io::IO, t::ComputeTaskABC_S1)
|
||||
|
||||
Print the S1 task to io.
|
||||
"""
|
||||
show(io::IO, t::ComputeTaskS1) = print(io, "ComputeS1")
|
||||
show(io::IO, t::ComputeTaskABC_S1) = print(io, "ComputeS1")
|
||||
|
||||
"""
|
||||
show(io::IO, t::ComputeTaskS2)
|
||||
show(io::IO, t::ComputeTaskABC_S2)
|
||||
|
||||
Print the S2 task to io.
|
||||
"""
|
||||
show(io::IO, t::ComputeTaskS2) = print(io, "ComputeS2")
|
||||
show(io::IO, t::ComputeTaskABC_S2) = print(io, "ComputeS2")
|
||||
|
||||
"""
|
||||
show(io::IO, t::ComputeTaskP)
|
||||
show(io::IO, t::ComputeTaskABC_P)
|
||||
|
||||
Print the P task to io.
|
||||
"""
|
||||
show(io::IO, t::ComputeTaskP) = print(io, "ComputeP")
|
||||
show(io::IO, t::ComputeTaskABC_P) = print(io, "ComputeP")
|
||||
|
||||
"""
|
||||
show(io::IO, t::ComputeTaskU)
|
||||
show(io::IO, t::ComputeTaskABC_U)
|
||||
|
||||
Print the U task to io.
|
||||
"""
|
||||
show(io::IO, t::ComputeTaskU) = print(io, "ComputeU")
|
||||
show(io::IO, t::ComputeTaskABC_U) = print(io, "ComputeU")
|
||||
|
||||
"""
|
||||
show(io::IO, t::ComputeTaskV)
|
||||
show(io::IO, t::ComputeTaskABC_V)
|
||||
|
||||
Print the V task to io.
|
||||
"""
|
||||
show(io::IO, t::ComputeTaskV) = print(io, "ComputeV")
|
||||
show(io::IO, t::ComputeTaskABC_V) = print(io, "ComputeV")
|
||||
|
||||
"""
|
||||
show(io::IO, t::ComputeTaskSum)
|
||||
show(io::IO, t::ComputeTaskABC_Sum)
|
||||
|
||||
Print the sum task to io.
|
||||
"""
|
||||
show(io::IO, t::ComputeTaskSum) = print(io, "ComputeSum")
|
||||
show(io::IO, t::ComputeTaskABC_Sum) = print(io, "ComputeSum")
|
||||
|
||||
"""
|
||||
copy(t::DataTask)
|
||||
children(::ComputeTaskABC_S1)
|
||||
|
||||
Copy the data task and return it.
|
||||
Return the number of children of a ComputeTaskABC_S1 (always 1).
|
||||
"""
|
||||
copy(t::DataTask) = DataTask(t.data)
|
||||
children(::ComputeTaskABC_S1) = 1
|
||||
|
||||
"""
|
||||
children(::DataTask)
|
||||
children(::ComputeTaskABC_S2)
|
||||
|
||||
Return the number of children of a data task (always 1).
|
||||
Return the number of children of a ComputeTaskABC_S2 (always 2).
|
||||
"""
|
||||
children(::DataTask) = 1
|
||||
children(::ComputeTaskABC_S2) = 2
|
||||
|
||||
"""
|
||||
children(::ComputeTaskS1)
|
||||
children(::ComputeTaskABC_P)
|
||||
|
||||
Return the number of children of a ComputeTaskS1 (always 1).
|
||||
Return the number of children of a ComputeTaskABC_P (always 1).
|
||||
"""
|
||||
children(::ComputeTaskS1) = 1
|
||||
children(::ComputeTaskABC_P) = 1
|
||||
|
||||
"""
|
||||
children(::ComputeTaskS2)
|
||||
children(::ComputeTaskABC_U)
|
||||
|
||||
Return the number of children of a ComputeTaskS2 (always 2).
|
||||
Return the number of children of a ComputeTaskABC_U (always 1).
|
||||
"""
|
||||
children(::ComputeTaskS2) = 2
|
||||
children(::ComputeTaskABC_U) = 1
|
||||
|
||||
"""
|
||||
children(::ComputeTaskP)
|
||||
children(::ComputeTaskABC_V)
|
||||
|
||||
Return the number of children of a ComputeTaskP (always 1).
|
||||
Return the number of children of a ComputeTaskABC_V (always 2).
|
||||
"""
|
||||
children(::ComputeTaskP) = 1
|
||||
|
||||
"""
|
||||
children(::ComputeTaskU)
|
||||
|
||||
Return the number of children of a ComputeTaskU (always 1).
|
||||
"""
|
||||
children(::ComputeTaskU) = 1
|
||||
|
||||
"""
|
||||
children(::ComputeTaskV)
|
||||
|
||||
Return the number of children of a ComputeTaskV (always 2).
|
||||
"""
|
||||
children(::ComputeTaskV) = 2
|
||||
children(::ComputeTaskABC_V) = 2
|
||||
|
||||
|
||||
"""
|
||||
children(::ComputeTaskSum)
|
||||
children(::ComputeTaskABC_Sum)
|
||||
|
||||
Return the number of children of a ComputeTaskSum.
|
||||
Return the number of children of a ComputeTaskABC_Sum.
|
||||
"""
|
||||
children(t::ComputeTaskSum) = t.children_number
|
||||
children(t::ComputeTaskABC_Sum) = t.children_number
|
||||
|
||||
"""
|
||||
children(t::FusedComputeTask)
|
||||
@ -160,7 +137,7 @@ function children(t::FusedComputeTask)
|
||||
return length(union(Set(t.t1_inputs), Set(t.t2_inputs)))
|
||||
end
|
||||
|
||||
function add_child!(t::ComputeTaskSum)
|
||||
function add_child!(t::ComputeTaskABC_Sum)
|
||||
t.children_number += 1
|
||||
return nothing
|
||||
end
|
||||
|
@ -1,53 +1,44 @@
|
||||
"""
|
||||
DataTask <: AbstractDataTask
|
||||
|
||||
Task representing a specific data transfer in the ABC Model.
|
||||
"""
|
||||
struct DataTask <: AbstractDataTask
|
||||
data::Float64
|
||||
end
|
||||
|
||||
"""
|
||||
ComputeTaskS1 <: AbstractComputeTask
|
||||
ComputeTaskABC_S1 <: AbstractComputeTask
|
||||
|
||||
S task with a single child.
|
||||
"""
|
||||
struct ComputeTaskS1 <: AbstractComputeTask end
|
||||
struct ComputeTaskABC_S1 <: AbstractComputeTask end
|
||||
|
||||
"""
|
||||
ComputeTaskS2 <: AbstractComputeTask
|
||||
ComputeTaskABC_S2 <: AbstractComputeTask
|
||||
|
||||
S task with two children.
|
||||
"""
|
||||
struct ComputeTaskS2 <: AbstractComputeTask end
|
||||
struct ComputeTaskABC_S2 <: AbstractComputeTask end
|
||||
|
||||
"""
|
||||
ComputeTaskP <: AbstractComputeTask
|
||||
ComputeTaskABC_P <: AbstractComputeTask
|
||||
|
||||
P task with no children.
|
||||
"""
|
||||
struct ComputeTaskP <: AbstractComputeTask end
|
||||
struct ComputeTaskABC_P <: AbstractComputeTask end
|
||||
|
||||
"""
|
||||
ComputeTaskV <: AbstractComputeTask
|
||||
ComputeTaskABC_V <: AbstractComputeTask
|
||||
|
||||
v task with two children.
|
||||
"""
|
||||
struct ComputeTaskV <: AbstractComputeTask end
|
||||
struct ComputeTaskABC_V <: AbstractComputeTask end
|
||||
|
||||
"""
|
||||
ComputeTaskU <: AbstractComputeTask
|
||||
ComputeTaskABC_U <: AbstractComputeTask
|
||||
|
||||
u task with a single child.
|
||||
"""
|
||||
struct ComputeTaskU <: AbstractComputeTask end
|
||||
struct ComputeTaskABC_U <: AbstractComputeTask end
|
||||
|
||||
"""
|
||||
ComputeTaskSum <: AbstractComputeTask
|
||||
ComputeTaskABC_Sum <: AbstractComputeTask
|
||||
|
||||
Task that sums all its inputs, n children.
|
||||
"""
|
||||
mutable struct ComputeTaskSum <: AbstractComputeTask
|
||||
mutable struct ComputeTaskABC_Sum <: AbstractComputeTask
|
||||
children_number::Int
|
||||
end
|
||||
|
||||
@ -56,4 +47,5 @@ end
|
||||
|
||||
Constant vector of all tasks of the ABC-Model.
|
||||
"""
|
||||
ABC_TASKS = [DataTask, ComputeTaskS1, ComputeTaskS2, ComputeTaskP, ComputeTaskV, ComputeTaskU, ComputeTaskSum]
|
||||
ABC_TASKS =
|
||||
[ComputeTaskABC_S1, ComputeTaskABC_S2, ComputeTaskABC_P, ComputeTaskABC_V, ComputeTaskABC_U, ComputeTaskABC_Sum]
|
||||
|
@ -1,3 +1,5 @@
|
||||
import QEDbase.mass
|
||||
import QEDbase.AbstractParticle
|
||||
|
||||
"""
|
||||
AbstractPhysicsModel
|
||||
@ -6,23 +8,16 @@ Base type for a model, e.g. ABC-Model or QED. This is used to dispatch many func
|
||||
"""
|
||||
abstract type AbstractPhysicsModel end
|
||||
|
||||
"""
|
||||
AbstractParticle
|
||||
|
||||
Base type for particles belonging to a certain [`AbstractPhysicsModel`](@ref).
|
||||
"""
|
||||
abstract type AbstractParticle end
|
||||
|
||||
"""
|
||||
ParticleValue{ParticleType <: AbstractParticle}
|
||||
|
||||
A struct describing a particle during a calculation of a Feynman Diagram, together with the value that's being calculated.
|
||||
A struct describing a particle during a calculation of a Feynman Diagram, together with the value that's being calculated. `AbstractParticle` is the type from the QEDbase package.
|
||||
|
||||
`sizeof(ParticleValue())` = 48 Byte
|
||||
"""
|
||||
struct ParticleValue{ParticleType <: AbstractParticle}
|
||||
struct ParticleValue{ParticleType <: AbstractParticle, ValueType}
|
||||
p::ParticleType
|
||||
v::Float64
|
||||
v::ValueType
|
||||
end
|
||||
|
||||
"""
|
||||
@ -43,13 +38,6 @@ See also: [`gen_process_input`](@ref)
|
||||
"""
|
||||
abstract type AbstractProcessInput end
|
||||
|
||||
"""
|
||||
mass(t::Type{T}) where {T <: AbstractParticle}
|
||||
|
||||
Interface function that must be implemented for every subtype of [`AbstractParticle`](@ref), returning the particles mass at rest.
|
||||
"""
|
||||
function mass end
|
||||
|
||||
"""
|
||||
interaction_result(t1::Type{T1}, t2::Type{T2}) where {T1 <: AbstractParticle, T2 <: AbstractParticle}
|
||||
|
||||
|
@ -6,3 +6,12 @@ Print a string representation of the fused compute task to io.
|
||||
function show(io::IO, t::FusedComputeTask)
|
||||
return print(io, "ComputeFuse($(t.first_task), $(t.second_task))")
|
||||
end
|
||||
|
||||
"""
|
||||
show(io::IO, t::DataTask)
|
||||
|
||||
Print the data task to io.
|
||||
"""
|
||||
function show(io::IO, t::DataTask)
|
||||
return print(io, "Data", t.data)
|
||||
end
|
||||
|
@ -58,6 +58,20 @@ Return the data of a data task. Given by the task's `.data` field.
|
||||
"""
|
||||
data(t::AbstractDataTask)::Float64 = getfield(t, :data)
|
||||
|
||||
"""
|
||||
copy(t::DataTask)
|
||||
|
||||
Copy the data task and return it.
|
||||
"""
|
||||
copy(t::DataTask) = DataTask(t.data)
|
||||
|
||||
"""
|
||||
children(::DataTask)
|
||||
|
||||
Return the number of children of a data task (always 1).
|
||||
"""
|
||||
children(::DataTask) = 1
|
||||
|
||||
"""
|
||||
data(t::AbstractComputeTask)
|
||||
|
||||
|
@ -19,6 +19,15 @@ The shared base type for any data task.
|
||||
"""
|
||||
abstract type AbstractDataTask <: AbstractTask end
|
||||
|
||||
"""
|
||||
DataTask <: AbstractDataTask
|
||||
|
||||
Task representing a specific data transfer.
|
||||
"""
|
||||
struct DataTask <: AbstractDataTask
|
||||
data::Float64
|
||||
end
|
||||
|
||||
"""
|
||||
FusedComputeTask{T1 <: AbstractComputeTask, T2 <: AbstractComputeTask} <: AbstractComputeTask
|
||||
|
||||
|
@ -8,23 +8,23 @@ graph = MetagraphOptimization.DAG()
|
||||
|
||||
d_exit = insert_node!(graph, make_node(DataTask(10)), track = false)
|
||||
|
||||
s0 = insert_node!(graph, make_node(ComputeTaskS2()), track = false)
|
||||
s0 = insert_node!(graph, make_node(ComputeTaskABC_S2()), track = false)
|
||||
|
||||
ED = insert_node!(graph, make_node(DataTask(3)), track = false)
|
||||
FD = insert_node!(graph, make_node(DataTask(3)), track = false)
|
||||
|
||||
EC = insert_node!(graph, make_node(ComputeTaskV()), track = false)
|
||||
FC = insert_node!(graph, make_node(ComputeTaskV()), track = false)
|
||||
EC = insert_node!(graph, make_node(ComputeTaskABC_V()), track = false)
|
||||
FC = insert_node!(graph, make_node(ComputeTaskABC_V()), track = false)
|
||||
|
||||
A1D = insert_node!(graph, make_node(DataTask(4)), track = false)
|
||||
B1D_1 = insert_node!(graph, make_node(DataTask(4)), track = false)
|
||||
B1D_2 = insert_node!(graph, make_node(DataTask(4)), track = false)
|
||||
C1D = insert_node!(graph, make_node(DataTask(4)), track = false)
|
||||
|
||||
A1C = insert_node!(graph, make_node(ComputeTaskU()), track = false)
|
||||
B1C_1 = insert_node!(graph, make_node(ComputeTaskU()), track = false)
|
||||
B1C_2 = insert_node!(graph, make_node(ComputeTaskU()), track = false)
|
||||
C1C = insert_node!(graph, make_node(ComputeTaskU()), track = false)
|
||||
A1C = insert_node!(graph, make_node(ComputeTaskABC_U()), track = false)
|
||||
B1C_1 = insert_node!(graph, make_node(ComputeTaskABC_U()), track = false)
|
||||
B1C_2 = insert_node!(graph, make_node(ComputeTaskABC_U()), track = false)
|
||||
C1C = insert_node!(graph, make_node(ComputeTaskABC_U()), track = false)
|
||||
|
||||
AD = insert_node!(graph, make_node(DataTask(5)), track = false)
|
||||
BD = insert_node!(graph, make_node(DataTask(5)), track = false)
|
||||
|
@ -128,7 +128,7 @@ end
|
||||
# push a fusion with the sum node
|
||||
ops = get_operations(graph)
|
||||
for fusion in ops.nodeFusions
|
||||
if isa(fusion.input[3].task, ComputeTaskSum)
|
||||
if isa(fusion.input[3].task, ComputeTaskABC_Sum)
|
||||
push_operation!(graph, fusion)
|
||||
break
|
||||
end
|
||||
@ -158,7 +158,7 @@ end
|
||||
# push a fusion with the sum node
|
||||
ops = get_operations(graph)
|
||||
for fusion in ops.nodeFusions
|
||||
if isa(fusion.input[3].task, ComputeTaskSum)
|
||||
if isa(fusion.input[3].task, ComputeTaskABC_Sum)
|
||||
push_operation!(graph, fusion)
|
||||
break
|
||||
end
|
||||
@ -184,11 +184,11 @@ end
|
||||
@testset "AB->AB fusion edge case" for _ in 1:20
|
||||
graph = parse_dag(joinpath(@__DIR__, "..", "input", "AB->AB.txt"), ABCModel())
|
||||
|
||||
# push two fusions with ComputeTaskV
|
||||
# push two fusions with ComputeTaskABC_V
|
||||
for _ in 1:2
|
||||
ops = get_operations(graph)
|
||||
for fusion in ops.nodeFusions
|
||||
if isa(fusion.input[1].task, ComputeTaskV)
|
||||
if isa(fusion.input[1].task, ComputeTaskABC_V)
|
||||
push_operation!(graph, fusion)
|
||||
break
|
||||
end
|
||||
|
@ -22,7 +22,7 @@ d_exit = insert_node!(graph, make_node(DataTask(10)), track = false)
|
||||
@test length(graph.dirtyNodes) == 1
|
||||
|
||||
# final s compute
|
||||
s0 = insert_node!(graph, make_node(ComputeTaskS2()), track = false)
|
||||
s0 = insert_node!(graph, make_node(ComputeTaskABC_S2()), track = false)
|
||||
|
||||
@test length(graph.nodes) == 2
|
||||
@test length(graph.dirtyNodes) == 2
|
||||
@ -32,8 +32,8 @@ d_v0_s0 = insert_node!(graph, make_node(DataTask(5)), track = false)
|
||||
d_v1_s0 = insert_node!(graph, make_node(DataTask(5)), track = false)
|
||||
|
||||
# v0 and v1 compute
|
||||
v0 = insert_node!(graph, make_node(ComputeTaskV()), track = false)
|
||||
v1 = insert_node!(graph, make_node(ComputeTaskV()), track = false)
|
||||
v0 = insert_node!(graph, make_node(ComputeTaskABC_V()), track = false)
|
||||
v1 = insert_node!(graph, make_node(ComputeTaskABC_V()), track = false)
|
||||
|
||||
# data from uB, uA, uBp and uAp to v0 and v1
|
||||
d_uB_v0 = insert_node!(graph, make_node(DataTask(3)), track = false)
|
||||
@ -42,10 +42,10 @@ d_uBp_v1 = insert_node!(graph, make_node(DataTask(3)), track = false)
|
||||
d_uAp_v1 = insert_node!(graph, make_node(DataTask(3)), track = false)
|
||||
|
||||
# uB, uA, uBp and uAp computes
|
||||
uB = insert_node!(graph, make_node(ComputeTaskU()), track = false)
|
||||
uA = insert_node!(graph, make_node(ComputeTaskU()), track = false)
|
||||
uBp = insert_node!(graph, make_node(ComputeTaskU()), track = false)
|
||||
uAp = insert_node!(graph, make_node(ComputeTaskU()), track = false)
|
||||
uB = insert_node!(graph, make_node(ComputeTaskABC_U()), track = false)
|
||||
uA = insert_node!(graph, make_node(ComputeTaskABC_U()), track = false)
|
||||
uBp = insert_node!(graph, make_node(ComputeTaskABC_U()), track = false)
|
||||
uAp = insert_node!(graph, make_node(ComputeTaskABC_U()), track = false)
|
||||
|
||||
# data from PB, PA, PBp and PAp to uB, uA, uBp and uAp
|
||||
d_PB_uB = insert_node!(graph, make_node(DataTask(6)), track = false)
|
||||
@ -54,10 +54,10 @@ d_PBp_uBp = insert_node!(graph, make_node(DataTask(6)), track = false)
|
||||
d_PAp_uAp = insert_node!(graph, make_node(DataTask(6)), track = false)
|
||||
|
||||
# P computes PB, PA, PBp and PAp
|
||||
PB = insert_node!(graph, make_node(ComputeTaskP()), track = false)
|
||||
PA = insert_node!(graph, make_node(ComputeTaskP()), track = false)
|
||||
PBp = insert_node!(graph, make_node(ComputeTaskP()), track = false)
|
||||
PAp = insert_node!(graph, make_node(ComputeTaskP()), track = false)
|
||||
PB = insert_node!(graph, make_node(ComputeTaskABC_P()), track = false)
|
||||
PA = insert_node!(graph, make_node(ComputeTaskABC_P()), track = false)
|
||||
PBp = insert_node!(graph, make_node(ComputeTaskABC_P()), track = false)
|
||||
PAp = insert_node!(graph, make_node(ComputeTaskABC_P()), track = false)
|
||||
|
||||
# entry nodes getting data for P computes
|
||||
d_PB = insert_node!(graph, make_node(DataTask(4)), track = false)
|
||||
|
@ -1,9 +1,9 @@
|
||||
using MetagraphOptimization
|
||||
|
||||
nC1 = MetagraphOptimization.make_node(MetagraphOptimization.ComputeTaskU())
|
||||
nC2 = MetagraphOptimization.make_node(MetagraphOptimization.ComputeTaskV())
|
||||
nC3 = MetagraphOptimization.make_node(MetagraphOptimization.ComputeTaskP())
|
||||
nC4 = MetagraphOptimization.make_node(MetagraphOptimization.ComputeTaskSum())
|
||||
nC1 = MetagraphOptimization.make_node(MetagraphOptimization.ComputeTaskABC_U())
|
||||
nC2 = MetagraphOptimization.make_node(MetagraphOptimization.ComputeTaskABC_V())
|
||||
nC3 = MetagraphOptimization.make_node(MetagraphOptimization.ComputeTaskABC_P())
|
||||
nC4 = MetagraphOptimization.make_node(MetagraphOptimization.ComputeTaskABC_Sum())
|
||||
|
||||
nD1 = MetagraphOptimization.make_node(MetagraphOptimization.DataTask(10))
|
||||
nD2 = MetagraphOptimization.make_node(MetagraphOptimization.DataTask(20))
|
||||
|
@ -1,11 +1,11 @@
|
||||
using MetagraphOptimization
|
||||
|
||||
S1 = MetagraphOptimization.ComputeTaskS1()
|
||||
S2 = MetagraphOptimization.ComputeTaskS2()
|
||||
U = MetagraphOptimization.ComputeTaskU()
|
||||
V = MetagraphOptimization.ComputeTaskV()
|
||||
P = MetagraphOptimization.ComputeTaskP()
|
||||
Sum = MetagraphOptimization.ComputeTaskSum()
|
||||
S1 = MetagraphOptimization.ComputeTaskABC_S1()
|
||||
S2 = MetagraphOptimization.ComputeTaskABC_S2()
|
||||
U = MetagraphOptimization.ComputeTaskABC_U()
|
||||
V = MetagraphOptimization.ComputeTaskABC_V()
|
||||
P = MetagraphOptimization.ComputeTaskABC_P()
|
||||
Sum = MetagraphOptimization.ComputeTaskABC_Sum()
|
||||
|
||||
Data10 = MetagraphOptimization.DataTask(10)
|
||||
Data20 = MetagraphOptimization.DataTask(20)
|
||||
@ -46,4 +46,4 @@ Data10_3 = copy(Data10)
|
||||
S1_2 = copy(S1)
|
||||
|
||||
@test S1_2 == S1
|
||||
@test S1 == MetagraphOptimization.ComputeTaskS1()
|
||||
@test S1 == MetagraphOptimization.ComputeTaskABC_S1()
|
||||
|
Loading…
x
Reference in New Issue
Block a user