Skip to content

[meta] WaveSimulation Q15 stencil — perf + algorithmic follow-ups from #3073 #3098

Closed

Description

@zackees

Tracks the deferred items from the closed audit issue #3073 / merged PR #3083.

PR #3083 addressed §1 (the latent i32 overflow correctness bug in WaveSimulation*_Real::update()). The remaining items — perf wins and algorithmic options for the wave PDE solver behind WaveFx — are filed below as focused, independently-mergeable sub-issues.

Sub-issues

Recommended execution order

  1. Perf bundle — §2 + §3 + §4 (perf(wave): replace damping division by power-of-two with arithmetic shift (refs #3073 §2) #3092 + perf(wave): fold half-duplex zero-clamp into main update loop (refs #3073 §3) #3093 + perf(wave): branchless Q15 clamp + hoisted row indexing + __restrict__ (refs #3073 §4) #3094). Bundle into one PR — they all touch the same inner loop in wave_simulation_real.cpp.hpp and are easier to review together. Low risk, immediate user-visible CPU win on AVR / Cortex-M0.
  2. §6 (perf(wave): precompute damping as a Q15 multiplier (refs #3073 §6, alt to §2) #3096) instead of §2 (perf(wave): replace damping division by power-of-two with arithmetic shift (refs #3073 §2) #3092) if non-power-of-two damping is on the roadmap.
  3. §5 (feat(wave): opt-in 9-point isotropic Laplacian for super-sampled mode (refs #3073 §5) #3095) — opt-in algorithmic upgrade for the super-sampled path. Default off; user-visible visual quality improvement when enabled.
  4. §7 (feat(wave): SIMD kernels for wave PDE update — host + ESP32-S3 PIE + Teensy 4 DSP (refs #3073 §7) #3097) — separate larger effort, behind per-platform #ifdef gates. Each backend (host SSE2 / AVX2 / NEON, ESP32-S3 PIE, Teensy 4 DSP) is independent and can ship one at a time. Recommended after §2–§4 stabilize the scalar baseline.

Files touched (all sub-issues)

  • src/fl/math/wave/wave_simulation_real.h
  • src/fl/math/wave/wave_simulation_real.cpp.hpp
  • src/fl/math/wave/wave_simulation.{h, cpp.hpp} (super-sampled wrapper — touched by §5 default selection)
  • tests/fl/math/wave/wave_simulation_real.cpp (existing suite — extended per sub-issue)
  • §7 adds new platform-specific TUs (e.g. wave_simulation_real_simd_neon.cpp.hpp)

Not in this meta (related but independently tracked)

Other open meta trackers in the repo; cross-referenced here only to make it obvious they are not sub-issues of this one:

History

Activity

  1. zackees commented on Jun 15, 2026

    @zackees
    MemberAuthor

    All §1–§7 deferred items from the original audit (#3073) are now resolved.

    Sub-issue outcomes

    § Issue PR Outcome
    §1 #3073 (audit) #3083 i32 overflow fix + speed clamp at CFL bound, MERGED
    §2 #3092 #3099 damping division → arithmetic shift, MERGED (later superseded by §6's Q15 multiplier)
    §3 #3093 #3101 half-duplex zero-clamp folded into update loop + branchless fl::clamp, MERGED
    §4 #3094 #3103 row-arithmetic hoist + FL_RESTRICT_PARAM in 2D inner loop, MERGED
    §5 #3095 #3104 opt-in 9-point isotropic Laplacian + wrapper auto-select at SuperSample ≥ 2X, MERGED
    §6 #3096 #3105 precomputed Q15 damping multiplier (supersedes §2), MERGED
    §7 #3097 — umbrella closed; split into three focused per-backend sub-issues: #3106 (host), #3107 (ESP32-S3 PIE), #3108 (Teensy 4 DSP)

    State of the scalar wave kernel after this meta

    • Correctness: worst-case product cannot overflow i32 (i64 promote + CFL clamp).
    • Memory traffic: single pass over the 2D grid per update (half-duplex fold-in).
    • Inner loop: row pointers + FL_RESTRICT_PARAM, branchless fl::clamp, precomputed Q15 damping multiplier.
    • Algorithmic options: 5-point (default) or 9-point isotropic (auto-selected by the supersampled wrapper at multiplier ≥ 2).

    Open items in the same family (filed during this meta)

    Closing the meta. Future wave-kernel work tracks individually.

  2. moved this from Triage to Done in FastLED Trackeron Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions