Make bounded scalar folds data-first - #8
Conversation
Post-merge compiler measurement follow-upThese measurements close the requested engineering notes; they are not timing gates. Julia 1.12.6, Apple M1, one Julia thread, KernelAbstractions 0.9.42, Statistics 1.11.5. Each column used a fresh Julia process with existing package caches and an isolated temporary Pkg environment. No repository Project/Manifest or production code was changed. The small witness has two source items, four Float32 input values
All three evaluators are concrete/isbits and infer Reproduction: develop the selected LocalMath checkout temporarily, add KernelAbstractions and Statistics to that temporary environment, and use the public authoring fixture below. Run the three spellings in separate processes; the legacy spelling is used only when checking out the historical baseline. using LocalMath, KernelAbstractions, Statistics, InteractiveUtils
function make_law(source, values, output, neighbors)
@localmath i ∈ source begin
gathered = samples(values[neighbors(i)])
output[i] = LocalMath.fold(gathered;
combine=+, init=0.0f0, domain = >(0.0f0))
end
end
source = Space(2)
values_space = Space(4)
values = Field(values_space, Float32)
output = Field(source, Float32)
neighbors = FixedRelation(source => values_space; degree=2)
law = make_law(source, values, output, neighbors)
bound = LocalMath.bind(law,
values => Float32[1,2,3,4], output => zeros(Float32,2),
neighbors => reshape(Int32[1,2,3,4],2,2))
planned = LocalMath.plan(bound; backend=CPU())
prepared = prepare(planned)
wait(execute!(prepared))
@assert LocalMath.storage(prepared, output) == Float32[3,7]Time construction, binding, planning, preparation, and first execution separately with For the historical case, construct Interpretation: no extra fold launch family, no warm compilation/recompilation, no warm-host allocation regression in this witness, and concrete evaluator results. Single-run cold differences are descriptive, not a general speedup claim. |
Existing four-stage compiler benchmark: baseline/current follow-upRan the repository-owned workload, unchanged, in fresh Julia 1.12.6 processes with one thread, KernelAbstractions 0.9.42, on Apple M1: julia --project=<temporary-environment> --startup-file=no \
<checkout>/benchmark/compiler_scaling/stage_scaling.jl \
--stages=4 --items=16 --warm-samples=9Temporary environments used
The repeated pair ran sequentially with the other compiler measurement process stopped. The initially observed ~6% cold difference did not persist: repeated preparation is effectively the same, and planning varied in the opposite direction. These few runs are descriptive compiler-health evidence, not a speedup claim or timing acceptance threshold. Physical phases, warm allocation, and warm compilation remain unchanged for the existing Unique/Reduce/Resolve/Collect workload. No benchmark-specific optimization or production change was made. The focused fold/reduction evaluator measurements (including selected optimized typed IR) are in #8 (comment) . |
Summary
LocalMath.fold(values; ...)authoring operationBoundedFold(T, ...)andevaluate_boundedas compiler contractsbounded_foldspelling without an aliasValidation