Skip to content

Perf: NDCT/NDST direct 1D — blocked phase recurrence - #234

Draft
jenskeiner wants to merge 3 commits into
developfrom
feature/nfct-nfst-performance
Draft

Perf: NDCT/NDST direct 1D — blocked phase recurrence#234
jenskeiner wants to merge 3 commits into
developfrom
feature/nfct-nfst-performance

Conversation

@jenskeiner

@jenskeiner jenskeiner commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

perfeng-pr-234.zip

NDCT/NDST direct 1D — blocked phase recurrence

Optimizes the 1D branch of the direct real transforms — nfct_trafo_direct /
nfct_adjoint_direct (kernel/nfct/nfct.c) and nfst_trafo_direct /
nfst_adjoint_direct (kernel/nfst/nfst.c), serial + OpenMP — by transplanting the
NDFT blocked phase-recurrence optimization. Instead of recomputing cos/sin per
frequency, the phase is advanced by a per-step complex factor within fixed-size
blocks, with an accurate reduced-argument seed per block.

Outcome

  • Speed: NDCT/NDST 1D direct 4–5.5× faster (forward), ~4× faster
    (threaded adjoint, large N).
  • Accuracy: avoidable large-N argument error removed (recurrence caps argument
    error at O(B·u) instead of O(N·u)); verified offline, surfaced via the accuracy
    heatmap.
  • Correctness: full CUnit suite green in float / double / long-double
    (checkall + checkall_threads); net extended to cover the OpenMP 1D direct path
    (tests/check.c).
  • Residual resolved: the threaded-adjoint N≈64–128 perf valley was fixed with a
    num_threads(N/B) cap on the blocked branch (platform-independent), now −40…−54% at
    N=64 vs baseline in float and double.
  • Follow-up (won't fix): a real 3-term (Chebyshev) recurrence for the single needed
    cos/sin sequence was assessed and rejected — structural endpoint conditioning defect;
    the complex form's "discarded" component is load-bearing.

Deliverables

Produced by the nfft-perf-eng skill. Per the current convention the run's deliverables
(phase docs, summary.html, error-analysis.html, raw benchmark/test artifacts, charts)
live in the gitignored .perfeng/ directory and are not committed — they are attached
to this PR as a zip (perfeng-pr-234.zip). summary.html is the reviewer's entry point.

Note: based on develop, so until the perf-engineering skill PR (#233) merges this
PR's diff also shows the skill files. The transform-specific change here is
kernel/nfct/nfct.c, kernel/nfst/nfst.c, and tests/check.c.

… conclude

Deliverables now live in a fixed, gitignored .perfeng/ (single static dir,
never committed) instead of docs/perfeng/NNNN-<slug>/; removed the committed
shared index. perf-init records the squash base in .perfeng/BASE.

Agents commit self-contained source units during the loop (Phase E), and a
new Phase G hands the run off: perf-conclude.sh squashes to one commit
(reset --soft <base>), then offers push + PR to develop labelled perf-eng;
package <N> renames .perfeng -> .perfeng-pr-<N> and builds a standard-ZIP
perfeng-pr-<N>.zip to attach. Post-conclude follow-ups re-package and
overwrite the archive in the existing PR comment.


def failing(path):
fails = [(c, e, b) for st, c, e, b in parse(read(path)) if st in ("FAIL", "ERROR")]
def cmd_check(args):
names = {c for c, _, _ in failing(args.log)}
if args.expect:
expected = {ln.strip() for ln in open(args.expect) if ln.strip()}
if not os.path.exists(summ):
sys.stderr.write(f"error: {summ} not found\n")
return 1
html = open(summ, encoding="utf-8").read()
@jenskeiner
jenskeiner marked this pull request as draft July 2, 2026 21:20
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

Accuracy report

2279 unchanged · 78 improved · 3 regressed

module improved regressed
nfct 27 2
nfst 51 1

📊 Full accuracy report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant