From 46d3333b4402d70ee6a4a7d2bf52798e582e148e Mon Sep 17 00:00:00 2001 From: Chris Elrod Date: Tue, 17 Jan 2023 16:09:55 -0500 Subject: [PATCH] Remove gratuitous overloads. (#461) * Remove gratuitous overloads. * Bump version --- Project.toml | 2 +- src/constructors.jl | 4 ++-- src/modeling/graphs.jl | 23 ++++++++++++----------- src/parse/add_compute.jl | 19 ++++--------------- 4 files changed, 19 insertions(+), 29 deletions(-) diff --git a/Project.toml b/Project.toml index 032cd7c05..e75502997 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.146" +version = "0.12.147" [deps] ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" diff --git a/src/constructors.jl b/src/constructors.jl index 121f8c290..1aeb78bb0 100644 --- a/src/constructors.jl +++ b/src/constructors.jl @@ -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) @@ -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 diff --git a/src/modeling/graphs.jl b/src/modeling/graphs.jl index 8d41cf726..f15b3008c 100644 --- a/src/modeling/graphs.jl +++ b/src/modeling/graphs.jl @@ -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) @@ -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) @@ -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 @@ -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]) @@ -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) @@ -1006,7 +1007,7 @@ function makestatic!(expr) expr end add_loop_bound!( - ls::LoopSet, + ::LoopSet, itersym::Symbol, bound::Union{Integer,Symbol}, upper::Bool, @@ -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) @@ -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) @@ -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") @@ -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, diff --git a/src/parse/add_compute.jl b/src/parse/add_compute.jl index ee1c7651e..20176c1e9 100644 --- a/src/parse/add_compute.jl +++ b/src/parse/add_compute.jl @@ -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}, @@ -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 @@ -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