Skip to content

Commit 3d4d35c

Browse files
Complete BLIS triangular solve with native LAPACK calls
Replace Julia ldiv\! fallback with direct LAPACK getrs\! calls via BLIS for the triangular solve portion of BLISLUFactorization. This ensures the entire LU solve process uses native LAPACK routines through BLIS instead of falling back to libblastrampoline. Changes: - Use existing getrs\! functions that were already implemented but unused - Handle both square and overdetermined systems with proper dimension checks - Add proper error handling for failed factorizations with ReturnCode - Add missing ReturnCode import from SciMLBase - Maintain compatibility with existing LinearCache interface 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent c7a560b commit 3d4d35c

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

ext/LinearSolveBLISExt.jl

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ using LinearAlgebra: BlasInt, LU
1010
using LinearAlgebra.LAPACK: require_one_based_indexing, chkfinite, chkstride1,
1111
@blasfunc, chkargsok
1212
using LinearSolve: ArrayInterface, BLISLUFactorization, @get_cacheval, LinearCache, SciMLBase
13+
using SciMLBase: ReturnCode
1314

1415
const global libblis = blis_jll.blis
1516
const global liblapack = LAPACK_jll.liblapack
@@ -224,27 +225,27 @@ function SciMLBase.solve!(cache::LinearCache, alg::BLISLUFactorization;
224225
res = getrf!(A; ipiv = cacheval[1].ipiv, info = cacheval[2])
225226
fact = LU(res[1:3]...), res[4]
226227
cache.cacheval = fact
228+
229+
if !LinearAlgebra.issuccess(fact[1])
230+
return SciMLBase.build_linear_solution(
231+
alg, cache.u, nothing, cache; retcode = ReturnCode.Failure)
232+
end
227233
cache.isfresh = false
228234
end
229235

230-
y = ldiv!(cache.u, @get_cacheval(cache, :BLISLUFactorization)[1], cache.b)
231-
SciMLBase.build_linear_solution(alg, y, nothing, cache)
232-
233-
#=
234236
A, info = @get_cacheval(cache, :BLISLUFactorization)
235-
LinearAlgebra.require_one_based_indexing(cache.u, cache.b)
237+
require_one_based_indexing(cache.u, cache.b)
236238
m, n = size(A, 1), size(A, 2)
237239
if m > n
238240
Bc = copy(cache.b)
239241
getrs!('N', A.factors, A.ipiv, Bc; info)
240-
return copyto!(cache.u, 1, Bc, 1, n)
242+
copyto!(cache.u, 1, Bc, 1, n)
241243
else
242244
copyto!(cache.u, cache.b)
243245
getrs!('N', A.factors, A.ipiv, cache.u; info)
244246
end
245247

246-
SciMLBase.build_linear_solution(alg, cache.u, nothing, cache)
247-
=#
248+
SciMLBase.build_linear_solution(alg, cache.u, nothing, cache; retcode = ReturnCode.Success)
248249
end
249250

250251
end

0 commit comments

Comments
 (0)