From 3d5ed71212a89dfe33cfabebfb469266b2a56a2b Mon Sep 17 00:00:00 2001 From: Daniel Karrasch Date: Sun, 11 Jun 2023 21:49:48 +0200 Subject: [PATCH 1/5] use unwrapping mechanism for triangular matrices --- lib/mkl/linalg.jl | 36 ++++++++++++++++++++++++++++-------- lib/mkl/wrappers.jl | 2 +- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/lib/mkl/linalg.jl b/lib/mkl/linalg.jl index f41e34b4..d20d9bcd 100644 --- a/lib/mkl/linalg.jl +++ b/lib/mkl/linalg.jl @@ -137,6 +137,14 @@ if VERSION < v"1.10.0-DEV.1365" end # triangular +if isdefined(LinearAlgebra, :generic_trimatmul!) # VERSION >= v"1.10-DEVXYZ" +# multiplication +LinearAlgebra.generic_trimatmul!(c::oneStridedVector{T}, uploc, isunitc, tfun::Function, A::oneStridedMatrix{T}, b::AbstractVector{T}) where {T<:onemklFloat} = + trmv!(uploc, tfun === identity ? 'N' : tfun === transpose ? 'T' : 'C', isunitc, A, c === b ? c : copyto!(c, b)) +# division +LinearAlgebra.generic_trimatdiv!(C::oneStridedVector{T}, uploc, isunitc, tfun::Function, A::oneStridedMatrix{T}, B::AbstractVector{T}) where {T<:CublasFloat} = + trsv!(uploc, tfun === identity ? 'N' : tfun === transpose ? 'T' : 'C', isunitc, A, C === B ? C : copyto!(C, B)) +else ## direct multiplication/division for (t, uploc, isunitc) in ((:LowerTriangular, 'L', 'N'), (:UnitLowerTriangular, 'L', 'U'), @@ -183,6 +191,7 @@ for (t, uploc, isunitc) in ((:LowerTriangular, 'U', 'N'), trsv!($uploc, 'C', $isunitc, parent(parent(A)), B) end end +end # VERSION # @@ -254,6 +263,16 @@ end end # VERSION # triangular +if isdefined(LinearAlgebra, :generic_trimatmul!) # VERSION >= v"1.10-DEVXYZ" +LinearAlgebra.generic_trimatmul!(C::oneStridedMatrix{T}, uploc, isunitc, tfun::Function, A::oneStridedMatrix{T}, B::oneStridedMatrix{T}) where {T<:onemklFloat} = + trmm!('L', uploc, tfun === identity ? 'N' : tfun === transpose ? 'T' : 'C', isunitc, one(T), A, C === B ? C : copyto!(C, B)) +LinearAlgebra.generic_mattrimul!(C::oneStridedMatrix{T}, uploc, isunitc, tfun::Function, A::oneStridedMatrix{T}, B::oneStridedMatrix{T}) where {T<:onemklFloat} = + trmm!('R', uploc, tfun === identity ? 'N' : tfun === transpose ? 'T' : 'C', isunitc, one(T), B, C === A ? C : copyto!(C, A)) +LinearAlgebra.generic_trimatdiv!(C::oneStridedMatrix{T}, uploc, isunitc, tfun::Function, A::oneStridedMatrix{T}, B::oneStridedMatrix{T}) where {T<:onemklFloat} = + trsm!('L', uploc, tfun === identity ? 'N' : tfun === transpose ? 'T' : 'C', isunitc, one(T), A, C === B ? C : copyto!(C, B)) +LinearAlgebra.generic_mattridiv!(C::oneStridedMatrix{T}, uploc, isunitc, tfun::Function, A::oneStridedMatrix{T}, B::oneStridedMatrix{T}) where {T<:onemklFloat} = + trsm!('R', uploc, tfun === identity ? 'N' : tfun === transpose ? 'T' : 'C', isunitc, one(T), B, C === A ? C : copyto!(C, A)) +else ## direct multiplication/division for (t, uploc, isunitc) in ((:LowerTriangular, 'L', 'N'), (:UnitLowerTriangular, 'L', 'U'), @@ -261,16 +280,17 @@ for (t, uploc, isunitc) in ((:LowerTriangular, 'L', 'N'), (:UnitUpperTriangular, 'U', 'U')) @eval begin # Multiplication - LinearAlgebra.lmul!(A::$t{T,<:oneStridedVecOrMat}, - B::oneStridedVecOrMat{T}) where {T<:onemklFloat} = - trmm!('L', $uploc, 'N', $isunitc, one(T), parent(A), B, B) - LinearAlgebra.rmul!(A::oneStridedVecOrMat{T}, - B::$t{T,<:oneStridedVecOrMat}) where {T<:onemklFloat} = - trmm!('R', $uploc, 'N', $isunitc, one(T), parent(B), A, A) + LinearAlgebra.lmul!(A::$t{T,<:oneStridedMatrix}, + B::oneStridedMatrix{T}) where {T<:onemklFloat} = + trmm!('L', $uploc, 'N', $isunitc, one(T), parent(A), B) + LinearAlgebra.rmul!(A::oneStridedMatrix{T}, + B::$t{T,<:oneStridedMatrix}) where {T<:onemklFloat} = + trmm!('R', $uploc, 'N', $isunitc, one(T), parent(B), A) # Left division - LinearAlgebra.ldiv!(A::$t{T,<:oneStridedVecOrMat}, - B::oneStridedVecOrMat{T}) where {T<:onemklFloat} = + LinearAlgebra.ldiv!(A::$t{T,<:oneStridedMatrix}, + B::oneStridedMatrix{T}) where {T<:onemklFloat} = trsm!('L', $uploc, 'N', $isunitc, one(T), parent(A), B) end end +end # VERSION diff --git a/lib/mkl/wrappers.jl b/lib/mkl/wrappers.jl index 10cabc15..c5e5388e 100644 --- a/lib/mkl/wrappers.jl +++ b/lib/mkl/wrappers.jl @@ -1100,7 +1100,7 @@ function trmm(side::Char, alpha::Number, A::oneStridedMatrix{T}, B::oneStridedMatrix{T}) where T - trmm!(side, uplo, transa, diag, alpha, A, B) + trmm!(side, uplo, transa, diag, alpha, A, copy(B)) end function trsm(side::Char, uplo::Char, From 8ac581992ec3f0259aca91879b85b2d19862cd4d Mon Sep 17 00:00:00 2001 From: Daniel Karrasch Date: Sun, 11 Jun 2023 22:10:14 +0200 Subject: [PATCH 2/5] fix trmm test --- test/onemkl.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/onemkl.jl b/test/onemkl.jl index 0f757ae6..cfe46af9 100644 --- a/test/onemkl.jl +++ b/test/onemkl.jl @@ -655,9 +655,9 @@ end dA = oneArray(A) dB = oneArray(B) C = alpha*A*B - oneMKL.trmm('L','U','N','N',alpha,dA,dB) + dC = oneMKL.trmm('L','U','N','N',alpha,dA,dB) # move to host and compare - h_C = Array(dB) + h_C = Array(dC) @test C ≈ h_C end From c63f20089f696b5e3443b9579d61faad2e730de4 Mon Sep 17 00:00:00 2001 From: Daniel Karrasch Date: Mon, 12 Jun 2023 11:38:36 +0200 Subject: [PATCH 3/5] fix copy-paste mistake --- lib/mkl/linalg.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mkl/linalg.jl b/lib/mkl/linalg.jl index d20d9bcd..66db0123 100644 --- a/lib/mkl/linalg.jl +++ b/lib/mkl/linalg.jl @@ -142,7 +142,7 @@ if isdefined(LinearAlgebra, :generic_trimatmul!) # VERSION >= v"1.10-DEVXYZ" LinearAlgebra.generic_trimatmul!(c::oneStridedVector{T}, uploc, isunitc, tfun::Function, A::oneStridedMatrix{T}, b::AbstractVector{T}) where {T<:onemklFloat} = trmv!(uploc, tfun === identity ? 'N' : tfun === transpose ? 'T' : 'C', isunitc, A, c === b ? c : copyto!(c, b)) # division -LinearAlgebra.generic_trimatdiv!(C::oneStridedVector{T}, uploc, isunitc, tfun::Function, A::oneStridedMatrix{T}, B::AbstractVector{T}) where {T<:CublasFloat} = +LinearAlgebra.generic_trimatdiv!(C::oneStridedVector{T}, uploc, isunitc, tfun::Function, A::oneStridedMatrix{T}, B::AbstractVector{T}) where {T<:onemklFloat} = trsv!(uploc, tfun === identity ? 'N' : tfun === transpose ? 'T' : 'C', isunitc, A, C === B ? C : copyto!(C, B)) else ## direct multiplication/division From 8abc934f6713458e2a7f162a1e7e5fa07e593a28 Mon Sep 17 00:00:00 2001 From: Tim Besard Date: Sat, 29 Jul 2023 21:26:10 +0200 Subject: [PATCH 4/5] Enable 1.10 CI. --- .buildkite/pipeline.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 666d4d25..09c5df06 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -31,7 +31,8 @@ steps: - "1.6" - "1.7" - "1.8" - - "1.9-nightly" + - "1.9" + - "1.10-nightly" - "nightly" adjustments: - with: From 091628687be80d34f8b0c21c3c9ed6ecac9364ab Mon Sep 17 00:00:00 2001 From: Tim Besard Date: Mon, 14 Aug 2023 12:23:23 +0200 Subject: [PATCH 5/5] Allow 1.10 to fail, for now. --- .buildkite/pipeline.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 09c5df06..ee19692b 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -38,6 +38,9 @@ steps: - with: julia: "nightly" soft_fail: true + - with: + julia: "1.10-nightly" + soft_fail: true # Special tests - group: ":eyes: Special"