Skip to content

Commit

Permalink
Updates for ArrayInterface 7, fixes #168 (#169)
Browse files Browse the repository at this point in the history
  • Loading branch information
chriselrod authored Mar 4, 2023
1 parent 4304bce commit c6d46de
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 16 deletions.
8 changes: 4 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
name = "Octavian"
uuid = "6fd5a793-0b7e-452c-907f-f8bfe9c57db4"
authors = ["Chris Elrod", "Dilum Aluthge", "Mason Protter", "contributors"]
version = "0.3.20"
version = "0.3.21"

[deps]
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
CPUSummary = "2a0fbf3d-bb9c-48f3-b0a9-814d99fd7ab9"
IfElse = "615f187c-cbe4-4ef1-ba3b-2fcf58d6d173"
LoopVectorization = "bdcacae8-1622-11e9-2a5c-532679323890"
Expand All @@ -13,19 +12,20 @@ PolyesterWeave = "1d0040c9-8b98-4ee7-8388-3f51789ca0ad"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
SnoopPrecompile = "66db9d55-30c0-4569-8b51-7e840670fc0c"
Static = "aedffcd0-7271-4cad-89d0-dc628f76c6d3"
StaticArrayInterface = "0d7ed370-da01-4f52-bd93-41d350b8b718"
ThreadingUtilities = "8290d209-cae3-49c0-8002-c8c24d57dab5"
VectorizationBase = "3d5dd08c-fd9d-11e8-17fa-ed2836048c2f"

[compat]
ArrayInterface = "3.1.14, 5.0.1, 6"
CPUSummary = "0.1.26, 0.2.1"
IfElse = "0.1"
LoopVectorization = "0.12.86"
ManualMemory = "0.1.1"
PolyesterWeave = "0.1.1, 0.2"
Requires = "1"
SnoopPrecompile = "1"
Static = "0.7.5, 0.8"
Static = "0.8.4"
StaticArrayInterface = "1"
ThreadingUtilities = "0.5"
VectorizationBase = "0.21.15"
julia = "1.6"
Expand Down
6 changes: 4 additions & 2 deletions src/Octavian.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Octavian

using Requires: @require

using VectorizationBase, ArrayInterface, LoopVectorization
using VectorizationBase, StaticArrayInterface, LoopVectorization

using VectorizationBase:
align,
Expand All @@ -18,7 +18,9 @@ using VectorizationBase:
has_feature
using CPUSummary: cache_size, num_cores, cache_inclusive, cache_linesize
using LoopVectorization: preserve_buffer, CloseOpen, UpperBoundedInteger
using ArrayInterface: size, strides, offsets, indices, axes, StrideIndex
using StaticArrayInterface:
static_size, static_strides, offsets, indices, axes, StrideIndex
const ArrayInterface = StaticArrayInterface
using IfElse: ifelse
using PolyesterWeave
using Static:
Expand Down
1 change: 0 additions & 1 deletion src/complex_matmul.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
real_rep(a::AbstractArray{Complex{T},N}) where {T,N} =
reinterpret(reshape, T, a)
#PtrArray(Ptr{T}(pointer(a)), (StaticInt(2), size(a)...))

for AT in [:AbstractVector, :AbstractMatrix] # to avoid ambiguity error
@eval begin
Expand Down
8 changes: 4 additions & 4 deletions src/matmul.jl
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ end
@inline contiguousstride1(A) = ArrayInterface.contiguous_axis(A) === One()
@inline contiguousstride1(A::AbstractStridedPointer{T,N,1}) where {T,N} = true
# @inline bytestride(A::AbstractArray, i) = VectorizationBase.bytestrides(A)[i]
@inline bytestride(A::AbstractStridedPointer, i) = strides(A)[i]
@inline bytestride(A::AbstractStridedPointer, i) = static_strides(A)[i]
@inline firstbytestride(A::AbstractStridedPointer) = bytestride(A, One())

@inline function vectormultiple(bytex, ::Type{Tc}, ::Type{Ta}) where {Tc,Ta}
Expand Down Expand Up @@ -154,8 +154,8 @@ end
B::AbstractMatrix{TB}
) where {TA,TB}
# TODO: if `M` and `N` are statically sized, shouldn't return a `Matrix`.
M, KA = size(A)
KB, N = size(B)
M, KA = static_size(A)
KB, N = static_size(B)
@assert KA == KB "Size mismatch."
if M === StaticInt(1)
transpose(Vector{promote_type(TA, TB)}(undef, N)), (M, KA, N)
Expand All @@ -168,7 +168,7 @@ end
B::AbstractVector{TB}
) where {TA,TB}
# TODO: if `M` and `N` are statically sized, shouldn't return a `Matrix`.
M, KA = size(A)
M, KA = static_size(A)
KB = length(B)
@assert KA == KB "Size mismatch."
Vector{promote_type(TA, TB)}(undef, M), (M, KA, One())
Expand Down
10 changes: 5 additions & 5 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ Checks sizes for compatibility, and preserves the static size information if
given a mix of static and dynamic sizes.
"""
@inline function matmul_sizes(C, A, B)
MC, NC = size(C)
MA, KA = size(A)
KB, NB = size(B)
MC, NC = static_size(C)
MA, KA = static_size(A)
KB, NB = static_size(B)
@assert ((MC == MA) & (KA == KB) & (NC == NB)) "Size mismatch."
(_select(MA, MC), _select(KA, KB), _select(NB, NC))
end
Expand Down Expand Up @@ -77,7 +77,7 @@ end
Bn = Core.ifelse(B > 1, B + 1, B)
quote
$(Expr(:meta, :inline))
x = strides(sp)
x = static_strides(sp)
x0 = $gf(x, 1, false)
si = StrideIndex{$(N + 1),$Rn,$Cn}($xt, $ot)
stridedpointer($gf(sp, :p), si, StaticInt{$Bn}())
Expand All @@ -97,7 +97,7 @@ end
end
quote
$(Expr(:meta, :inline))
x = strides(sp)
x = static_strides(sp)
o = offsets(sp)
si = StrideIndex{$(N - 1),$rt,$Cn}($xt, $ot)
stridedpointer($gf(sp, :p), si, StaticInt{$Bn}())
Expand Down

2 comments on commit c6d46de

@chriselrod
Copy link
Collaborator 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/78953

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.3.21 -m "<description of version>" c6d46de7b6b473848feedc5182842ae1bbede144
git push origin v0.3.21

Please sign in to comment.