From daa92b2984d5f42c8ab2a54396c31b43f4e22491 Mon Sep 17 00:00:00 2001 From: ChrisRackauckas-Claude Date: Sun, 9 Aug 2026 03:57:54 -0400 Subject: [PATCH] Restore and modernize the precompile workload The `@setup_workload` block at the bottom of the module has been inside a `#= ... =#` since before 0.2.0, and PrecompileTools was not in [deps], so no kernel precompiled at all. The block also could not be uncommented as-is: it calls `__init__()`, which this module does not define. The restored workload covers all four wrapper families (both `rdiv!` and `ldiv!` respecialize per family because `ldiv!` transposes its arguments), unit and non-unit diagonals, the `Val(true)`/`Val(false)` thread variants, both `Float32` and `Float64`, and the vector right-hand-side kernels added in 0.2.5. Co-Authored-By: Chris Rackauckas --- Project.toml | 4 ++- src/TriangularSolve.jl | 55 ++++++++++++++++++++++++++++-------------- 2 files changed, 40 insertions(+), 19 deletions(-) diff --git a/Project.toml b/Project.toml index fa9ea50..790db0b 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "TriangularSolve" uuid = "d5829a12-d9aa-46ab-831f-fb7c9ab06edf" authors = ["chriselrod and contributors"] -version = "0.2.5" +version = "0.2.6" [deps] CloseOpenIntervals = "fb6a15b2-703c-40df-9091-08a04967cfa9" @@ -10,6 +10,7 @@ LayoutPointers = "10f19ff3-798f-405d-979b-55457f8fc047" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" LoopVectorization = "bdcacae8-1622-11e9-2a5c-532679323890" Polyester = "f517fe37-dbe3-4b94-8317-1923a5111588" +PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a" Static = "aedffcd0-7271-4cad-89d0-dc628f76c6d3" VectorizationBase = "3d5dd08c-fd9d-11e8-17fa-ed2836048c2f" @@ -22,6 +23,7 @@ LayoutPointers = "0.1.2" LinearAlgebra = "1" LoopVectorization = "0.12.30" Polyester = "0.4, 0.5, 0.6, 0.7" +PrecompileTools = "1" Static = "0.2, 0.3, 0.4, 0.6, 0.7, 0.8, 1" Test = "1" VectorizationBase = "0.21" diff --git a/src/TriangularSolve.jl b/src/TriangularSolve.jl index fe13992..8c0a8ac 100644 --- a/src/TriangularSolve.jl +++ b/src/TriangularSolve.jl @@ -2391,26 +2391,45 @@ function _ldiv_U!( nothing end -#= -using PrecompileTools -@static if VERSION >= v"1.8.0-beta1" - @setup_workload begin - A = rand(1, 1) - B = rand(1, 1) - res = similar(A) - @compile_workload begin - rdiv!(res, A, UpperTriangular(B)) - rdiv!(res, A, UnitUpperTriangular(B)) - rdiv!(res, A, UpperTriangular(B), Val(false)) - rdiv!(res, A, UnitUpperTriangular(B), Val(false)) +using PrecompileTools: @setup_workload, @compile_workload - __init__() - ldiv!(res, LowerTriangular(B), A) - ldiv!(res, UnitLowerTriangular(B), A) - ldiv!(res, LowerTriangular(B), A, Val(false)) - ldiv!(res, UnitLowerTriangular(B), A, Val(false)) +@setup_workload begin + # The drivers branch on runtime sizes only, so N = 8 reaches every kernel: + # inference covers the untaken blocked and threaded branches. The four + # wrappers do not share specializations — each `ldiv!` transposes its args. + N = 8 + for T in (Float64, Float32) + B = Matrix{T}(undef, N, N) + A = Matrix{T}(undef, N, N) + C = Matrix{T}(undef, N, N) + b = Vector{T}(undef, N) + c = Vector{T}(undef, N) + B .= rand.(T) + @view(B[diagind(B)]) .+= T(N) + A .= rand.(T) + b .= rand.(T) + @compile_workload begin + for W in ( + UpperTriangular, + UnitUpperTriangular, + LowerTriangular, + UnitLowerTriangular + ) + U = W(B) + rdiv!(C, A, U) + rdiv!(C, A, U, Val(false)) + rdiv!(copyto!(C, A), U) + rdiv!(copyto!(C, A), U, Val(false)) + ldiv!(C, U, A) + ldiv!(C, U, A, Val(false)) + ldiv!(U, copyto!(C, A)) + ldiv!(U, copyto!(C, A), Val(false)) + ldiv!(c, U, b) + ldiv!(c, U, b, Val(false)) + ldiv!(U, copyto!(c, b)) + ldiv!(U, copyto!(c, b), Val(false)) + end end end end -=# end