1
1
using LoopVectorization
2
2
using LinearAlgebra: BlasInt, BlasFloat, LU, UnitLowerTriangular, ldiv!, checknonsingular, BLAS, LinearAlgebra
3
3
4
- function lu (A:: AbstractMatrix , pivot:: Union{Val{false}, Val{true}} = Val (true ); kwargs... )
5
- return lu! (copy (A), pivot; kwargs... )
4
+ # 1.7 compat
5
+ normalize_pivot (t:: Val{T} ) where T = t
6
+ to_stdlib_pivot (t) = t
7
+ if VERSION >= v " 1.7.0-DEV.1188"
8
+ normalize_pivot (:: LinearAlgebra.RowMaximum ) = Val (true )
9
+ normalize_pivot (:: LinearAlgebra.NoPivot ) = Val (false )
10
+ to_stdlib_pivot (:: Val{true} ) = LinearAlgebra. RowMaximum ()
11
+ to_stdlib_pivot (:: Val{false} ) = LinearAlgebra. NoPivot ()
6
12
end
7
13
8
- function lu! (A, pivot:: Union{Val{false}, Val{true}} = Val (true ); check= true , kwargs... )
14
+ function lu (A:: AbstractMatrix , pivot = Val (true ); kwargs... )
15
+ return lu! (copy (A), normalize_pivot (pivot); kwargs... )
16
+ end
17
+
18
+ function lu! (A, pivot = Val (true ); check= true , kwargs... )
9
19
m, n = size (A)
10
20
minmn = min (m, n)
11
21
F = if minmn < 10 # avx introduces small performance degradation
12
- LinearAlgebra. generic_lufact! (A, pivot; check= check)
22
+ LinearAlgebra. generic_lufact! (A, to_stdlib_pivot ( pivot) ; check= check)
13
23
else
14
- lu! (A, Vector {BlasInt} (undef, minmn), pivot; check= check, kwargs... )
24
+ lu! (A, Vector {BlasInt} (undef, minmn), normalize_pivot ( pivot) ; check= check, kwargs... )
15
25
end
16
26
return F
17
27
end
@@ -20,21 +30,28 @@ const RECURSION_THRESHOLD = Ref(-1)
20
30
21
31
# AVX512 needs a smaller recursion limit
22
32
function pick_threshold ()
23
- blasvendor = BLAS. vendor ()
24
33
RECURSION_THRESHOLD[] >= 0 && return RECURSION_THRESHOLD[]
34
+ blasvendor = @static if VERSION >= v " 1.7.0-DEV.610"
35
+ :openblas64
36
+ else
37
+ BLAS. vendor ()
38
+ end
25
39
if blasvendor === :openblas || blasvendor === :openblas64
26
40
LoopVectorization. register_size () == 64 ? 110 : 72
27
41
else
28
42
LoopVectorization. register_size () == 64 ? 48 : 72
29
43
end
30
44
end
31
45
32
- function lu! (A:: AbstractMatrix{T} , ipiv:: AbstractVector{<:Integer} ,
33
- pivot:: Union{Val{false}, Val{true}} = Val (true );
34
- check:: Bool = true ,
35
- # the performance is not sensitive wrt blocksize, and 16 is a good default
36
- blocksize:: Integer = 16 ,
37
- threshold:: Integer = pick_threshold ()) where T
46
+ function lu! (
47
+ A:: AbstractMatrix{T} , ipiv:: AbstractVector{<:Integer} ,
48
+ pivot = Val (true );
49
+ check:: Bool = true ,
50
+ # the performance is not sensitive wrt blocksize, and 16 is a good default
51
+ blocksize:: Integer = 16 ,
52
+ threshold:: Integer = pick_threshold ()
53
+ ) where T
54
+ pivot = normalize_pivot (pivot)
38
55
info = zero (BlasInt)
39
56
m, n = size (A)
40
57
mnmin = min (m, n)
@@ -187,7 +204,7 @@ function _generic_lufact!(A, ::Val{Pivot}, ipiv, info) where Pivot
187
204
elseif info == 0
188
205
info = k
189
206
end
190
- k == minmn && break
207
+ k == minmn && break
191
208
# Update the rest
192
209
@avx for j = k+ 1 : n
193
210
for i = k+ 1 : m
0 commit comments