Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,16 @@ steps:
- "1.6"
- "1.7"
- "1.8"
- "1.9-nightly"
- "1.9"
- "1.10-nightly"
- "nightly"
adjustments:
- with:
julia: "nightly"
soft_fail: true
- with:
julia: "1.10-nightly"
soft_fail: true

# Special tests
- group: ":eyes: Special"
Expand Down
36 changes: 28 additions & 8 deletions lib/mkl/linalg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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<:onemklFloat} =
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'),
Expand Down Expand Up @@ -183,6 +191,7 @@ for (t, uploc, isunitc) in ((:LowerTriangular, 'U', 'N'),
trsv!($uploc, 'C', $isunitc, parent(parent(A)), B)
end
end
end # VERSION


#
Expand Down Expand Up @@ -254,23 +263,34 @@ 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))
Comment on lines +273 to +274
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This adds rdiv!-functionality, which could be included in the "old" branch below.

else
## direct multiplication/division
for (t, uploc, isunitc) in ((:LowerTriangular, 'L', 'N'),
(:UnitLowerTriangular, 'L', 'U'),
(:UpperTriangular, 'U', '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)
Comment on lines -264 to -269
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the signature of trmm!, only matrix arguments are allowed, so either it should be relaxed over there or, as is done here, restricted here.

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
2 changes: 1 addition & 1 deletion lib/mkl/wrappers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was oversight, and the corresponding test required an according change.

end
function trsm(side::Char,
uplo::Char,
Expand Down
4 changes: 2 additions & 2 deletions test/onemkl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down