Skip to content

Commit 35f8310

Browse files
johnbcoughlinJack Coughlin
and
Jack Coughlin
authored
Use 16 bits to store an array reference index (#451)
* 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]>
1 parent c74cd33 commit 35f8310

File tree

4 files changed

+31
-6
lines changed

4 files changed

+31
-6
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "LoopVectorization"
22
uuid = "bdcacae8-1622-11e9-2a5c-532679323890"
33
authors = ["Chris Elrod <[email protected]>"]
4-
version = "0.12.142"
4+
version = "0.12.143"
55

66
[deps]
77
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"

src/condense_loopset.jl

+5-5
Original file line numberDiff line numberDiff line change
@@ -147,17 +147,17 @@ struct OperationStruct <: AbstractLoopOperation
147147
parents₃::UInt128
148148
node_type::OperationType
149149
symid::UInt16
150-
array::UInt8
150+
array::UInt16
151151
end
152152
optype(os) = os.node_type
153153

154154
function findmatchingarray(ls::LoopSet, mref::ArrayReferenceMeta)
155-
id = 0x01
155+
id = 0x0001
156156
for r ls.refs_aliasing_syms
157157
r == mref && return id
158-
id += 0x01
158+
id += 0x0001
159159
end
160-
0x00
160+
0x0000
161161
end
162162
filled_8byte_chunks(u::T) where {T<:Unsigned} = sizeof(T) - (leading_zeros(u) >>> 3)
163163

@@ -224,7 +224,7 @@ function OperationStruct!(
224224
rd = reduceddeps_uint(ls, op)
225225
cd = childdeps_uint(ls, op)
226226
p0, p1, p2, p3 = parents_uint(op)
227-
array = accesses_memory(op) ? findmatchingarray(ls, op.ref) : 0x00
227+
array = accesses_memory(op) ? findmatchingarray(ls, op.ref) : 0x0000
228228
ids[identifier(op)] = id = findindoradd!(varnames, name(op))
229229
OperationStruct(ld, rd, cd, p0, p1, p2, p3, op.node_type, id, array)
230230
end

test/grouptests.jl

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ const START_TIME = time()
5151

5252
@time include("reduction_untangling.jl")
5353

54+
@time include("manyarrayrefs.jl")
55+
5456
@time include("manyloopreductions.jl")
5557

5658
@time include("simplemisc.jl")

test/manyarrayrefs.jl

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
@generated function sum_way_too_unrolled(A, ::Val{rows}, ::Val{cols}) where {rows, cols}
2+
terms = :( 0 )
3+
4+
for i in 1:rows
5+
for j in 1:cols
6+
terms = :( $terms + A[$i, $j, k] )
7+
end
8+
end
9+
10+
quote
11+
sum = 0.0
12+
@turbo for k in axes(A, 3)
13+
sum += $terms
14+
end
15+
sum
16+
end
17+
end
18+
19+
@testset "Many Array References" begin
20+
A = rand(17, 16, 10)
21+
22+
@test isapprox(sum_way_too_unrolled(A, Val(17), Val(16)), sum(A))
23+
end

0 commit comments

Comments
 (0)