Skip to content

Commit 5d75154

Browse files
authored
Bypass the reordering phase in cuDSS when we provide a custom permutation (#448)
1 parent 041ac2e commit 5d75154

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

lib/MadNLPGPU/src/LinearSolvers/cudss.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,12 @@ function CUDSSSolver(
108108
elseif opt.cudss_ordering == AMD_ORDERING
109109
A = SparseMatrixCSC(csc)
110110
opt.cudss_perm = AMD.amd(A)
111+
elseif opt.cudss_ordering == SYMAMD_ORDERING
112+
A = SparseMatrixCSC(csc)
113+
opt.cudss_perm = AMD.symamd(A)
114+
elseif opt.cudss_ordering == COLAMD_ORDERING
115+
A = SparseMatrixCSC(csc)
116+
opt.cudss_perm = AMD.colamd(A)
111117
elseif opt.cudss_ordering == USER_ORDERING
112118
(!isempty(opt.cudss_perm) && isperm(opt.cudss_perm)) || error("The vector opt.cudss_perm is not a valid permutation.")
113119
else
@@ -116,9 +122,9 @@ function CUDSSSolver(
116122
CUDSS.cudss_set(solver, "user_perm", opt.cudss_perm)
117123
end
118124

125+
# The phase "analysis" is "reordering" combined with "symbolic_factorization"
119126
x_gpu = CUDA.zeros(T, n)
120127
b_gpu = CUDA.zeros(T, n)
121-
122128
CUDSS.cudss("analysis", solver, x_gpu, b_gpu)
123129

124130
return CUDSSSolver(

lib/MadNLPGPU/src/utils.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
METIS_ORDERING = 1
44
AMD_ORDERING = 2
55
USER_ORDERING = 3
6+
SYMAMD_ORDERING = 4
7+
COLAMD_ORDERING = 5
68
end
79

810
function MadNLP._madnlp_unsafe_wrap(vec::VT, n, shift=1) where {T, VT <: CuVector{T}}

lib/MadNLPGPU/test/madnlpgpu_test.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,24 @@ testset = [
1717
),
1818
[],
1919
],
20+
[
21+
"CUDSS-SYMAMD",
22+
()->MadNLP.Optimizer(
23+
linear_solver=MadNLPGPU.CUDSSSolver,
24+
print_level=MadNLP.ERROR,
25+
ordering=MadNLPGPU.SYMAMD_ORDERING,
26+
),
27+
[],
28+
],
29+
[
30+
"CUDSS-COLAMD",
31+
()->MadNLP.Optimizer(
32+
linear_solver=MadNLPGPU.CUDSSSolver,
33+
print_level=MadNLP.ERROR,
34+
ordering=MadNLPGPU.COLAMD_ORDERING,
35+
),
36+
[],
37+
],
2038
[
2139
"CUDSS-METIS",
2240
()->MadNLP.Optimizer(

0 commit comments

Comments
 (0)