Commit e22f5d6
committed
Cache SearchProperties per interpolation to skip per-call Auto probes
The previous commit migrated the sorted-batch evaluators to FFF 2.0's
strategy-dispatched `searchsortedlast!` API, but called it with the
default `strategy = Auto()`. Each such call has `Auto()` re-probe the
knot vector `A.t` for linearity / NaN / uniformity on every batched
evaluation. Because `A.t` is fixed at interpolation construction, that
probe is wasted work on every call after the first.
This commit precomputes `FindFirstFunctions.SearchProperties(A.t)`
once at cache-construction time and stores it as a new
`t_props::propsType` field on every interpolation cache struct, then
threads `FindFirstFunctions.Auto(A.t_props)` into each batched
`searchsortedlast!` call site so the probe is skipped.
Changes:
- `src/interpolation_caches.jl`: every cache struct
(`LinearInterpolation`, `QuadraticInterpolation`,
`LagrangeInterpolation`, `AkimaInterpolation`,
`ConstantInterpolation`, `SmoothedConstantInterpolation`,
`QuadraticSpline`, `CubicSpline`, `BSplineInterpolation`,
`BSplineApprox`, `CubicHermiteSpline`, `QuinticHermiteSpline`,
`SmoothArcLengthInterpolation`) gains a `propsType` type
parameter and a `t_props` field, populated by
`FindFirstFunctions.SearchProperties(t)` in the inner constructor.
- `src/integral_inverses.jl`: same change for
`LinearInterpolationIntInv` and `ConstantInterpolationIntInv`.
- `src/interpolation_methods.jl`: every
`FindFirstFunctions.searchsortedlast!(...)` call site in the
sorted-batch evaluators now passes
`strategy = FindFirstFunctions.Auto(A.t_props)`.
`_eval_interior_adaptive!` gains a `strategy` parameter so the
Akima call site can pass the cached strategy through.
For `AbstractRange{<:Real}` knot vectors the `SearchProperties`
specialised constructor skips every probe (all properties are known
statically), so the construction cost is zero. For `Vector{Float64}`
the populated constructor runs an O(n) NaN scan once at construction
time; for integer / non-numeric eltypes only the O(1) sampled-
linearity probe runs.
Tests: all five groups pass locally on Julia 1.11:
Core | 2539 pass, 5 broken (pre-existing)
Methods | 42151 pass
Extensions | 13178 pass
Misc | 11 pass
QA | 18 pass
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>1 parent 9ad45d3 commit e22f5d6
3 files changed
Lines changed: 113 additions & 50 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
45 | | - | |
46 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
47 | 49 | | |
48 | 50 | | |
49 | 51 | | |
| |||
93 | 95 | | |
94 | 96 | | |
95 | 97 | | |
96 | | - | |
| 98 | + | |
97 | 99 | | |
98 | 100 | | |
99 | 101 | | |
100 | 102 | | |
101 | 103 | | |
102 | 104 | | |
| 105 | + | |
103 | 106 | | |
104 | 107 | | |
105 | 108 | | |
106 | 109 | | |
107 | | - | |
108 | | - | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
109 | 113 | | |
110 | 114 | | |
111 | 115 | | |
| |||
0 commit comments