Skip to content

Add SSE inverse residue schedule and scheduled inverse dispatch#34

Merged
falseywinchnet merged 1 commit into
mainfrom
ptsa5p-main/update-local-repo-and-optimize-inverse-performance
Jun 21, 2026
Merged

Add SSE inverse residue schedule and scheduled inverse dispatch#34
falseywinchnet merged 1 commit into
mainfrom
ptsa5p-main/update-local-repo-and-optimize-inverse-performance

Conversation

@falseywinchnet

Copy link
Copy Markdown
Owner

Motivation

  • Replace the recursive inverse residue traversal with a flat, forward-derived schedule to remove per-call overhead and expose sequential op metadata to SIMD backends.
  • Enable the scheduled inverse on 128-bit SSE/NEON builds first because removing recursion is the clearest win there while wider-vector paths keep the proven recursive kernels.

Description

  • Add an INV_RES_SCHEDULE table and build_inverse_residue_schedule() that reverses FWD_RES_SCHEDULE and appends a final inverse binomial to form the exact inverse stream.
  • Introduce scheduled dispatchers run_inv_residue_schedule and run_inv_residue_schedule_f32 that walk INV_RES_SCHEDULE and call the inverse kernels (norm2_inv_fused, codelet_d3_tw_res_inv, binomial_inv, etc.), and add __builtin_prefetch hints for the next base.
  • Wire schedule construction into plan setup (build_forward_schedules() now builds INV_RES_SCHEDULE) and gate use of the flat scheduled inverse with #if BRUUN_LEVEL == 1 so SSE/NEON use the schedule while AVX2/AVX-512 retain the existing recursive path.
  • Add a text notes file src/detail/inverse_acceleration_notes.txt documenting the decisions, ISA gating, and follow-up optimization candidates.

Testing

  • Ran make test which built the library and ran tests/correctness and tests/api_c, both completing successfully on the AVX2 build.
  • Built and ran an SSE-only test build (make BUILD_DIR=build-sse AUTO_SIMD_FLAGS='-msse2 -mno-avx'), ran build-sse/examples/benchmark 65536 7, and observed improved SSE round-trip timings versus the previous SSE build.
  • Built and ran AVX2 benchmarks (examples/benchmark 65536 7) and observed that AVX2 performance did not improve with the flat schedule on this host, so the recursive inverse path remains enabled for wide-vector backends.
  • Generated assembly via make asm-check and inspected the run_inv_residue_schedule / codelet output to verify vectorized code paths and that prefetch hints are emitted.

Codex Task

@falseywinchnet falseywinchnet merged commit 950d0e8 into main Jun 21, 2026
4 checks passed
@falseywinchnet falseywinchnet deleted the ptsa5p-main/update-local-repo-and-optimize-inverse-performance branch June 21, 2026 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant