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
26 changes: 26 additions & 0 deletions src/mkl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,19 @@ to avoid allocations and does not require libblastrampoline.
"""
struct MKLLUFactorization <: AbstractFactorization end

# Check if MKL is available
@static if !@isdefined(MKL_jll)
__mkl_isavailable() = false
else
__mkl_isavailable() = MKL_jll.is_available()
end

function getrf!(A::AbstractMatrix{<:ComplexF64};
ipiv = similar(A, BlasInt, min(size(A, 1), size(A, 2))),
info = Ref{BlasInt}(),
check = false)
__mkl_isavailable() ||
error("Error, MKL binary is missing but solve is being called. Report this issue")
require_one_based_indexing(A)
check && chkfinite(A)
chkstride1(A)
Expand All @@ -33,6 +41,8 @@ function getrf!(A::AbstractMatrix{<:ComplexF32};
ipiv = similar(A, BlasInt, min(size(A, 1), size(A, 2))),
info = Ref{BlasInt}(),
check = false)
__mkl_isavailable() ||
error("Error, MKL binary is missing but solve is being called. Report this issue")
require_one_based_indexing(A)
check && chkfinite(A)
chkstride1(A)
Expand All @@ -53,6 +63,8 @@ function getrf!(A::AbstractMatrix{<:Float64};
ipiv = similar(A, BlasInt, min(size(A, 1), size(A, 2))),
info = Ref{BlasInt}(),
check = false)
__mkl_isavailable() ||
error("Error, MKL binary is missing but solve is being called. Report this issue")
require_one_based_indexing(A)
check && chkfinite(A)
chkstride1(A)
Expand All @@ -73,6 +85,8 @@ function getrf!(A::AbstractMatrix{<:Float32};
ipiv = similar(A, BlasInt, min(size(A, 1), size(A, 2))),
info = Ref{BlasInt}(),
check = false)
__mkl_isavailable() ||
error("Error, MKL binary is missing but solve is being called. Report this issue")
require_one_based_indexing(A)
check && chkfinite(A)
chkstride1(A)
Expand All @@ -94,6 +108,8 @@ function getrs!(trans::AbstractChar,
ipiv::AbstractVector{BlasInt},
B::AbstractVecOrMat{<:ComplexF64};
info = Ref{BlasInt}())
__mkl_isavailable() ||
error("Error, MKL binary is missing but solve is being called. Report this issue")
require_one_based_indexing(A, ipiv, B)
LinearAlgebra.LAPACK.chktrans(trans)
chkstride1(A, B, ipiv)
Expand All @@ -119,6 +135,8 @@ function getrs!(trans::AbstractChar,
ipiv::AbstractVector{BlasInt},
B::AbstractVecOrMat{<:ComplexF32};
info = Ref{BlasInt}())
__mkl_isavailable() ||
error("Error, MKL binary is missing but solve is being called. Report this issue")
require_one_based_indexing(A, ipiv, B)
LinearAlgebra.LAPACK.chktrans(trans)
chkstride1(A, B, ipiv)
Expand All @@ -144,6 +162,8 @@ function getrs!(trans::AbstractChar,
ipiv::AbstractVector{BlasInt},
B::AbstractVecOrMat{<:Float64};
info = Ref{BlasInt}())
__mkl_isavailable() ||
error("Error, MKL binary is missing but solve is being called. Report this issue")
require_one_based_indexing(A, ipiv, B)
LinearAlgebra.LAPACK.chktrans(trans)
chkstride1(A, B, ipiv)
Expand All @@ -169,6 +189,8 @@ function getrs!(trans::AbstractChar,
ipiv::AbstractVector{BlasInt},
B::AbstractVecOrMat{<:Float32};
info = Ref{BlasInt}())
__mkl_isavailable() ||
error("Error, MKL binary is missing but solve is being called. Report this issue")
require_one_based_indexing(A, ipiv, B)
LinearAlgebra.LAPACK.chktrans(trans)
chkstride1(A, B, ipiv)
Expand Down Expand Up @@ -213,6 +235,8 @@ end

function SciMLBase.solve!(cache::LinearCache, alg::MKLLUFactorization;
kwargs...)
__mkl_isavailable() ||
error("Error, MKL binary is missing but solve is being called. Report this issue")
A = cache.A
A = convert(AbstractMatrix, A)
if cache.isfresh
Expand Down Expand Up @@ -266,6 +290,8 @@ end

function SciMLBase.solve!(cache::LinearCache, alg::MKL32MixedLUFactorization;
kwargs...)
__mkl_isavailable() ||
error("Error, MKL binary is missing but solve is being called. Report this issue")
A = cache.A
A = convert(AbstractMatrix, A)

Expand Down
25 changes: 24 additions & 1 deletion src/openblas.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,19 @@ sol = solve(prob, OpenBLASLUFactorization())
"""
struct OpenBLASLUFactorization <: AbstractFactorization end

# OpenBLAS methods - OpenBLAS_jll is always available as a standard library
# Check if OpenBLAS is available
@static if !@isdefined(OpenBLAS_jll)
__openblas_isavailable() = false
else
__openblas_isavailable() = OpenBLAS_jll.is_available()
end

function openblas_getrf!(A::AbstractMatrix{<:ComplexF64};
ipiv = similar(A, BlasInt, min(size(A, 1), size(A, 2))),
info = Ref{BlasInt}(),
check = false)
__openblas_isavailable() ||
error("Error, OpenBLAS binary is missing but solve is being called. Report this issue")
require_one_based_indexing(A)
check && chkfinite(A)
chkstride1(A)
Expand All @@ -59,6 +66,8 @@ function openblas_getrf!(A::AbstractMatrix{<:ComplexF32};
ipiv = similar(A, BlasInt, min(size(A, 1), size(A, 2))),
info = Ref{BlasInt}(),
check = false)
__openblas_isavailable() ||
error("Error, OpenBLAS binary is missing but solve is being called. Report this issue")
require_one_based_indexing(A)
check && chkfinite(A)
chkstride1(A)
Expand All @@ -79,6 +88,8 @@ function openblas_getrf!(A::AbstractMatrix{<:Float64};
ipiv = similar(A, BlasInt, min(size(A, 1), size(A, 2))),
info = Ref{BlasInt}(),
check = false)
__openblas_isavailable() ||
error("Error, OpenBLAS binary is missing but solve is being called. Report this issue")
require_one_based_indexing(A)
check && chkfinite(A)
chkstride1(A)
Expand All @@ -99,6 +110,8 @@ function openblas_getrf!(A::AbstractMatrix{<:Float32};
ipiv = similar(A, BlasInt, min(size(A, 1), size(A, 2))),
info = Ref{BlasInt}(),
check = false)
__openblas_isavailable() ||
error("Error, OpenBLAS binary is missing but solve is being called. Report this issue")
require_one_based_indexing(A)
check && chkfinite(A)
chkstride1(A)
Expand All @@ -120,6 +133,8 @@ function openblas_getrs!(trans::AbstractChar,
ipiv::AbstractVector{BlasInt},
B::AbstractVecOrMat{<:ComplexF64};
info = Ref{BlasInt}())
__openblas_isavailable() ||
error("Error, OpenBLAS binary is missing but solve is being called. Report this issue")
require_one_based_indexing(A, ipiv, B)
LinearAlgebra.LAPACK.chktrans(trans)
chkstride1(A, B, ipiv)
Expand All @@ -145,6 +160,8 @@ function openblas_getrs!(trans::AbstractChar,
ipiv::AbstractVector{BlasInt},
B::AbstractVecOrMat{<:ComplexF32};
info = Ref{BlasInt}())
__openblas_isavailable() ||
error("Error, OpenBLAS binary is missing but solve is being called. Report this issue")
require_one_based_indexing(A, ipiv, B)
LinearAlgebra.LAPACK.chktrans(trans)
chkstride1(A, B, ipiv)
Expand All @@ -170,6 +187,8 @@ function openblas_getrs!(trans::AbstractChar,
ipiv::AbstractVector{BlasInt},
B::AbstractVecOrMat{<:Float64};
info = Ref{BlasInt}())
__openblas_isavailable() ||
error("Error, OpenBLAS binary is missing but solve is being called. Report this issue")
require_one_based_indexing(A, ipiv, B)
LinearAlgebra.LAPACK.chktrans(trans)
chkstride1(A, B, ipiv)
Expand All @@ -195,6 +214,8 @@ function openblas_getrs!(trans::AbstractChar,
ipiv::AbstractVector{BlasInt},
B::AbstractVecOrMat{<:Float32};
info = Ref{BlasInt}())
__openblas_isavailable() ||
error("Error, OpenBLAS binary is missing but solve is being called. Report this issue")
require_one_based_indexing(A, ipiv, B)
LinearAlgebra.LAPACK.chktrans(trans)
chkstride1(A, B, ipiv)
Expand Down Expand Up @@ -239,6 +260,8 @@ end

function SciMLBase.solve!(cache::LinearCache, alg::OpenBLASLUFactorization;
kwargs...)
__openblas_isavailable() ||
error("Error, OpenBLAS binary is missing but solve is being called. Report this issue")
A = cache.A
A = convert(AbstractMatrix, A)
if cache.isfresh
Expand Down
Loading