Skip to content

Commit 33f9cf8

Browse files
committed
Added some (currently unused) infrastructure for tracking arrays as offsets.
1 parent 45cbcdc commit 33f9cf8

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

src/add_loads.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,10 @@ end
7373

7474
struct LoopValue end
7575
@inline VectorizationBase.stridedpointer(::LoopValue) = LoopValue()
76-
@inline SIMDPirates.vload(::LoopValue, i::Tuple{_MM{W}}) where {W} = SVec(SIMDPirates.vrangeincr(Val{W}(), @inbounds(i[1].i), Val{1}()))
77-
@inline SIMDPirates.vload(::LoopValue, i::Tuple{_MM{W}}, ::Unsigned) where {W} = SVec(SIMDPirates.vrangeincr(Val{W}(), @inbounds(i[1].i), Val{1}()))
76+
@inline SIMDPirates.vload(::LoopValue, i::Tuple{_MM{W}}) where {W} = _MM{W}(@inbounds(i[1].i) + 1)
77+
@inline SIMDPirates.vload(::LoopValue, i::Tuple{_MM{W}}, ::Unsigned) where {W} = _MM{W}(@inbounds(i[1].i) + 1)
78+
# @inline SIMDPirates.vload(::LoopValue, i::Tuple{_MM{W}}) where {W} = SVec(SIMDPirates.vrangeincr(Val{W}(), @inbounds(i[1].i), Val{1}()))
79+
# @inline SIMDPirates.vload(::LoopValue, i::Tuple{_MM{W}}, ::Unsigned) where {W} = SVec(SIMDPirates.vrangeincr(Val{W}(), @inbounds(i[1].i), Val{1}()))
7880
@inline VectorizationBase.load(::LoopValue, i::Integer) = i + one(i)
7981
@inline VectorizationBase.load(::LoopValue, i::Tuple{I}) where {I<:Integer} = @inbounds(i[1]) + one(I)
8082
@inline Base.eltype(::LoopValue) = Int8

src/condense_loopset.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Base.:(==)(u::Unsigned, it::IndexType) = (u % UInt8) == UInt8(it)
77
struct ArrayRefStruct
88
index_types::UInt64
99
indices::UInt64
10+
offsets::UInt64
1011
end
1112

1213
function findindoradd!(v::Vector{T}, s::T) where {T}
@@ -18,12 +19,16 @@ end
1819
function ArrayRefStruct(ls::LoopSet, mref::ArrayReferenceMeta, arraysymbolinds::Vector{Symbol})
1920
index_types = zero(UInt64)
2021
indices = zero(UInt64)
22+
offsets = zero(UInt64)
2123
indv = mref.ref.indices
24+
offv = mref.ref.offsets
2225
# we can discard that the array was considered discontiguous, as it should be recovered from type information
2326
start = 1 + (first(indv) === Symbol("##DISCONTIGUOUSSUBARRAY##"))
2427
for (n,ind) enumerate(@view(indv[start:end]))
2528
index_types <<= 8
2629
indices <<= 8
30+
offsets <<= 8
31+
offsets |= offv[n]
2732
if mref.loopedindex[n]
2833
index_types |= LoopIndex
2934
indices |= getloopid(ls, ind)
@@ -38,7 +43,7 @@ function ArrayRefStruct(ls::LoopSet, mref::ArrayReferenceMeta, arraysymbolinds::
3843
end
3944
end
4045
end
41-
ArrayRefStruct( index_types, indices )
46+
ArrayRefStruct( index_types, indices, offsets )
4247
end
4348

4449
struct OperationStruct

src/operations.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
struct ArrayReference
33
array::Symbol
44
indices::Vector{Symbol}
5+
offsets::Vector{Int8}
56
end
7+
ArrayReference(array, indices) = ArrayReference(array, indices, similar(indices, Int8))
68
function Base.isequal(x::ArrayReference, y::ArrayReference)
79
x.array === y.array || return false
810
xinds = x.indices

src/reconstruct_loopset.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ function ArrayReferenceMeta(
3030
)
3131
index_types = ar.index_types
3232
indices = ar.indices
33+
offsets = ar.offsets
3334
ni = filled_8byte_chunks(index_types)
3435
index_vec = Vector{Symbol}(undef, ni)
36+
offset_vec = Vector{Int8}(undef, ni)
3537
loopedindex = fill(false, ni)
3638
while index_types != zero(UInt64)
3739
ind = indices % UInt8
@@ -45,12 +47,14 @@ function ArrayReferenceMeta(
4547
arraysymbolinds[ind]
4648
end
4749
index_vec[ni] = symind
50+
offset_vec[ni] = offsets % Int8
4851
index_types >>>= 8
4952
indices >>>= 8
53+
offsets >>>= 8
5054
ni -= 1
5155
end
5256
ArrayReferenceMeta(
53-
ArrayReference(array, index_vec),
57+
ArrayReference(array, index_vec, offset_vec),
5458
loopedindex, vp
5559
)
5660
end

0 commit comments

Comments
 (0)