Skip to content

Commit

Permalink
Remove gratuitous overloads. (#461)
Browse files Browse the repository at this point in the history
* Remove gratuitous overloads.

* Bump version
  • Loading branch information
chriselrod authored Jan 17, 2023
1 parent d57642c commit 46d3333
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 29 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.146"
version = "0.12.147"

[deps]
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
Expand Down
4 changes: 2 additions & 2 deletions src/constructors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# ls
# end

function Base.copyto!(ls::LoopSet, q::Expr)
function _copyto!(ls::LoopSet, q::Expr)
q.head === :for || throw("Expression must be a for loop.")
add_loop!(ls, q, 8)
# strip_unneeded_const_deps!(ls)
Expand Down Expand Up @@ -108,7 +108,7 @@ function LoopSet(q::Expr, mod::Symbol = :Main)
ls = LoopSet(mod)
check_inputs!(q, ls.prepreamble)
contract_pass!(q)
copyto!(ls, q)
_copyto!(ls, q)
resize!(ls.loop_order, num_loops(ls))
ls
end
Expand Down
23 changes: 12 additions & 11 deletions src/modeling/graphs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ pushexpr!(ex::Expr, x::Integer) =
pushexpr!(ex::Expr, @nospecialize(x::StaticInt)) = (push!(ex.args, x); nothing)
MaybeKnown(x::Integer) =
MaybeKnown(convert(Int, x), Symbol("##UNDEFINED##"), true)
MaybeKnown(x::Integer, default::Int) = MaybeKnown(x)
MaybeKnown(x::Integer, ::Int) = MaybeKnown(x)
MaybeKnown(x::Symbol, default::Int) = MaybeKnown(default, x, false)

isknown(mk::MaybeKnown) = getfield(mk, :known)
Expand Down Expand Up @@ -158,7 +158,7 @@ function arithmeticexpr(
return _arithmeticexpr(f, a, b)
end
end
arithmeticexpr(op, f, a, b) = _arithmeticexpr(f, a, b)
arithmeticexpr(_, f, a, b) = _arithmeticexpr(f, a, b)
function _arithmeticexpr(f, a, b)
ex = Expr(:call, lv(f))
pushexpr!(ex, a)
Expand Down Expand Up @@ -664,7 +664,8 @@ This is used so that identical loops will create identical `_turbo_!` calls in t
"""
gensym!(ls::LoopSet, s) = Symbol("###$(s)###$(ls.symcounter += 1)###")

fill_children!(ls::LoopSet) = for op operations(ls)
fill_children!(ls::LoopSet) =
for op operations(ls)
empty!(children(op))
for opp parents(op)
@assert children(opp) !== NOPARENTS
Expand All @@ -688,7 +689,7 @@ function rejectinterleave!(
op.rejectinterleave = true
else
omop = ls.omop
batchid, opind = omop.batchedcollectionmap[identifier(op)]
batchid, _ = omop.batchedcollectionmap[identifier(op)]
op.rejectinterleave =
((batchid == 0) || (!isvectorized(op))) ||
rejectinterleave(ls, op, vloop, omop.batchedcollections[batchid])
Expand Down Expand Up @@ -984,7 +985,7 @@ function add_block!(ls::LoopSet, ex::Expr, elementbytes::Int, position::Int)
for x ex.args
x isa Expr || continue # be that general?
x.head === :inbounds && continue
push!(ls, x, elementbytes, position)
_push!(ls, x, elementbytes, position)
end
end
function makestatic!(expr)
Expand All @@ -1006,7 +1007,7 @@ function makestatic!(expr)
expr
end
add_loop_bound!(
ls::LoopSet,
::LoopSet,
itersym::Symbol,
bound::Union{Integer,Symbol},
upper::Bool,
Expand Down Expand Up @@ -1096,7 +1097,7 @@ end
r::OptionallyStaticRange,
::StaticInt{S}
) where {S}
ifelse(ArrayInterface.gt(StaticInt{S}(), Zero()), r, _reverse(r))
S > 0 ? r : _reverse(r)
end
@inline canonicalize_range(r::OptionallyStaticRange, s::Integer) =
s > 0 ? r : _reverse(r)
Expand Down Expand Up @@ -1378,7 +1379,7 @@ function add_loop!(ls::LoopSet, q::Expr, elementbytes::Int)
if body.head === :block
add_block!(ls, body, elementbytes, position)
else
push!(ls, q, elementbytes, position)
_push!(ls, q, elementbytes, position)
end
end
function add_loop!(ls::LoopSet, loop::Loop, itersym::Symbol = loop.itersymbol)
Expand Down Expand Up @@ -1409,7 +1410,7 @@ function instruction!(ls::LoopSet, x::Expr)
pushprepreamble!(ls, Expr(:(=), instr, x))
Instruction(Symbol(""), instr)
end
instruction!(ls::LoopSet, x::Symbol) = instruction(x)
instruction!(::LoopSet, x::Symbol) = instruction(x)
function instruction!(ls::LoopSet, f::F) where {F<:Function}
get(FUNCTIONSYMBOLS, F) do
instr = gensym!(ls, "f")
Expand Down Expand Up @@ -1819,14 +1820,14 @@ function push_op!(
add_compute!(ls, LHS, :identity, [RHS], elementbytes)
end
else
push!(ls, localbody, elementbytes, position, mpref)
_push!(ls, localbody, elementbytes, position, mpref)
end
else
throw(LoopError("Don't know how to handle expression.", ex))
end
end

function Base.push!(
function _push!(
ls::LoopSet,
ex::Expr,
elementbytes::Int,
Expand Down
19 changes: 4 additions & 15 deletions src/parse/add_compute.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,8 @@ function search_tree(opv::Vector{Operation}, var::Symbol) # relies on cycles bei
false
end

search_tree_for_ref(
ls::LoopSet,
opv::Vector{Operation},
::Nothing,
var::Symbol
) = var, false
search_tree_for_ref(::LoopSet, ::Vector{Operation}, ::Nothing, var::Symbol) =
var, false
function search_tree_for_ref(
ls::LoopSet,
opv::Vector{Operation},
Expand Down Expand Up @@ -433,35 +429,29 @@ function find_inner_reduct_parent(op::Operation, opname::Symbol)
end

function maybe_fix_reduced_deps!(
ls::LoopSet,
::LoopSet,
deps::Vector{Symbol},
reduceddeps::Vector{Symbol},
parent::Operation,
mpref::ArrayReferenceMetaPosition,
position::Int
::Int
)
loopdeps_parent = loopdependencies(parent)
reduceddeps_parent = reduceddependencies(parent)
loopdeps_mpref = loopdependencies(mpref)
loopdeps_new = Symbol[]
# pushv = Vector{Symbol}[loopdeps_new, reduceddeps_parent]
instr = instruction(parent).instr
pparent_id = findfirst(Base.Fix2(===, name(parent)) name, parents(parent))
pparent_id === nothing && return deps, reduceddeps
pparent = parents(parent)[pparent_id]
@assert length(loopdependencies(pparent)) ==
length(loopdeps_parent) + length(reduceddeps_parent)
reduceddeps_pparent = reduceddependencies(pparent)
# if instr === :identity
# push!(pushv,
# if Base.sym_in(instr, :ident
for ld loopdeps_parent
if ld loopdeps_mpref
push!(loopdeps_new, ld)
else
push!(reduceddeps_parent, ld)
push!(reduceddeps_pparent, ld)
# foreach(Base.Fix2(push!, ld), pushv)
end
end
parent.dependencies = loopdeps_new
Expand Down Expand Up @@ -803,7 +793,6 @@ function add_pow!(
elseif x isa Number
return add_constant!(ls, x^p, elementbytes, var)::Operation
end
local pnum::Int, pden::Int
if p isa Integer
pnum = Int(p)::Int
pden = 1
Expand Down

2 comments on commit 46d3333

@chriselrod
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/75885

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.12.147 -m "<description of version>" 46d3333b4402d70ee6a4a7d2bf52798e582e148e
git push origin v0.12.147

Please sign in to comment.