Skip to content

Commit 11ed033

Browse files
committed
Added explicit dependency on ArrayInterface
1 parent 98ac7ba commit 11ed033

File tree

4 files changed

+27
-3
lines changed

4 files changed

+27
-3
lines changed

Project.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ authors = ["Mason Protter", "Chris Elrod", "Dilum Aluthge", "contributors"]
44
version = "0.1.0-DEV"
55

66
[deps]
7+
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
78
LoopVectorization = "bdcacae8-1622-11e9-2a5c-532679323890"
89
VectorizationBase = "3d5dd08c-fd9d-11e8-17fa-ed2836048c2f"
910

1011
[compat]
11-
BenchmarkTools = "0.5"
12+
ArrayInterface = "2.14"
1213
LoopVectorization = "0.9.14"
1314
VectorizationBase = "0.14.9"
1415
julia = "1.5"
@@ -19,8 +20,8 @@ InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
1920
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
2021
LoopVectorization = "bdcacae8-1622-11e9-2a5c-532679323890"
2122
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
22-
VectorizationBase = "3d5dd08c-fd9d-11e8-17fa-ed2836048c2f"
2323
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
24+
VectorizationBase = "3d5dd08c-fd9d-11e8-17fa-ed2836048c2f"
2425

2526
[targets]
2627
test = ["BenchmarkTools", "InteractiveUtils", "LinearAlgebra", "LoopVectorization", "Random", "VectorizationBase", "Test"]

src/Octavian.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module Octavian
22

3+
import ArrayInterface
34
import LoopVectorization
45
import VectorizationBase
56

src/matmul.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
evenly_divide(x, y) = cld(x, cld(x, y))
22
evenly_divide(x, y, z) = cld(evenly_divide(x, y), z) * z
33

4+
_dim1contig(::ArrayInterface.Contiguous) = false
5+
_dim1contig(::ArrayInterface.Contiguous{1}) = true
6+
dim1contig(::Type{A}) where {A <: StridedArray} = _dim1contig(ArrayInterface.contiguous_axis(A))
7+
dim1contig(::Type) = false
8+
dim1contig(A) = dim1contig(typeof(A))
9+
410
"""
511
matmul!(C::AbstractMatrix, A::AbstractMatrix, B::AbstractMatrix, _α = 1, _β = 0)
612
"""
@@ -10,7 +16,7 @@ function matmul!(C::AbstractMatrix{T}, A::AbstractMatrix{T}, B::AbstractMatrix{T
1016
M, K, N = matmul_sizes(C, A, B)
1117

1218
# Check if maybe it's better not to pack at all.
13-
if M * K _Mc * _Kc && A isa DenseArray && C isa StridedArray && B isa StridedArray && #
19+
if M * K _Mc * _Kc && dim1contig(A) && LoopVectorization.check_args(C, A, B) &&
1420
(stride(A,2) 72 || (iszero(stride(A,2) & (VectorizationBase.pick_vector_width(eltype(A))-1)) && iszero(reinterpret(Int,pointer(A)) & 63)))
1521
macrokernel!(C, A, B, _α, _β)
1622
return C

test/matmul_coverage.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,19 @@ end
5757
@test @time(Octavian.matmul(A, B′)) == A * B′
5858
@test @time(Octavian.matmul(A′, B′)) == A′ * B′
5959
end
60+
61+
@time @testset "A not-a-StrideArray" begin
62+
m = 20
63+
n = 20
64+
k = 20
65+
A = view(rand(Float64, 2m, 2k), 1:2:2m, 2:2:2k)
66+
B = rand(Float64, k, n)
67+
A′ = view(permutedims(parent(A))', 1:2:2m, 2:2:2k)
68+
B′ = permutedims(B)'
69+
@show m, k, n
70+
@test @time(Octavian.matmul(A, B)) A * B
71+
@test @time(Octavian.matmul(A′, B)) A′ * B
72+
@test @time(Octavian.matmul(A, B′)) A * B′
73+
@test @time(Octavian.matmul(A′, B′)) A′ * B′
74+
end
75+

0 commit comments

Comments
 (0)