Commit 4c58ce2
SupernodalLU: fix block factorization on the direct-BLAS backends (#1119)
`snlu` on a Mac was a `MethodError` for any matrix with a supernode at or
above `dense_threshold`:
MethodError: no method matching _lu_from_cacheval(::AppleAccelerateLUCache{...})
`_lu_from_cacheval` pulled the block factorization out of the dense cache's
cacheval, handling `LU` and `Tuple`. The direct-BLAS backends store neither:
Apple Accelerate, BLIS, and OpenBLAS each keep a mutable `*LUCache` holding
the factored matrix, the getrf pivots, and `info`, which
`_custom_cache_factorization` wraps in an `LU` only on demand. On a Mac the
*default* dense solver resolves to Apple Accelerate, so the default path fell
straight into the hole.
`_cache_lu!` reads exactly `.factors`/`.ipiv`, with the same LAPACK
semantics those caches use, so the cacheval is handed back as-is rather than
allocating a throwaway `LU` per block; anything exposing neither field now
gets a real error message instead of a `MethodError`.
`test/Core/supernodal_lu.jl` missed this because it loads
RecursiveFactorization, which makes the default resolve to RFLU (a `Tuple`
cacheval) everywhere. The new testset names the platform's direct-BLAS
backends explicitly, over both a caching-heavy and a caching-sparse
`dense_threshold`, and covers refactorization through the same caches.
Also version-gates two assertions in test/qa/allocations.jl. Above
`PANEL_BLAS_CUTOFF` the sweeps hand off to LinearAlgebra's `ldiv!`/`mul!`,
whose wrappers are not statically allocation-free on every release: 1.10 and
1.13 leave a `generic_trimatdiv!` dynamic dispatch plus boxed
`MulAddMul`/`SubArray` values that AllocCheck reports from stdlib frames, and
1.11 allocates them for real on the `SubArray`-matrix path the multi-RHS
sweep takes. Runtime allocation is 0 on 1.10, 1.12, and 1.13, so each
assertion is pinned to the versions that can carry it rather than dropped.
Verified on macOS aarch64: qa/allocations.jl and Core/supernodal_lu.jl pass
on 1.10, 1.11, and 1.12; runtime zero-allocation confirmed on 1.13. The new
testset fails with the original `MethodError` without the numeric.jl change.
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent ae3cf08 commit 4c58ce2
3 files changed
Lines changed: 66 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
307 | 307 | | |
308 | 308 | | |
309 | 309 | | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
310 | 326 | | |
311 | 327 | | |
312 | 328 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
158 | 188 | | |
159 | 189 | | |
160 | 190 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
74 | 87 | | |
75 | 88 | | |
76 | 89 | | |
| |||
97 | 110 | | |
98 | 111 | | |
99 | 112 | | |
100 | | - | |
101 | | - | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
102 | 117 | | |
103 | 118 | | |
104 | 119 | | |
| |||
109 | 124 | | |
110 | 125 | | |
111 | 126 | | |
112 | | - | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
113 | 130 | | |
114 | 131 | | |
0 commit comments