Skip to content

Commit dcac88a

Browse files
committed
more boilerplate code
1 parent 5d3b79b commit dcac88a

File tree

2 files changed

+30
-37
lines changed

2 files changed

+30
-37
lines changed

src/LinearSolve.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function __init__()
4141
IS_OPENBLAS[] = occursin("openblas", BLAS.get_config().loaded_libs[1].libname)
4242
end
4343

44-
@require Pardiso="46dd5b70-b6fb-5a00-ae2d-e8fea33afaf2" PardisoJL, PardisoJL_Default
44+
@require Pardiso="46dd5b70-b6fb-5a00-ae2d-e8fea33afaf2" PardisoJL
4545
end
4646

4747
export LUFactorization, SVDFactorization, QRFactorization, GenericFactorization,

src/wrappers.jl

Lines changed: 29 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -300,50 +300,45 @@ end
300300

301301
## Paradiso
302302

303-
struct PardisoJL{F,A,K} <: SciMLLinearSolveAlgorithm
304-
which_paradiso::F
305-
matrix_type::Union{Int, Nothing}
303+
struct PardisoJL{A} <: SciMLLinearSolveAlgorithm
306304
nthreads::Union{Int, Nothing}
307-
solver_type::Union{Int, Nothing}
308-
solve_phase::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}
309308
release_phase::Union{Int, Nothing}
310-
ipram::Union{Int, Nothing}
311-
dpram::Union{Int, Nothing}
312-
args::A
313-
kwargs::K
309+
iparm::Union{A, Nothing}
310+
dparm::Union{A, Nothing}
314311
end
315312

316-
function PardisoJL(args...; which_pardiso=MKLPardisoSolver,
317-
kwargs...)
313+
function PardisoJL(solver_type=Pardiso.nothing,)
318314

319-
return PardisoJL(which_pardiso,
320-
args, kwargs)
315+
return PardisoJL(nthreads, solver_type, matrix_type, solve_phase,
316+
release_phase, setup_func)
321317
end
322318

323-
# some standard implementation - maybe SPD, or
324-
PardisoJL_Default(args...; kwargs...) = PardisoJL(args...;
325-
which_pardiso=:this_one,
326-
kwargs...)
327-
328319
function init_cacheval(alg::PardisoJL, cache::LinearCache)
329-
@unpack verbose, matrix_type
320+
@unpack nthreads, solver_type, matrix_type
330321

331-
solver = """ is alg.which_pardiso necessary? """
332-
if Pardiso.PARDISO_LOADED[]
333-
PardisoSolver()
334-
else
335-
MKLPardisoSolver()
336-
end
322+
solver = Pardiso.PARDISO_LOADED[] ? PardisoSolver() : MKLPardisoSolver()
337323

338-
verbose && Pardiso.set_msglvl!(solver, Pardiso.MESSAGE_LEVEL_ON)
339-
matrix_type !== nothing && Pardiso.set_matrixtype!(solver, matrix_type)
340-
nthreads !== nothing && set_nprocs!(ps, nthreads)
341-
# set_iparm!(solver, 5, 13.37)
342-
# set_dparm!(solver, 5, 13.37)
343-
# set_solver!(solver, key)
324+
Pardiso.pardisoinit(solver) # default initialization
344325

345-
# inject user code for additional setup stuff
346-
# solver_setup!(solver)
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
347342

348343
return solver
349344
end
@@ -358,10 +353,8 @@ function SciMLBase.solve(cache::LinearCache, alg::PardisoJL; kwargs...)
358353

359354
abstol = cache.abstol
360355
reltol = cache.reltol
361-
verbose = cache.verbose
362356

363-
kwargs = (abstol=abstol, reltol=reltol,
364-
alg.kwargs...)
357+
kwargs = (abstol=abstol, reltol=reltol, alg.kwargs...)
365358

366359
Pardiso.set_phase!(ps, alg.phase)
367360

0 commit comments

Comments
 (0)