Skip to content

Commit a95d8da

Browse files
Merge pull request #134 from ChrisRackauckas-Claude/precompile-improvements-20260101-030200
Add PrecompileTools workload to improve TTFX
2 parents c137361 + d3a0e8c commit a95d8da

3 files changed

Lines changed: 39 additions & 0 deletions

File tree

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ version = "0.1.3"
77
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
88
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
99
ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78"
10+
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
1011
RandomizedLinAlg = "0448d7d9-159c-5637-8537-fd72090fea46"
1112
Setfield = "efcf1570-3423-57d1-acb7-fd33fddbac46"
1213
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
@@ -16,6 +17,7 @@ TSVD = "9449cd9e-2762-5aa3-a617-5413e99d722e"
1617
DocStringExtensions = "0.8, 0.9"
1718
LinearAlgebra = "1"
1819
ModelingToolkit = "10.10"
20+
PrecompileTools = "1"
1921
RandomizedLinAlg = "0.1"
2022
Setfield = "0.8, 1"
2123
SparseArrays = "1"

src/ModelOrderReduction.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,6 @@ export POD, reduce!
1919
include("deim.jl")
2020
export deim
2121

22+
include("precompile.jl")
23+
2224
end

src/precompile.jl

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using PrecompileTools
2+
3+
@setup_workload begin
4+
# Setup code - create minimal test data
5+
n = 20 # small state dimension
6+
m = 10 # small number of snapshots
7+
snapshot_matrix = Float64[sin(i * j / n) for i in 1:n, j in 1:m]
8+
snapshot_vov = [Float64[sin(i * j / n) for i in 1:n] for j in 1:m]
9+
10+
# Create an orthonormal basis for deim_interpolation_indices
11+
Q, _ = qr(snapshot_matrix)
12+
deim_basis = Matrix(Q[:, 1:5])
13+
14+
@compile_workload begin
15+
# POD construction with matrix input
16+
pod_mat = POD(snapshot_matrix, 3)
17+
18+
# POD construction with vector of vectors
19+
pod_vov = POD(snapshot_vov, 3)
20+
21+
# reduce! with SVD algorithm
22+
reduce!(pod_mat, SVD())
23+
24+
# reduce! with TSVD algorithm
25+
pod_tsvd = POD(snapshot_matrix, 3)
26+
reduce!(pod_tsvd, TSVD())
27+
28+
# reduce! with RSVD algorithm
29+
pod_rsvd = POD(snapshot_matrix, 3)
30+
reduce!(pod_rsvd, RSVD())
31+
32+
# deim_interpolation_indices (core DEIM algorithm)
33+
deim_interpolation_indices(deim_basis)
34+
end
35+
end

0 commit comments

Comments
 (0)