@@ -263,9 +263,11 @@ has_refinement(F::UmfpackLU) = has_refinement(F.control)
263
263
has_refinement (control:: AbstractVector ) = control[JL_UMFPACK_IRSTEP] > 0
264
264
265
265
# auto magick resize, should this only expand and not shrink?
266
- getworkspace (F:: UmfpackLU ) = @lock F. lock begin
267
- return resize! (F. workspace, F, has_refinement (F); expand_only= true )
266
+ function getworkspace (F:: UmfpackLU )
267
+ @lock F. lock begin
268
+ return resize! (F. workspace, F, has_refinement (F); expand_only = true )
268
269
end
270
+ end
269
271
270
272
UmfpackWS (F:: UmfpackLU{Tv, Ti} , refinement:: Bool = has_refinement (F)) where {Tv, Ti} = UmfpackWS (
271
273
Vector {Ti} (undef, size (F, 2 )),
@@ -297,29 +299,12 @@ Base.copy(F::T, ws=UmfpackWS(F)) where {T <: ATLU} =
297
299
298
300
Base. transpose (F:: UmfpackLU ) = TransposeFactorization (F)
299
301
300
- function Base. lock (f:: Function , F:: UmfpackLU )
301
- lock (F)
302
- try
303
- f ()
304
- finally
305
- unlock (F)
306
- end
307
- end
308
- Base. lock (F:: UmfpackLU ) = if ! trylock (F. lock)
309
- @info """ waiting for UmfpackLU's lock, it's safe to ignore this message.
310
- see the documentation for Umfpack""" maxlog = 1
311
- lock (F. lock)
312
- end
313
-
314
- @inline Base. trylock (F:: UmfpackLU ) = trylock (F. lock)
315
- @inline Base. unlock (F:: UmfpackLU ) = unlock (F. lock)
316
-
317
302
show_umf_ctrl (F:: UmfpackLU , level:: Real = 2.0 ) =
318
- @lock F show_umf_ctrl (F. control, level)
303
+ @lock F. lock show_umf_ctrl (F. control, level)
319
304
320
305
321
306
show_umf_info (F:: UmfpackLU , level:: Real = 2.0 ) =
322
- @lock F show_umf_info (F. control, F. info, level)
307
+ @lock F. lock show_umf_info (F. control, F. info, level)
323
308
324
309
325
310
"""
@@ -598,7 +583,7 @@ for itype in UmfpackIndexTypes
598
583
@eval begin
599
584
function umfpack_symbolic! (U:: UmfpackLU{Float64,$itype} , q:: Union{Nothing, StridedVector{$itype}} )
600
585
_isnotnull (U. symbolic) && return U
601
- @lock U begin
586
+ @lock U. lock begin
602
587
tmp = Ref {Ptr{Cvoid}} (C_NULL )
603
588
if q === nothing
604
589
@isok $ sym_r (U. m, U. n, U. colptr, U. rowval, U. nzval, tmp, U. control, U. info)
@@ -613,7 +598,7 @@ for itype in UmfpackIndexTypes
613
598
end
614
599
function umfpack_symbolic! (U:: UmfpackLU{ComplexF64,$itype} , q:: Union{Nothing, StridedVector{$itype}} )
615
600
_isnotnull (U. symbolic) && return U
616
- @lock U begin
601
+ @lock U. lock begin
617
602
tmp = Ref {Ptr{Cvoid}} (C_NULL )
618
603
if q === nothing
619
604
@isok $ sym_c (U. m, U. n, U. colptr, U. rowval, real (U. nzval), imag (U. nzval), tmp,
@@ -627,7 +612,7 @@ for itype in UmfpackIndexTypes
627
612
return U
628
613
end
629
614
function umfpack_numeric! (U:: UmfpackLU{Float64,$itype} ; reuse_numeric= true , q= nothing )
630
- @lock U begin
615
+ @lock U. lock begin
631
616
(reuse_numeric && _isnotnull (U. numeric)) && return U
632
617
if _isnull (U. symbolic)
633
618
umfpack_symbolic! (U, q)
@@ -643,7 +628,7 @@ for itype in UmfpackIndexTypes
643
628
return U
644
629
end
645
630
function umfpack_numeric! (U:: UmfpackLU{ComplexF64,$itype} ; reuse_numeric= true , q= nothing )
646
- @lock U begin
631
+ @lock U. lock begin
647
632
(reuse_numeric && _isnotnull (U. numeric)) && return U
648
633
_isnull (U. symbolic) && umfpack_symbolic! (U, q)
649
634
tmp = Ref {Ptr{Cvoid}} (C_NULL )
@@ -672,7 +657,7 @@ for itype in UmfpackIndexTypes
672
657
if workspace_W_size (lu) > length (workspace. W)
673
658
throw (ArgumentError (" W should be larger than `workspace_W_size(Af)`" ))
674
659
end
675
- @lock lu begin
660
+ @lock lu. lock begin
676
661
umfpack_numeric! (lu)
677
662
(size (b, 1 ) == lu. m) && (size (b) == size (x)) || throw (DimensionMismatch ())
678
663
@@ -697,7 +682,7 @@ for itype in UmfpackIndexTypes
697
682
if workspace_W_size (lu) > length (workspace. W)
698
683
throw (ArgumentError (" W should be larger than `workspace_W_size(Af)`" ))
699
684
end
700
- @lock lu begin
685
+ @lock lu. lock begin
701
686
umfpack_numeric! (lu)
702
687
(size (b, 1 ) == lu. m) && (size (b) == size (x)) || throw (DimensionMismatch ())
703
688
@isok $ wsol_c (typ, lu. colptr, lu. rowval, lu. nzval, C_NULL , x, C_NULL , b,
@@ -707,14 +692,14 @@ for itype in UmfpackIndexTypes
707
692
end
708
693
function det (lu:: UmfpackLU{Float64,$itype} )
709
694
mx = Ref {Float64} (zero (Float64))
710
- @lock lu @isok ($ det_r (mx, C_NULL , lu. numeric, lu. info))
695
+ @lock lu. lock @isok ($ det_r (mx, C_NULL , lu. numeric, lu. info))
711
696
mx[]
712
697
end
713
698
714
699
function det (lu:: UmfpackLU{ComplexF64,$itype} )
715
700
mx = Ref {Float64} (zero (Float64))
716
701
mz = Ref {Float64} (zero (Float64))
717
- @lock lu @isok ($ det_z (mx, mz, C_NULL , lu. numeric, lu. info))
702
+ @lock lu. lock @isok ($ det_z (mx, mz, C_NULL , lu. numeric, lu. info))
718
703
complex (mx[], mz[])
719
704
end
720
705
function logabsdet (F:: UmfpackLU{T, $itype} ) where {T<: Union{Float64,ComplexF64} } # return log(abs(det)) and sign(det)
@@ -1030,7 +1015,7 @@ for Tv in (:Float64, :ComplexF64), Ti in UmfpackIndexTypes
1030
1015
1031
1016
_report_symbolic = Symbol (umf_nm (" report_symbolic" , Tv, Ti))
1032
1017
@eval umfpack_report_symbolic (lu:: UmfpackLU{$Tv,$Ti} , level:: Real = 4 ; q= nothing ) =
1033
- @lock lu begin
1018
+ @lock lu. lock begin
1034
1019
umfpack_symbolic! (lu, q)
1035
1020
old_prl = lu. control[JL_UMFPACK_PRL]
1036
1021
lu. control[JL_UMFPACK_PRL] = level
@@ -1040,7 +1025,7 @@ for Tv in (:Float64, :ComplexF64), Ti in UmfpackIndexTypes
1040
1025
end
1041
1026
_report_numeric = Symbol (umf_nm (" report_numeric" , Tv, Ti))
1042
1027
@eval umfpack_report_numeric (lu:: UmfpackLU{$Tv,$Ti} , level:: Real = 4 ; q= nothing ) =
1043
- @lock lu begin
1028
+ @lock lu. lock begin
1044
1029
umfpack_numeric! (lu; q)
1045
1030
old_prl = lu. control[JL_UMFPACK_PRL]
1046
1031
lu. control[JL_UMFPACK_PRL] = level
0 commit comments