Skip to content

Commit

Permalink
Use 16 bits to store an array reference index (#451)
Browse files Browse the repository at this point in the history
* Allow more than 256 array references

- Add test with generated function
- Use 16 bits to store an array reference index

* Bump version to 0.12.143

Co-authored-by: Jack Coughlin <[email protected]>
  • Loading branch information
johnbcoughlin and Jack Coughlin authored Dec 30, 2022
1 parent c74cd33 commit 35f8310
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 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.142"
version = "0.12.143"

[deps]
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
Expand Down
10 changes: 5 additions & 5 deletions src/condense_loopset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,17 @@ struct OperationStruct <: AbstractLoopOperation
parents₃::UInt128
node_type::OperationType
symid::UInt16
array::UInt8
array::UInt16
end
optype(os) = os.node_type

function findmatchingarray(ls::LoopSet, mref::ArrayReferenceMeta)
id = 0x01
id = 0x0001
for r ls.refs_aliasing_syms
r == mref && return id
id += 0x01
id += 0x0001
end
0x00
0x0000
end
filled_8byte_chunks(u::T) where {T<:Unsigned} = sizeof(T) - (leading_zeros(u) >>> 3)

Expand Down Expand Up @@ -224,7 +224,7 @@ function OperationStruct!(
rd = reduceddeps_uint(ls, op)
cd = childdeps_uint(ls, op)
p0, p1, p2, p3 = parents_uint(op)
array = accesses_memory(op) ? findmatchingarray(ls, op.ref) : 0x00
array = accesses_memory(op) ? findmatchingarray(ls, op.ref) : 0x0000
ids[identifier(op)] = id = findindoradd!(varnames, name(op))
OperationStruct(ld, rd, cd, p0, p1, p2, p3, op.node_type, id, array)
end
Expand Down
2 changes: 2 additions & 0 deletions test/grouptests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ const START_TIME = time()

@time include("reduction_untangling.jl")

@time include("manyarrayrefs.jl")

@time include("manyloopreductions.jl")

@time include("simplemisc.jl")
Expand Down
23 changes: 23 additions & 0 deletions test/manyarrayrefs.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@generated function sum_way_too_unrolled(A, ::Val{rows}, ::Val{cols}) where {rows, cols}
terms = :( 0 )

for i in 1:rows
for j in 1:cols
terms = :( $terms + A[$i, $j, k] )
end
end

quote
sum = 0.0
@turbo for k in axes(A, 3)
sum += $terms
end
sum
end
end

@testset "Many Array References" begin
A = rand(17, 16, 10)

@test isapprox(sum_way_too_unrolled(A, Val(17), Val(16)), sum(A))
end

2 comments on commit 35f8310

@chriselrod
Copy link
Member

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/74795

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.143 -m "<description of version>" 35f83103c12992ddd887cd709bf65e345db5ec9e
git push origin v0.12.143

Please sign in to comment.