Skip to content

Commit

Permalink
tuple support
Browse files Browse the repository at this point in the history
  • Loading branch information
chriselrod committed Oct 18, 2022
1 parent 9da30ff commit 4f8a194
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "LoopVectorization"
uuid = "bdcacae8-1622-11e9-2a5c-532679323890"
authors = ["Chris Elrod <[email protected]>"]
version = "0.12.135"
version = "0.12.136"

[deps]
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
Expand Down
1 change: 1 addition & 0 deletions src/condense_loopset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
1 change: 1 addition & 0 deletions src/modeling/graphs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion src/parse/add_compute.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ function pushparent!(
reduceddeps::Vector{Symbol},
parent::Operation,
)
@assert parents !== NOPARENTS
push!(parents, parent)
update_deps!(deps, reduceddeps, parent)
end
Expand Down Expand Up @@ -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(
Expand Down
13 changes: 11 additions & 2 deletions src/parse/add_ifelse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions test/grouptests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
20 changes: 20 additions & 0 deletions test/misc2.jl
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 4f8a194

Please sign in to comment.