diff --git a/Project.toml b/Project.toml index 2a690d6e9..ac737944b 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "LoopVectorization" uuid = "bdcacae8-1622-11e9-2a5c-532679323890" authors = ["Chris Elrod "] -version = "0.12.135" +version = "0.12.136" [deps] ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" diff --git a/src/condense_loopset.jl b/src/condense_loopset.jl index ab232638f..83b4dd54e 100644 --- a/src/condense_loopset.jl +++ b/src/condense_loopset.jl @@ -882,6 +882,7 @@ end @inline check_args(::LoTri) = false @inline check_args(::Diagonal) = false @inline check_args(::Type{T}) where {T} = check_type(T) +@inline check_args(::Tuple{T,Vararg{T,K}}) where {T,K} = check_type(T) """ check_type(::Type{T}) where {T} diff --git a/src/modeling/graphs.jl b/src/modeling/graphs.jl index 8afda61c2..e2aae42a3 100644 --- a/src/modeling/graphs.jl +++ b/src/modeling/graphs.jl @@ -623,6 +623,7 @@ function fill_children!(ls::LoopSet) for op ∈ operations(ls) empty!(children(op)) for opp ∈ parents(op) + @assert children(opp) !== NOPARENTS push!(children(opp), op) end end diff --git a/src/parse/add_compute.jl b/src/parse/add_compute.jl index 9bfac67b5..1527ed1b7 100644 --- a/src/parse/add_compute.jl +++ b/src/parse/add_compute.jl @@ -55,6 +55,7 @@ function pushparent!( reduceddeps::Vector{Symbol}, parent::Operation, ) + @assert parents !== NOPARENTS push!(parents, parent) update_deps!(deps, reduceddeps, parent) end @@ -299,7 +300,10 @@ function add_reduction_update_parent!( # create child op, which is the reduction combination childrdeps = Symbol[] childparents = Operation[op]#, parent ] - add_reduct_instruct && push!(childparents, parent) + if add_reduct_instruct + @assert childparents !== NOPARENTS + push!(childparents, parent) + end childdeps = loopdependencies(reductinit) setdiffv!(childrdeps, loopdependencies(op), childdeps) child = Operation( diff --git a/src/parse/add_ifelse.jl b/src/parse/add_ifelse.jl index a583efd0b..611d87ed2 100644 --- a/src/parse/add_ifelse.jl +++ b/src/parse/add_ifelse.jl @@ -30,7 +30,11 @@ function add_if!( all(ld -> ld ∈ loopdependencies(trueop), loopdependencies(condop)) && !search_tree(parents(condop), trueop) trueop.instruction = Instruction(:conditionalload) - push!(parents(trueop), condop) + if parents(trueop) !== NOPARENTS + push!(parents(trueop), condop) + else + trueop.parents = [condop] + end end else trueop = getop(ls, iftrue, elementbytes) @@ -50,7 +54,12 @@ function add_if!( all(ld -> ld ∈ loopdependencies(falseop), loopdependencies(condop)) && !search_tree(parents(condop), falseop) falseop.instruction = Instruction(:conditionalload) - push!(parents(falseop), negateop!(ls, condop, elementbytes)) + negop = negateop!(ls, condop, elementbytes) + if parents(falseop) !== NOPARENTS + push!(parents(falseop), negop) + else + falseop.parents = [negop] + end if (any(==(identifier(trueop)), Iterators.map(first, ls.preamble_zeros))) falseop.variable = LHS ls.opdict[LHS] = falseop diff --git a/test/grouptests.jl b/test/grouptests.jl index 74c66b161..db31402c1 100644 --- a/test/grouptests.jl +++ b/test/grouptests.jl @@ -9,6 +9,7 @@ const START_TIME = time() @time if LOOPVECTORIZATION_TEST == "all" || LOOPVECTORIZATION_TEST == "part1" @time include("broadcast.jl") @time include("parsing_inputs.jl") + @time include("misc2.jl") end @time if LOOPVECTORIZATION_TEST == "all" || LOOPVECTORIZATION_TEST == "part2" diff --git a/test/misc2.jl b/test/misc2.jl new file mode 100644 index 000000000..a540dbc5c --- /dev/null +++ b/test/misc2.jl @@ -0,0 +1,20 @@ + +using LoopVectorization, Test + +function tuptestturbo(x,y,t) + s = 0.0 + @turbo for i = eachindex(x,y) + s += x[i]*t[1] - y[i]*t[2] + end + s +end +function tuptest(x,y,t) + s = 0.0 + @inbounds @fastmath for i = eachindex(x,y) + s += x[i]*t[1] - y[i]*t[2] + end + s +end +x = rand(127); y = rand(127); t = (rand(),rand()); +@test tuptestturbo(x,y,t) ≈ tuptest(x,y,t) +