You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf(wave): fold half-duplex zero-clamp into main update loop (refs #3073 §3) #3093
src/fl/math/wave/wave_simulation_real.cpp.hpp runs the half-duplex zero-clamp as a separate second full pass over the grid:
1D: lines ~151–158
2D: lines ~296–306
if (mHalfDuplex) {
for (fl::size j = 1; j <= height; ++j) {
for (fl::size i = 1; i <= width; ++i) {
int index = j * stride + i;
if (next[index] < 0) next[index] = 0;
}
}
}
This doubles memory traffic on the grid — especially expensive in 2D when vector_psram<i16> puts the grid in ESP32 PSRAM (slow RAM, no cache prefetch help).
Change
Fold into the existing update loop right before the store:
if (mHalfDuplex && f < 0) f = 0;
next[index] = (i16)f;
Better — combine the half-duplex clamp with the existing Q15 saturation clamp using fl::clamp (which most compilers lower branchlessly). Hoist lo out of the inner loop:
Activity
zackees commentedon Jun 15, 2026
Parent meta: #3098. Bundle with #3094 (§4 branchless clamp + hoisted indexing) — same inner loop body.
perf(wave): fold half-duplex zero-clamp into main update loop (#3101)