Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify mul! dispatch #49806

Merged
merged 2 commits into from
May 15, 2023
Merged

Simplify mul! dispatch #49806

merged 2 commits into from
May 15, 2023

Conversation

dkarrasch
Copy link
Member

Guys, I saw the light, while I was struck by a thunder. Look what we can do! Let a generic mul! strip off potential AdjOrTrans wrappers, and peel off the actually data-storing array. With this design, it is crystal-clear what SparseArrays.jl, GPUArrays.jl and its surounding ecosystem need to overload. Not tons of mul!, but generic_matmatmul! with all three matrix arguments of their own(ed) kind: SparseMatrixCSC, CuArray, MtlArray etc. In this PR, we have 4(!) methods as follows:

julia> methods(LinearAlgebra.generic_matmatmul!, (Any, Any, Any, Any, Any, Any))
# 4 methods for generic function "generic_matmatmul!" from LinearAlgebra:
 [1] generic_matmatmul!(C::StridedMatrix{T}, tA, tB, A::StridedVecOrMat{T}, B::StridedVecOrMat{T}, _add::LinearAlgebra.MulAddMul) where T<:Union{Float32, Float64, ComplexF64, ComplexF32}
     @ ~/Documents/julia/usr/share/julia/stdlib/v1.10/LinearAlgebra/src/matmul.jl:349
 [2] generic_matmatmul!(C::StridedVecOrMat{Complex{T}}, tA, tB, A::StridedVecOrMat{Complex{T}}, B::StridedVecOrMat{T}, _add::MulAddMul=MulAddMul()) where {T<:BlasReal}
     @ ~/Documents/julia/usr/share/julia/stdlib/v1.10/LinearAlgebra/src/matmul.jl:411
 [3] generic_matmatmul!(C::AbstractMatrix, tA, tB, A::AbstractMatrix, B::AbstractMatrix, _add::LinearAlgebra.MulAddMul)
     @ ~/Documents/julia/usr/share/julia/stdlib/v1.10/LinearAlgebra/src/matmul.jl:780
 [4] generic_matmatmul!(C::AbstractVecOrMat, tA, tB, A::AbstractVecOrMat, B::AbstractVecOrMat, _add::LinearAlgebra.MulAddMul)
     @ ~/Documents/julia/usr/share/julia/stdlib/v1.10/LinearAlgebra/src/matmul.jl:798

That should be really helpful in terms of package load times.

@dkarrasch dkarrasch added the linear algebra Linear algebra label May 13, 2023
@dkarrasch
Copy link
Member Author

@nanosoldier runtests()

@nanosoldier renbenchmarks("linalg", vs=":master")

@dkarrasch
Copy link
Member Author

@nanosoldier runbenchmarks("linalg", vs=":master")

@nanosoldier
Copy link
Collaborator

Your benchmark job has completed - no performance regressions were detected. A full report can be found here.

@nanosoldier
Copy link
Collaborator

Your package evaluation job has completed - possible new issues were detected.
A full report can be found here.

@maleadt
Copy link
Member

maleadt commented May 13, 2023

Many tests were skipped because of PkgEval issue; let's try again:

@nanosoldier runtests()

@dkarrasch
Copy link
Member Author

Aha, okay, out of the tested packages that failed I couldn't find a single related one. But some strange errors like undefined variables. Is that related to the issue you mentioned?

@nanosoldier
Copy link
Collaborator

Your package evaluation job has completed - possible new issues were detected.
A full report can be found here.

@dkarrasch
Copy link
Member Author

There seem to be no related issues.

@maleadt
Copy link
Member

maleadt commented May 14, 2023

Is that related to the issue you mentioned?

No, just the skipped packages with Disk quota exceeded.

@dkarrasch
Copy link
Member Author

I wonder if this will help packages already, just because the LinearAlgebra dispatch "competitors" are gone?

I applied the same dispatch move to matvec multiplication, so to be safe, let's run pkgeval once more, and then merge. BTW, one can do something similar to HermOrSym mul! methods, but I'll do it in a separate PR. It's not so clear to me if that is worth it, but we'll see.

@nanosoldier runtests()

@nanosoldier
Copy link
Collaborator

Your package evaluation job has completed - possible new issues were detected.
A full report can be found here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
linear algebra Linear algebra
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants