Skip to content

Commit

Permalink
Move ordering in CudssSolverOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
amontoison committed Apr 5, 2024
1 parent f05e338 commit 93dd1a4
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/MadNLPGPU/src/cudss.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import SparseArrays
@kwdef mutable struct CudssSolverOptions <: MadNLP.AbstractOptions
# Use LDLᵀ by default in CUDSS as Cholesky can lead to undefined behavior.
cudss_algorithm::MadNLP.LinearFactorization = MadNLP.LDL
ordering::Symbol = :default
end

mutable struct CUDSSSolver{T} <: MadNLP.AbstractLinearSolver{T}
Expand All @@ -20,7 +21,6 @@ function CUDSSSolver(
csc::CUSPARSE.CuSparseMatrixCSC{T};
opt=CudssSolverOptions(),
logger=MadNLP.MadNLPLogger(),
ordering::Symbol=:default
) where T
n, m = size(csc)
@assert n == m
Expand All @@ -45,18 +45,18 @@ function CUDSSSolver(
data = CUDSS.CudssData()
solver = CUDSS.CudssSolver(matrix, config, data)

if ordering != :default
if ordering == :metis
if opt.ordering != :default
if opt.ordering == :metis
A = SparseMatrixCSC(csc)
G = Metis.graph(A, check_hermitian=false)
perm, iperm = Metis.permutation(G)
cudss_set(solver, "user_perm", perm)
elseif ordering == :amd
elseif opt.ordering == :amd
A = SparseMatrixCSC(csc)
perm = AMD.amd(A)
cudss_set(solver, "user_perm", perm)
else
error("The ordering $ordering is not supported.")
error("The ordering $(opt.ordering) is not supported.")
end
end

Expand Down

0 comments on commit 93dd1a4

Please sign in to comment.