Name first generated kernel: splined field evaluation (#515) - #516
Open
krystophny wants to merge 1 commit into
Open
Name first generated kernel: splined field evaluation (#515)#516krystophny wants to merge 1 commit into
krystophny wants to merge 1 commit into
Conversation
Name splined_evaluate / splined_evaluate_with_der as the first SIMPLE kernel the lazy-fortran generation programme must replace, and add the production-side measurement instrument that decides whether a generated kernel is worth shipping. - DOC/first-generated-kernel.md records the decision and rationale (hottest, arithmetic-heavy, straight-line path; matches the symbolic-AD shape; libneo#408 evidence) and fixes the fortsym statement template. - test_splined_kernel_bench measures T (time per evaluation of the value-only and value+derivative variants) and X ulp (accuracy of the splined Bmod against the direct Biot-Savart coils field) on a real NCSX workload. Golden records are untouched: no production code changes.
krystophny
temporarily deployed
to
github-pages
August 10, 2026 22:26 — with
GitHub Actions
Inactive
krystophny
commented
Aug 10, 2026
krystophny
left a comment
Member
Author
There was a problem hiding this comment.
Review verdict: Comment
Summary: The benchmark is registered correctly, but its reported performance and accuracy gates are not reliable enough for the stated measurement contract.
Findings:
- [minor] test/tests/test_splined_kernel_bench.f90:125-135 — The timed region recomputes all sample coordinates, including
modand conversions, on every iteration. This inflatesTwith workload-generation overhead rather than measuring only field evaluation. Precompute the input points outside the timed loops. - [minor] test/tests/test_splined_kernel_bench.f90:80-91 — The comment claims a
<1e-3relative-accuracy gate, but the test only checksmax_ulp < 1e13; this is neither a relative threshold nor a meaningful accuracy oracle. Compare relative error directly (and separately compare generated output with the handwritten kernel).
Verdict: Comment — useful baseline, but the measurement claims should be corrected before relying on it for generated-kernel decisions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The lazy-fortran stack generates numerical kernels from symbolic definitions,
but none of its ~35 issues touches code that publishes a physics number. This
issue (#515) closes that gap by naming the first SIMPLE kernel that a generated
implementation must replace, and by fixing the measurement instrument that
decides whether the generated kernel is worth shipping.
The other candidates (canonical-coordinate transforms, RK stages) are larger,
more control-flow-heavy, or downstream of the field anyway. The spline path is
the hottest, arithmetic-heavy, straight-line evaluation in the code, and its
derivative variant has exactly the shape symbolic AD produces well — the
evidence (libneo#408 2.16x spline improvement, SIMPLE's own 2.86x batch-spline
speedup) is already in-repo.
Change
DOC/first-generated-kernel.md— records the decision: the firstgenerated consumer is
splined_evaluate/splined_evaluate_with_derinsrc/field/field_splined.f90, with the rationale and the fortsym statementtemplate (N_sym / N_emit / N_machine / T / X ulp).
test/tests/test_splined_kernel_bench.f90— the production-sidemeasurement instrument. It measures, on a real NCSX coils workload:
value+derivative splined-field kernel (best-of-N), and
Bmodagainst the direct Biot-Savartcoils field (the high-precision reference for this kernel).
test/tests/CMakeLists.txt— registerstest_splined_kernel_bench(labels
unit;performance).Baseline measured here (gfortran 14, one core):
The ulp figure is spline-interpolation accuracy at the default 62x63x64 grid,
the accuracy the kernel delivers today; a generated kernel must match it or the
golden-record gate rejects it. N_sym and N_emit come from the fortsym toolchain
(external); this PR supplies the SIMPLE-side measurement and the decision.
Acceptance
Golden records are untouched — no production code changes, only a new
measurement test and documentation.
Verified:
test_splined_kernel_bench,test_splined_field_derivatives,test_bder_from_splines, andtest_batch_splinesall pass.Closes #515