Skip to content

Commit

Permalink
Type declarations in mulexpr (#500)
Browse files Browse the repository at this point in the history
* ignore oftype

* support expr in oftype disregard

* change tests, storing in 0-dim arrays not supported

* mulexpr code_typed is unchanged on Julia master...
  • Loading branch information
chriselrod committed Jun 20, 2023
1 parent 8fe27b9 commit 2e06010
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions src/vectorizationbase_compat/contract_pass.jl
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@

mulexprcost(::Number) = 0
mulexprcost(::Symbol) = 1
function mulexprcost(ex::Expr)
base = ex.head === :call ? 10 : 1
base + length(ex.args)
const ProdArg = Union{Symbol,Expr,Number}
function mulexprcost(@nospecialize(x::ProdArg))::Int
if x isa Number
return 0
elseif x isa Symbol
return 1
else
ex = x::Expr
base = ex.head === :call ? 10 : 1
return base + length(ex.args)
end
end
function mul_fast_expr(args)
function mul_fast_expr(args::SubArray{Any, 1, Vector{Any}, Tuple{UnitRange{Int64}}, true})::Expr
b = Expr(:call, :mul_fast)
for i 2:length(args)
push!(b.args, args[i])
end
b
end
function mulexpr(mulexargs)
a = (mulexargs[1])::Union{Symbol,Expr,Number}
function mulexpr(mulexargs::SubArray{Any, 1, Vector{Any}, Tuple{UnitRange{Int64}}, true})::Tuple{ProdArg,ProdArg}
a = (mulexargs[1])::ProdArg
if length(mulexargs) == 2
return (a, mulexargs[2]::Union{Symbol,Expr,Number})
return (a, mulexargs[2]::ProdArg)
elseif length(mulexargs) == 3
# We'll calc the product between the guesstimated cheaper two args first, for better out of order execution
b = (mulexargs[2])::Union{Symbol,Expr,Number}
c = (mulexargs[3])::Union{Symbol,Expr,Number}
b = (mulexargs[2])::ProdArg
c = (mulexargs[3])::ProdArg
ac = mulexprcost(a)
bc = mulexprcost(b)
cc = mulexprcost(c)
Expand Down

2 comments on commit 2e06010

@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/85933

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.160 -m "<description of version>" 2e060100f1be46740a2e7cbebdddc2d701b22b63
git push origin v0.12.160

Please sign in to comment.