Skip to content

Commit 9d60062

Browse files
committed
updates
1 parent 753a26a commit 9d60062

File tree

2 files changed

+27
-14
lines changed

2 files changed

+27
-14
lines changed

src/pardiso.jl

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,34 @@ Base.@kwdef struct PardisoJL <: SciMLLinearSolveAlgorithm
1515
dparm::Union{Vector{Tuple{Int,Int}}, Nothing} = nothing
1616
end
1717

18-
PardisoJLFactorize(;kwargs...) = PardisoJL(;solver_type=0, kwargs...)
19-
PardisoJLIterate(;kwargs...) = PardisoJL(;solver_type=1, kwargs...)
18+
PardisoJLFactorize(;kwargs...) = PardisoJL(;solver_type=0,
19+
solve_phase=Pardiso.NUM_FACT,
20+
kwargs...)
21+
PardisoJLIterate(;kwargs...) = PardisoJL(;solver_type=1,
22+
solve_phase=Pardiso.SOLVE_ITERATIVE_REFINE,
23+
kwargs...)
2024

2125
# TODO schur complement functionality
2226

2327
function init_cacheval(alg::PardisoJL, cache::LinearCache)
2428
@unpack nprocs, solver_type, matrix_type, iparm, dparm = alg
2529

26-
solver = Pardiso.PARDISO_LOADED[] ? Pardiso.PardisoSolver() : Pardiso.MKLPardisoSolver()
30+
solver =
31+
if Pardiso.PARDISO_LOADED[]
32+
Pardiso.PardisoSolver()
33+
solver_type !== nothing && Pardiso.set_solver!(solver, solver_type)
34+
else
35+
Pardiso.MKLPardisoSolver()
36+
nprocs !== nothing && Pardiso.set_nprocs!(solver, nprocs)
37+
end
2738

2839
Pardiso.pardisoinit(solver) # default initialization
2940

30-
nprocs !== nothing && Pardiso.set_nprocs!(ps, nprocs)
31-
solver_type !== nothing && Pardiso.set_solver!(solver, key)
41+
@show solver
3242
matrix_type !== nothing && Pardiso.set_matrixtype!(solver, matrix_type)
3343
cache.verbose && Pardiso.set_msglvl!(solver, Pardiso.MESSAGE_LEVEL_ON)
3444

35-
if iparm !== nothing # pass in vector of tuples like [(iparm, key)]
45+
if iparm !== nothing # pass in vector of tuples like [(iparm, key) ...]
3646
for i in length(iparm)
3747
Pardiso.set_iparm!(solver, iparm[i]...)
3848
end
@@ -44,6 +54,8 @@ function init_cacheval(alg::PardisoJL, cache::LinearCache)
4454
end
4555
end
4656

57+
Pardiso.set_phase!(cacheval, Pardiso.ANALYSIS)
58+
4759
return solver
4860
end
4961

@@ -62,13 +74,9 @@ function SciMLBase.solve(cache::LinearCache, alg::PardisoJL; kwargs...)
6274
reltol = cache.reltol
6375
kwargs = (abstol=abstol, reltol=reltol)
6476

65-
"""
66-
figure out whatever phase is. should set_phase call be in init_cacheval?
67-
can we use phase to store factorization in cache?
68-
"""
6977
alg.solve_phase !== nothing && Pardiso.set_phase!(cacheval, alg.solve_phase)
7078
Pardiso.pardiso(cache.cacheval, u, A, b)
71-
alg.release_phase !== nothing && Pardiso.set_phase!(cacheval, alg.release_phase) # is this necessary?
79+
alg.release_phase !== nothing && Pardiso.set_phase!(cacheval, alg.release_phase)
7280

7381
return cache.u
7482
end

test/runtests.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ end
127127
end
128128

129129
@testset "PardisoJL" begin
130-
#@test_broken alg = PardisoJL()
130+
@test_broken alg = PardisoJL()
131131

132132
using Pardiso, SparseArrays
133133
verbose = true
@@ -137,11 +137,16 @@ end
137137
-2 1 4 -7
138138
3 2 -7 5 ])
139139
b = rand(4)
140+
u = zero(b)
140141

141142
prob = LinearProblem(A, b)
142-
alg = PardisoJL()
143+
for alg in (PardisoJL(),
144+
PardisoJLFactorize(),
145+
PardisoJLIterate(), # not with MKLPardisoSolver
146+
)
143147

144-
u = solve(prob, alg; verbose=true)
148+
u = solve(prob, alg; verbose=true)
149+
end
145150

146151
end
147152

0 commit comments

Comments
 (0)