Fix occasional execution error

This commit is contained in:
Anton Reinhard 2023-10-04 17:32:23 +02:00
parent 0f50b59933
commit a86901e425
4 changed files with 14 additions and 16 deletions

View File

@ -42,7 +42,7 @@ Problems:
- Lots of testing required because mistakes will propagate and multiply.
## Other TODOs
- Reduce memory footprint of the graph, are the UUIDs too large?
- Reduce memory footprint of the graph
- Memory layout of Nodes? They should lie linearly in memory, right now probably on heap?
- Add scaling functions
@ -53,7 +53,7 @@ For graphs AB->AB^n:
- Number of ComputeTaskS2 should always be (n+1)!
- Number of ComputeTaskU should always be (n+3)
Times are from my home machine: AMD Ryzen 7900X3D, 64GB DDR5 RAM @ 6000MHz
Times are from my home machine: AMD Ryzen 7900X3D, 64GB DDR5 RAM @ 6000MHz (not necessarily up to date, check Jupyter Notebooks in `notebooks/` instead)
```
$ julia --project examples/import_bench.jl

View File

@ -160,17 +160,22 @@ function remove_edge!(graph::DAG, node1::Node, node2::Node; track = true, invali
end
function replace_children!(task::FusedComputeTask, before, after)
# TODO: this assert fails sometimes and really shouldn't
@assert length(findall(x -> x == before, task.t1_inputs)) >= 1 ||
length(findall(x -> x == before, task.t2_inputs)) >= 1 "Replacing $before with $after in $(task.t1_inputs...) and $(task.t2_inputs...)"
replacedIn1 = length(findall(x -> x == before, task.t1_inputs))
replacedIn2 = length(findall(x -> x == before, task.t2_inputs))
# recursively descend down the tree
replace_children!(task.first_task, before, after)
replace_children!(task.second_task, before, after)
@assert replacedIn1 >= 1 || replacedIn2 >= 1 "Nothing to replace while replacing $before with $after in $(task.t1_inputs...) and $(task.t2_inputs...)"
replace!(task.t1_inputs, before => after)
replace!(task.t2_inputs, before => after)
# recursively descend down the tree, but only in the tasks where we're replacing things
if replacedIn1 > 0
replace_children!(task.first_task, before, after)
end
if replacedIn2 > 0
replace_children!(task.second_task, before, after)
end
return nothing
end

View File

@ -9,7 +9,6 @@ function apply_all!(graph::DAG)
op = popfirst!(graph.operationsToApply)
# apply it
println(graph.appliedOperations)
appliedOp = apply_operation!(graph, op)
# push to the end of the appliedOperations deque
@ -238,12 +237,6 @@ function node_reduction!(graph::DAG, nodes::Vector{Node})
# names of the previous children that n1 now replaces per parent
newParentsChildNames = Dict{Node, Symbol}()
str = Vector{String}()
for n in nodes
push!(str, "$(n.id)")
end
#println("Reducing $(nodes[1].task) Nodes $(str)")
# remove all of the nodes' parents and children and the nodes themselves (except for first node)
for i in 2:length(nodes)
n = nodes[i]

View File

@ -64,7 +64,7 @@ include("../examples/profiling_utilities.jl")
end
@testset "AB->ABBB after random walk" begin
for i in 1:20
for i in 1:200
graph = parse_dag(joinpath(@__DIR__, "..", "input", "AB->ABBB.txt"), ABCModel())
random_walk!(graph, 100)
@test is_valid(graph)