Skip to content

Commit

Permalink
support a silly number of returns
Browse files Browse the repository at this point in the history
  • Loading branch information
chriselrod committed Jun 2, 2022
1 parent 67f4232 commit cbb9f23
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 35 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.115"
version = "0.12.116"

[deps]
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
Expand Down
35 changes: 32 additions & 3 deletions src/getconstindexes.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
for (i, f) enumerate((
const EXTRACTFUNS = (
:first,
:second,
:third,
:fourth,
Expand All @@ -11,6 +12,34 @@ for (i, f) ∈ enumerate((
:eleventh,
:twelfth,
:thirteenth,
))
@eval @inline $f(x) = @inbounds getindex(x, $(i + 1))
:fourteenth,
:fifteenth,
:sixteenth,
:seventeenth,
:eighteenth,
:nineteenth,
:twentieth,
:twentyfirst,
:twentysecond,
:twentythird,
:twentyfourth,
:twentyfifth,
:twentysixth,
:twentyseventh,
:twentyeighth,
:twentyninth,
:thirtieth,
:thirtyfirst,
:thirtysecond,
:thirtythird,
:thirtyfourth,
:thirtyfifth,
:thirtysixth,
:thirtyseventh,
:thirtyeighth,
:last)

for (i, f) enumerate(EXTRACTFUNS)
(i == 1 || i == length(EXTRACTFUNS)) && continue
@eval @inline $f(x) = @inbounds getindex(x, $i)
end
18 changes: 4 additions & 14 deletions src/modeling/costs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -253,20 +253,6 @@ const COST = Dict{Symbol,InstructionCost}(
:adjoint => InstructionCost(0, 0.0, 0.0, 0),
:conj => InstructionCost(0, 0.0, 0.0, 0),
:transpose => InstructionCost(0, 0.0, 0.0, 0),
:first => InstructionCost(0, 0.0, 0.0, 0),
:second => InstructionCost(0, 0.0, 0.0, 0),
:third => InstructionCost(0, 0.0, 0.0, 0),
:fourth => InstructionCost(0, 0.0, 0.0, 0),
:fifth => InstructionCost(0, 0.0, 0.0, 0),
:sixth => InstructionCost(0, 0.0, 0.0, 0),
:seventh => InstructionCost(0, 0.0, 0.0, 0),
:eighth => InstructionCost(0, 0.0, 0.0, 0),
:ninth => InstructionCost(0, 0.0, 0.0, 0),
:tenth => InstructionCost(0, 0.0, 0.0, 0),
:eleventh => InstructionCost(0, 0.0, 0.0, 0),
:twelfth => InstructionCost(0, 0.0, 0.0, 0),
:thirteenth => InstructionCost(0, 0.0, 0.0, 0),
:last => InstructionCost(0, 0.0, 0.0, 0),
:prefetch => InstructionCost(0, 0.0, 0.0, 0),
:prefetch0 => InstructionCost(0, 0.0, 0.0, 0),
:prefetch1 => InstructionCost(0, 0.0, 0.0, 0),
Expand All @@ -280,6 +266,10 @@ const COST = Dict{Symbol,InstructionCost}(
:significand => InstructionCost(8, 1.0),
)

for f = EXTRACTFUNS
COST[f] = InstructionCost(0, 0.0, 0.0, 0)
end

# # @inline prefetch0(x::Ptr, i) = VectorizationBase.prefetch(x, Val{3}(), Val{0}())
# @inline prefetch0(x, i) = VectorizationBase.prefetch(gep(stridedpointer(x), (data(i),)), Val{3}(), Val{0}())
# @inline prefetch0(x, I::Tuple) = VectorizationBase.prefetch(gep(x, I), Val{3}(), Val{0}())
Expand Down
19 changes: 2 additions & 17 deletions src/modeling/graphs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1528,7 +1528,7 @@ function unpack_tuple!(ls::LoopSet, LHS::Expr, RHS, elementbytes::Int, position:
end
return last(operations(ls)) # FIXME: dummy
end
@assert length(LHS.args) 14 "Functions returning more than 9 values aren't currently supported."
@assert length(LHS.args) length(EXTRACTFUNS) "Functions returning more than $(length(EXTRACTFUNS)) values aren't currently supported."
lhstemp = gensym!(ls, "lhstuple")
vparents = Operation[maybe_const_compute!(
ls,
Expand All @@ -1548,22 +1548,7 @@ function unpack_tuple!(
position::Int,
)
for i eachindex(LHS.args)
f = (
:first,
:second,
:third,
:fourth,
:fifth,
:sixth,
:seventh,
:eighth,
:ninth,
:tenth,
:eleventh,
:twelfth,
:thirteenth,
:last,
)[i]
f = EXTRACTFUNS[i]
lhsi = LHS.args[i]
if lhsi isa Symbol
add_compute!(ls, lhsi, f, vparents, elementbytes)
Expand Down

2 comments on commit cbb9f23

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

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.116 -m "<description of version>" cbb9f2324ec3cb2c4aa5523d8c4fb98147aa7855
git push origin v0.12.116

Please sign in to comment.