Skip to content

Commit d3b4284

Browse files
committed
moving things around
1 parent 04109ed commit d3b4284

File tree

4 files changed

+73
-71
lines changed

4 files changed

+73
-71
lines changed

Project.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ IterativeSolvers = "42fd0dbc-a981-5370-80f2-aaf504508153"
99
Krylov = "ba0b0d4f-ebba-5204-a429-3ac8c609bfb7"
1010
KrylovKit = "0b1a1467-8014-51b9-945f-bf0ae24f4b77"
1111
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
12-
Pardiso = "46dd5b70-b6fb-5a00-ae2d-e8fea33afaf2"
1312
RecursiveFactorization = "f2c3362d-daeb-58d1-803e-2bc74f2840b4"
1413
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
1514
Requires = "ae029012-a4dd-5104-9daa-d747884805df"

src/LinearSolve.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ using Requires
1616
import Krylov
1717
import KrylovKit # TODO
1818
import IterativeSolvers
19-
import Pardiso
2019

2120
using Reexport
2221
@reexport using SciMLBase
@@ -48,8 +47,7 @@ export LUFactorization, SVDFactorization, QRFactorization, GenericFactorization,
4847
RFLUFactorizaation
4948
export KrylovJL, KrylovJL_CG, KrylovJL_GMRES, KrylovJL_BICGSTAB, KrylovJL_MINRES,
5049
IterativeSolversJL, IterativeSolversJL_CG, IterativeSolversJL_GMRES,
51-
IterativeSolversJL_BICGSTAB, IterativeSolversJL_MINRES,
52-
PardisoJL
50+
IterativeSolversJL_BICGSTAB, IterativeSolversJL_MINRES
5351
export DefaultLinSolve
5452

5553
end

src/pardiso.jl

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
2+
## Paradiso
3+
4+
import Pardiso
5+
6+
export PardisoJL
7+
8+
struct PardisoJL{A} <: SciMLLinearSolveAlgorithm
9+
nthreads::Union{Int, Nothing}
10+
solver_type::Union{Int, Pardiso.Solver, Nothing}
11+
matrix_type::Union{Int, Pardiso.MatrixType, Nothing}
12+
solve_phase::Union{Int, Pardiso.Phase, Nothing}
13+
release_phase::Union{Int, Nothing}
14+
iparm::Union{A, Nothing}
15+
dparm::Union{A, Nothing}
16+
end
17+
18+
function PardisoJL(solver_type=Pardiso.nothing,)
19+
20+
return PardisoJL(nthreads, solver_type, matrix_type, solve_phase,
21+
release_phase, iparm, dparm)
22+
end
23+
24+
function init_cacheval(alg::PardisoJL, cache::LinearCache)
25+
@unpack nthreads, solver_type, matrix_type, iparm, dparm = alg
26+
27+
solver = Pardiso.PARDISO_LOADED[] ? PardisoSolver() : MKLPardisoSolver()
28+
29+
Pardiso.pardisoinit(solver) # default initialization
30+
31+
nthreads !== nothing && Pardiso.set_nprocs!(ps, nthreads)
32+
solver_type !== nothing && Pardiso.set_solver!(solver, key)
33+
matrix_type !== nothing && Pardiso.set_matrixtype!(solver, matrix_type)
34+
cache.verbose && Pardiso.set_msglvl!(solver, Pardiso.MESSAGE_LEVEL_ON)
35+
36+
iparm !== nothing && begin # pass in vector of tuples like [(iparm, key)]
37+
for i in length(iparm)
38+
Pardiso.set_iparm!(solver, iparm[i]...)
39+
end
40+
end
41+
42+
dparm !== nothing && begin
43+
for i in length(dparm)
44+
Pardiso.set_dparm!(solver, dparm[i]...)
45+
end
46+
end
47+
48+
return solver
49+
end
50+
51+
function SciMLBase.solve(cache::LinearCache, alg::PardisoJL; kwargs...)
52+
@unpack A, b, u, cacheval = cache
53+
54+
if cache.isfresh
55+
solver = init_cacheval(alg, cache)
56+
cache = set_cacheval(cache, solver)
57+
end
58+
59+
abstol = cache.abstol
60+
reltol = cache.reltol
61+
kwargs = (abstol=abstol, reltol=reltol, alg.kwargs...)
62+
63+
"""
64+
figure out whatever phase is. should set_phase call be in init_cacheval?
65+
can we use phase to store factorization in cache?
66+
"""
67+
Pardiso.set_phase!(cacheval, alg.solve_phase)
68+
Pardiso.solve!(cacheval, u, A, b)
69+
Pardiso.set_phase!(cacheval, alg.release_phase) # is this necessary?
70+
71+
return cache.u
72+
end

src/wrappers.jl

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -298,70 +298,3 @@ function SciMLBase.solve(cache::LinearCache, alg::IterativeSolversJL; kwargs...)
298298
return cache.u
299299
end
300300

301-
## Paradiso
302-
303-
struct PardisoJL{A} <: SciMLLinearSolveAlgorithm
304-
nthreads::Union{Int, Nothing}
305-
solver_type::Union{Int, Pardiso.Solver, Nothing}
306-
matrix_type::Union{Int, Pardiso.MatrixType, Nothing}
307-
solve_phase::Union{Int, Pardiso.Phase, Nothing}
308-
release_phase::Union{Int, Nothing}
309-
iparm::Union{A, Nothing}
310-
dparm::Union{A, Nothing}
311-
end
312-
313-
function PardisoJL(solver_type=Pardiso.nothing,)
314-
315-
return PardisoJL(nthreads, solver_type, matrix_type, solve_phase,
316-
release_phase, iparm, dparm)
317-
end
318-
319-
function init_cacheval(alg::PardisoJL, cache::LinearCache)
320-
@unpack nthreads, solver_type, matrix_type, iparm, dparm = alg
321-
322-
solver = Pardiso.PARDISO_LOADED[] ? PardisoSolver() : MKLPardisoSolver()
323-
324-
Pardiso.pardisoinit(solver) # default initialization
325-
326-
nthreads !== nothing && Pardiso.set_nprocs!(ps, nthreads)
327-
solver_type !== nothing && Pardiso.set_solver!(solver, key)
328-
matrix_type !== nothing && Pardiso.set_matrixtype!(solver, matrix_type)
329-
cache.verbose && Pardiso.set_msglvl!(solver, Pardiso.MESSAGE_LEVEL_ON)
330-
331-
iparm !== nothing && begin # pass in vector of tuples like [(iparm, key)]
332-
for i in length(iparm)
333-
Pardiso.set_iparm!(solver, iparm[i]...)
334-
end
335-
end
336-
337-
dparm !== nothing && begin
338-
for i in length(dparm)
339-
Pardiso.set_dparm!(solver, dparm[i]...)
340-
end
341-
end
342-
343-
return solver
344-
end
345-
346-
function SciMLBase.solve(cache::LinearCache, alg::PardisoJL; kwargs...)
347-
@unpack A, b, u, cacheval = cache
348-
349-
if cache.isfresh
350-
solver = init_cacheval(alg, cache)
351-
cache = set_cacheval(cache, solver)
352-
end
353-
354-
abstol = cache.abstol
355-
reltol = cache.reltol
356-
kwargs = (abstol=abstol, reltol=reltol, alg.kwargs...)
357-
358-
"""
359-
figure out whatever phase is. should set_phase call be in init_cacheval?
360-
can we use phase to store factorization in cache?
361-
"""
362-
Pardiso.set_phase!(cacheval, alg.solve_phase)
363-
Pardiso.solve!(cacheval, u, A, b)
364-
Pardiso.set_phase!(cacheval, alg.release_phase) # is this necessary?
365-
366-
return cache.u
367-
end

0 commit comments

Comments
 (0)