Skip to content

Commit e873cdd

Browse files
committed
Update to ArrayInterface 3
1 parent 5cb555e commit e873cdd

File tree

6 files changed

+26
-14
lines changed

6 files changed

+26
-14
lines changed

Project.toml

Lines changed: 3 additions & 3 deletions
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.10"
4+
version = "0.11"
55

66
[deps]
77
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
@@ -16,15 +16,15 @@ UnPack = "3a884ed6-31ef-47d7-9d2a-63182c4928ed"
1616
VectorizationBase = "3d5dd08c-fd9d-11e8-17fa-ed2836048c2f"
1717

1818
[compat]
19-
ArrayInterface = "2.14.12"
19+
ArrayInterface = "3"
2020
DocStringExtensions = "0.8"
2121
IfElse = "0.1"
2222
OffsetArrays = "1.4.1, 1.5"
2323
Requires = "1"
2424
SLEEFPirates = "0.6.6"
2525
ThreadingUtilities = "0.2.2"
2626
UnPack = "1"
27-
VectorizationBase = "0.16"
27+
VectorizationBase = "0.17"
2828
julia = "1.5"
2929

3030
[extras]

benchmark/looptests.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ Base.size(::SizedOffsetMatrix{<:Any,LR,UR,LC,UC}) where {LR,UR,LC,UC} = (UR-LR+1
1313
Base.axes(::SizedOffsetMatrix{T,LR,UR,LC,UC}) where {T,LR,UR,LC,UC} = (Static{LR}():Static{UR}(),Static{LC}():Static{UC}())
1414
Base.parent(A::SizedOffsetMatrix) = A.data
1515
Base.unsafe_convert(::Type{Ptr{T}}, A::SizedOffsetMatrix{T}) where {T} = pointer(A.data)
16-
ArrayInterface.contiguous_axis(::Type{<:SizedOffsetMatrix}) = ArrayInterface.Contiguous{1}()
17-
ArrayInterface.contiguous_batch_size(::Type{<:SizedOffsetMatrix}) = ArrayInterface.ContiguousBatch{0}()
18-
ArrayInterface.stride_rank(::Type{<:SizedOffsetMatrix}) = ArrayInterface.StrideRank{(1,2)}()
16+
ArrayInterface.contiguous_axis(::Type{<:SizedOffsetMatrix}) = Static(1)
17+
ArrayInterface.contiguous_batch_size(::Type{<:SizedOffsetMatrix}) = Static(0)
18+
ArrayInterface.stride_rank(::Type{<:SizedOffsetMatrix}) = (Static(1), Static(2))
1919
function ArrayInterface.strides(A::SizedOffsetMatrix{T,LR,UR,LC,UC}) where {T,LR,UR,LC,UC}
2020
(Static{1}(), (Static{UR}() - Static{LR}() + Static{1}()))
2121
end

src/map.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,12 @@ end
240240
end
241241

242242

243-
Base.@pure _all_dense(::ArrayInterface.DenseDims{D}) where {D} = all(D)
243+
@inline _all_dense(t::Tuple{ArrayInterface.True}) = true
244+
@inline _all_dense(t::Tuple{ArrayInterface.True,ArrayInterface.True,Vararg}) = _all_dense(Base.tail(t))
245+
@inline _all_dense(t::Tuple{ArrayInterface.True,ArrayInterface.False,Vararg}) = false
246+
@inline _all_dense(t::Tuple{ArrayInterface.False,Vararg}) = false
244247
@inline all_dense() = true
248+
@inline all_dense(A::Array) = true
245249
@inline all_dense(A::AbstractArray) = _all_dense(ArrayInterface.dense_dims(A))
246250
@inline all_dense(A::AbstractArray, B::AbstractArray, C::Vararg{AbstractArray,K}) where {K} = all_dense(A) && all_dense(B, C...)
247251

src/reconstruct_loopset.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,19 @@ function pushvarg!(ls::LoopSet, ar::ArrayReferenceMeta, i, name)
145145
# pushpreamble!(ls, Expr(:(=), name, Expr(:call, :(VectorizationBase.zero_offsets), extract_varg(i))))
146146
pushpreamble!(ls, Expr(:(=), name, extract_varg(i)))
147147
end
148+
function rank_to_sortperm(R::NTuple{N,Int}) where {N}
149+
sp = ntuple(zero, Val{N}())
150+
r = ntuple(n -> sum(R[n] .≥ R), Val{N}())
151+
@inbounds for n = 1:N
152+
sp = Base.setindex(sp, n, r[n])
153+
end
154+
sp
155+
end
148156
function add_mref!(
149157
ls::LoopSet, ar::ArrayReferenceMeta, i::Int, @nospecialize(_::Type{S}), name
150158
) where {T, N, C, B, R, X, O, S <: AbstractStridedPointer{T,N,C,B,R,X,O}}
151159
@assert B 0 "Batched arrays not supported yet."
152-
sp = ArrayInterface.rank_to_sortperm(R)
160+
sp = rank_to_sortperm(R)
153161
# maybe no change needed? -- optimize common case
154162
column_major = ntuple(identity, N)
155163
li = ar.loopedindex;

test/gemm.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -630,9 +630,9 @@
630630
end
631631
Base.unsafe_convert(::Type{Ptr{T}}, A::SizedMatrix{M,N,T}) where {M,N,T} = pointer(A.data)
632632
LoopVectorization.ArrayInterface.strides(::SizedMatrix{M}) where {M} = (LoopVectorization.Static{1}(),LoopVectorization.Static{M}())
633-
LoopVectorization.ArrayInterface.contiguous_axis(::Type{<:SizedMatrix}) = LoopVectorization.ArrayInterface.Contiguous{1}()
634-
LoopVectorization.ArrayInterface.contiguous_batch_size(::Type{<:SizedMatrix}) = LoopVectorization.ArrayInterface.ContiguousBatch{0}()
635-
LoopVectorization.ArrayInterface.stride_rank(::Type{<:SizedMatrix}) = LoopVectorization.ArrayInterface.StrideRank{(1,2)}()
633+
LoopVectorization.ArrayInterface.contiguous_axis(::Type{<:SizedMatrix}) = LoopVectorization.One()
634+
LoopVectorization.ArrayInterface.contiguous_batch_size(::Type{<:SizedMatrix}) = LoopVectorization.Zero()
635+
LoopVectorization.ArrayInterface.stride_rank(::Type{<:SizedMatrix}) = (LoopVectorization.Static(1), LoopVectorization.Static(2))
636636
LoopVectorization.ArrayInterface.offsets(::SizedMatrix) = (LoopVectorization.Static{0}(), LoopVectorization.Static{0}())
637637
# struct ZeroInitializedArray{T,N,A<:DenseArray{T,N}} <: DenseArray{T,N}
638638
# data::A

test/offsetarrays.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ using LoopVectorization: Static
102102
Base.axes(::SizedOffsetMatrix{T,LR,UR,LC,UC}) where {T,LR,UR,LC,UC} = (Static{LR}():Static{UR}(),Static{LC}():Static{UC}())
103103
Base.parent(A::SizedOffsetMatrix) = A.data
104104
Base.unsafe_convert(::Type{Ptr{T}}, A::SizedOffsetMatrix{T}) where {T} = pointer(A.data)
105-
ArrayInterface.contiguous_axis(::Type{<:SizedOffsetMatrix}) = ArrayInterface.Contiguous{1}()
106-
ArrayInterface.contiguous_batch_size(::Type{<:SizedOffsetMatrix}) = ArrayInterface.ContiguousBatch{0}()
107-
ArrayInterface.stride_rank(::Type{<:SizedOffsetMatrix}) = ArrayInterface.StrideRank{(1,2)}()
105+
ArrayInterface.contiguous_axis(::Type{<:SizedOffsetMatrix}) = ArrayInterface.One()
106+
ArrayInterface.contiguous_batch_size(::Type{<:SizedOffsetMatrix}) = ArrayInterface.Zero()
107+
ArrayInterface.stride_rank(::Type{<:SizedOffsetMatrix}) = (ArrayInterface.StaticInt(1), ArrayInterface.StaticInt(2))
108108
function ArrayInterface.strides(A::SizedOffsetMatrix{T,LR,UR,LC,UC}) where {T,LR,UR,LC,UC}
109109
(Static{1}(), (Static{UR}() - Static{LR}() + Static{1}()))
110110
end

0 commit comments

Comments
 (0)