Skip to content

Commit 2707d96

Browse files
committed
Fix MKL Pardiso
* iparm 12 -> 2 (transposed vs conjugate) * iparm 4 instead of 3 for reltol
1 parent 2b75abb commit 2707d96

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

ext/LinearSolvePardisoExt.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,18 @@ function LinearSolve.init_cacheval(alg::PardisoJL,
2525
@unpack nprocs, solver_type, matrix_type, cache_analysis, iparm, dparm = alg
2626
A = convert(AbstractMatrix, A)
2727

28-
solver = if Pardiso.PARDISO_LOADED[]
28+
transposed_iparm = 1
29+
solver = if false && Pardiso.PARDISO_LOADED[]
2930
solver = Pardiso.PardisoSolver()
3031
solver_type !== nothing && Pardiso.set_solver!(solver, solver_type)
3132

3233
solver
3334
else
3435
solver = Pardiso.MKLPardisoSolver()
3536
nprocs !== nothing && Pardiso.set_nprocs!(solver, nprocs)
36-
37+
# for mkl 1 means conjugated an 2 means transposed.
38+
# https://www.intel.com/content/www/us/en/docs/onemkl/developer-reference-c/2024-0/pardiso-iparm-parameter.html#IPARM37
39+
transposed_iparm = 2
3740
solver
3841
end
3942

@@ -73,7 +76,8 @@ function LinearSolve.init_cacheval(alg::PardisoJL,
7376
# applies these exact factors L and U for the next steps in a
7477
# preconditioned Krylov-Subspace iteration. If the iteration does not
7578
# converge, the solver will automatically switch back to the numerical factorization.
76-
Pardiso.set_iparm!(solver, 3, round(Int, abs(log10(reltol)), RoundDown) * 10 + 1)
79+
# Be aware that in the intel docs, iparm indexes are one lower.
80+
Pardiso.set_iparm!(solver, 4, round(Int, abs(log10(reltol)), RoundDown) * 10 + 1)
7781
end
7882

7983
# pass in vector of tuples like [(iparm::Int, key::Int) ...]
@@ -91,7 +95,7 @@ function LinearSolve.init_cacheval(alg::PardisoJL,
9195

9296
# Make sure to say it's transposed because its CSC not CSR
9397
# This is also the only value which should not be overwritten by users
94-
Pardiso.set_iparm!(solver, 12, 1)
98+
Pardiso.set_iparm!(solver, 12, transposed_iparm)
9599

96100
if cache_analysis
97101
Pardiso.set_phase!(solver, Pardiso.ANALYSIS)

test/pardiso/pardiso.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ for alg in (MKLPardisoIterate(),)
3434

3535
u = solve(prob2, alg; cache_kwargs...).u
3636
@test eltype(u) <: Complex
37-
@test_broken A2 * u b2
37+
@test A2 * u b2
3838
end
3939

4040

0 commit comments

Comments
 (0)