Skip to content

Commit ba76345

Browse files
authored
Take advantage of sparsity in blasmul! (#18)
* Take advantage of sparsity in blasmul! * Update runtests.jl
1 parent 7c5c010 commit ba76345

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
*.jl.mem
44
deps/deps.jl
55
Manifest.toml
6+
.DS_Store

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ArrayLayouts"
22
uuid = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
33
authors = ["Sheehan Olver <[email protected]>"]
4-
version = "0.3.0"
4+
version = "0.3.1"
55

66
[deps]
77
FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b"

src/muladd.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ function default_blasmul!(α, A::AbstractMatrix, B::AbstractMatrix, β, C::Abstr
181181
(iszero(mA) || iszero(nB)) && return C
182182
iszero(nA) && return lmul!(β, C)
183183

184-
@inbounds for k in colsupport(A), j in rowsupport(B)
184+
@inbounds for k in colsupport(A), j in rowsupport(B,rowsupport(A,k))
185185
z2 = zero(A[k, 1]*B[1, j] + A[k, 1]*B[1, j])
186186
Ctmp = convert(promote_type(eltype(C), typeof(z2)), z2)
187187
@simd for ν = rowsupport(A,k) colsupport(B,j)

test/runtests.jl

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using ArrayLayouts, Random, Test
1+
using ArrayLayouts, Random, FillArrays, Test
22
import ArrayLayouts: MemoryLayout, @_layoutlmul, triangulardata
33

44
Random.seed!(0)
@@ -47,6 +47,22 @@ MemoryLayout(::Type{MyMatrix}) = DenseColumnMajor()
4747

4848
@test qr(A) isa LinearAlgebra.QRCompactWY
4949
@test inv(A) inv(A.A)
50+
51+
Bin = randn(5,5)
52+
B = MyMatrix(copy(Bin))
53+
muladd!(1.0, A, A, 2.0, B)
54+
@test all(B .=== A.A^2 + 2Bin)
55+
56+
# tiled_blasmul!
57+
B = MyMatrix(copy(Bin))
58+
muladd!(1.0, Ones(5,5), A, 2.0, B)
59+
60+
#generic_blasmul!
61+
A = BigFloat.(randn(5,5))
62+
Bin = BigFloat.(randn(5,5))
63+
B = copy(Bin)
64+
muladd!(1.0, Ones(5,5), A, 2.0, B)
65+
@test B == Ones(5,5)*A + 2.0Bin
5066
end
5167

5268
struct MyUpperTriangular{T} <: AbstractMatrix{T}

0 commit comments

Comments
 (0)