@@ -24,14 +24,18 @@ struct CondensedFFTKKT{T, VT, FFT, R, C} <: AbstractMatrix{T}
2424 buffer_complex1:: C # Buffer for fft and ifft
2525 buffer_complex2:: C # Buffer for fft and ifft
2626 rdft:: Bool
27+ fft_timer:: Ref{Float64}
28+ mapping_timer:: Ref{Float64}
2729end
2830
2931function CondensedFFTKKT {T, VT} (nlp:: FFTNLPModel{T, VT} ) where {T, VT}
3032 nβ = nlp. N
3133 buf1 = VT (undef, nβ)
3234 Λ1 = VT (undef, nβ)
3335 Λ2 = VT (undef, nβ)
34- return CondensedFFTKKT {T, VT, typeof(nlp.op), typeof(nlp.buffer_real), typeof(nlp.buffer_complex1)} (nβ, nlp. parameters, buf1, Λ1, Λ2, nlp. op, nlp. buffer_real, nlp. buffer_complex1, nlp. buffer_complex2, nlp. rdft)
36+ return CondensedFFTKKT {T, VT, typeof(nlp.op), typeof(nlp.buffer_real), typeof(nlp.buffer_complex1)} (
37+ nβ, nlp. parameters, buf1, Λ1, Λ2, nlp. op, nlp. buffer_real,
38+ nlp. buffer_complex1, nlp. buffer_complex2, nlp. rdft, nlp. fft_timer, nlp. mapping_timer)
3539end
3640
3741Base. size (K:: CondensedFFTKKT ) = (2 * K. nβ, 2 * K. nβ)
@@ -54,7 +58,7 @@ function LinearAlgebra.mul!(y::AbstractVector, K::CondensedFFTKKT, x::AbstractVe
5458 xz = view (x, nβ+ 1 : 2 * nβ)
5559
5660 # Evaluate Mᵀ M xβ
57- Mβ .= M_perpt_M_perp_vec (K. buffer_real, K. buffer_complex1, K. buffer_complex2, K. op, DFTdim, DFTsize, xβ, index_missing; K. rdft)
61+ Mβ .= M_perpt_M_perp_vec (K. buffer_real, K. buffer_complex1, K. buffer_complex2, K. op, DFTdim, DFTsize, xβ, index_missing, K . fft_timer, K . mapping_timer ; K. rdft)
5862
5963 yβ .= beta .* yβ .+ alpha .* (Mβ .+ K. Λ1 .* xβ .+ K. Λ2 .* xz)
6064 yz .= beta .* yz .+ alpha .* (K. Λ2 .* xβ .+ K. Λ1 .* xz)
@@ -124,6 +128,8 @@ struct FFTKKTSystem{T, VI, VT, MT, LS} <: MadNLP.AbstractReducedKKTSystem{T, VT,
124128 z1:: VT # dimension nβ
125129 z2:: VT # dimension 2 * nβ
126130 linear_solver:: LS
131+ krylov_iterations:: Vector{Int}
132+ krylov_timer:: Vector{Float64}
127133end
128134
129135function MadNLP. create_kkt_system (
@@ -167,7 +173,7 @@ function MadNLP.create_kkt_system(
167173 reg, pr_diag, du_diag, l_diag, u_diag, l_lower, u_lower,
168174 ind_cons. ind_lb, ind_cons. ind_ub,
169175 z1, z2,
170- linear_solver,
176+ linear_solver, Int[], Float64[],
171177 )
172178end
173179
@@ -259,7 +265,7 @@ function MadNLP.mul!(y::VT, kkt::FFTKKTSystem, x::VT, alpha::Number, beta::Numbe
259265 xy2 = view (_x, 5 * nβ+ 1 : 6 * nβ)
260266
261267 # Evaluate (MᵀM) * xβ
262- Mβ .= M_perpt_M_perp_vec (kkt. K. buffer_real, kkt. K. buffer_complex1, kkt. K. buffer_complex2, kkt. K. op, DFTdim, DFTsize, xβ, index_missing; kkt. K. rdft)
268+ Mβ .= M_perpt_M_perp_vec (kkt. K. buffer_real, kkt. K. buffer_complex1, kkt. K. buffer_complex2, kkt. K. op, DFTdim, DFTsize, xβ, index_missing, kkt . K . fft_timer, kkt . K . mapping_timer ; kkt. K. rdft)
263269 yβ .= beta .* yβ .+ alpha .* (Mβ .- xy1 .+ xy2)
264270 yz .= beta .* yz .- alpha .* (xy1 .+ xy2)
265271 ys1 .= beta .* ys1 .- alpha .* xy1
@@ -358,6 +364,8 @@ function MadNLP.solve!(kkt::FFTKKTSystem, w::MadNLP.AbstractKKTVector)
358364 # Solve with CG
359365 Krylov. solve! (kkt. linear_solver, kkt. K, b, M= kkt. P, atol= 1e-12 , rtol= 0.0 , verbose= 0 )
360366 x = Krylov. solution (kkt. linear_solver)
367+ push! (kkt. krylov_iterations, kkt. linear_solver |> niterations)
368+ push! (kkt. krylov_timer, kkt. linear_solver. stats. timer)
361369
362370 # Unpack solution
363371 w1 .= x[1 : nβ] # / x
0 commit comments