Skip to content

Commit 23c837a

Browse files
MaxenceGollieramontoison
authored andcommitted
add unit tests for qrm_get allocs and minimize changes in wrapper
1 parent 462c60a commit 23c837a

File tree

3 files changed

+35
-10
lines changed

3 files changed

+35
-10
lines changed

src/wrapper/qr_mumps_api.jl

+5-4
Original file line numberDiff line numberDiff line change
@@ -861,15 +861,16 @@ for (finame, frname, elty) in ((:sqrm_spfct_get_i8_c, :sqrm_spfct_get_r4_c, :Flo
861861
@eval begin
862862
function qrm_get(spfct :: qrm_spfct{$elty}, str :: String)
863863
if (str PICNTL) || (str STATS)
864-
err = $finame(spfct, str, spfct.get_val_long)
864+
val = spfct.ref_int
865+
err = $finame(spfct, str, val)
865866
elseif str RCNTL
866-
err = $frname(spfct, str, spfct.get_val_float)
867+
val = spfct.ref_float
868+
err = $frname(spfct, str, val)
867869
else
868870
err = Int32(23)
869871
end
870872
qrm_check(err)
871-
(str RCNTL) && return spfct.get_val_float[]
872-
return spfct.get_val_long[]
873+
return val[]
873874
end
874875
end
875876
end

src/wrapper/qr_mumps_common.jl

+6-6
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@ the factorization, namely, the factors with all the symbolic information needed
7575
solve phase.
7676
"""
7777
mutable struct qrm_spfct{T} <: Factorization{T}
78-
cperm_in :: Vector{Cint}
79-
ptr_rp :: Ref{Ptr{Cint}}
80-
ptr_cp :: Ref{Ptr{Cint}}
81-
get_val_long :: Ref{Clonglong}
82-
get_val_float :: Ref{Float32}
83-
fct :: c_spfct{T}
78+
cperm_in :: Vector{Cint}
79+
ptr_rp :: Ref{Ptr{Cint}}
80+
ptr_cp :: Ref{Ptr{Cint}}
81+
ref_int :: Ref{Clonglong}
82+
ref_float:: Ref{Float32}
83+
fct :: c_spfct{T}
8484

8585
function qrm_spfct{T}() where T
8686
spfct = new(Cint[], Ref{Ptr{Cint}}(), Ref{Ptr{Cint}}(), Ref{Clonglong}(0), Ref{Float32}(0), c_spfct{T}())

test/test_qrm.jl

+24
Original file line numberDiff line numberDiff line change
@@ -546,3 +546,27 @@ end
546546
@test norm(b - A'*(A*x)) norm(b - A'*(A*x_refined))
547547
end
548548
end
549+
550+
@testset "allocations" begin
551+
for T in (Float32, Float64, ComplexF32, ComplexF64)
552+
tol = (real(T) == Float32) ? 1e-3 : 1e-12
553+
transp = (T <: Real) ? 't' : 'c'
554+
555+
for I in (Int32 , Int64)
556+
A = sprand(T, m, n, 0.3)
557+
A = convert(SparseMatrixCSC{T,I}, A)
558+
559+
spmat = qrm_spmat_init(T)
560+
qrm_spmat_init!(spmat, A)
561+
562+
spfct = qrm_spfct_init(spmat)
563+
564+
qrm_set(spfct, "qrm_rd_eps", tol)
565+
qrm_analyse!(spmat, spfct)
566+
qrm_factorize!(spmat, spfct)
567+
@test (@allocated qrm_get(spfct, "qrm_rd_num")) == 0
568+
569+
end
570+
end
571+
572+
end

0 commit comments

Comments
 (0)