Repository navigation
rational: recursive (IIR) half-band stages by 2 and their cascades (IIR-b) - #113
Merged
Merged
Conversation
… A9) Moves submodules/dsptap from 084f2f6 (v0.2.0) to bd9617a, the commit the maintainer tags v0.3.0 (tap/DspTap#68: IIR-a's recursive substrate, iir_design.h, iir_tables.h, iir_kernels.h, subnormals.h, chain.h's nominal latency members, and X-c's subband.h). TAP_SR_DSPTAP_MINIMUM is 0.3.0 in the three umbrella headers, family.VersionMacrosAgree re-pinned, and the root README's tested pairs gain the row for the unreleased 0.9.0. TAP_SR_VERSION stays 0.8.0 (0.9.0 is IIR-d's). Outside the new headers DspTap 0.3.0 changes only comments in kaiser.h and nyquist.h and adds members to chain.h that no FIR workload instantiates. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016GKzq1VSdcMYCRMhddiMaf
…e variants, and the cascades (IIR-b) The recursive stages of docs/IIR_PLAN.md (I2-I6, I8, I9, I13, I14), a stage type of their own beside basic_stage (the family's D20): - iir_stage.h: basic_iir_stage<S, Ch, R, P> over iir_stage_base<S, R, P> (K12), R up2 / down2, P iir_phase::nonlinear (the elliptic two-path allpass half-band) or iir_phase::near_linear (one path a pure delay); the aliases iir_converter<Ch, R> and iir_converter_near_linear<Ch, R> with their _q15 / _q31 siblings. The stage machine around DspTap's step kernels: the commutator and its latch, the near-linear delay path's ring, pull()'s banked output, outputs_for / frames_needed, flush and window_frames(), validate() (D17), process / pull / flush out of line against a cursor (A12). Every named profile reaches both variants (I3), at compile-time designs (nonlinear) or DspTap's committed tables (near-linear) at the divisors 1, 2, 4 and 8; a custom nonlinear profile designs at run time, a custom near-linear one is refused. Latency is the nominal triple chain.h composes (I5), plus the near-linear delay path subband.h takes as T; flush-to-zero is the host's job, checked as a debug-build precondition (I9). - iir_chain.h: iir_down_by / iir_up_by<S, Ch, P, D>, D = 2, 4, 8, 16: a cascade of half-bands, each at profile::relaxed of its divisor (I13). Its exact latency is deleted, its delay path composed, so the round-trip scaffold takes the near-linear cascades and refuses the nonlinear ones. - The golden leg: tools/reference/make_iir_reference_vectors.py writes tests/reference/iir_reference_vectors.h, every offered stage's transfer function in one direct form through scipy.signal.lfilter around down- sampling or zero-stuffing (64 cases). - tests/test_iir_stage.cpp (typed over float / double / Q15 / Q31) and tests/test_iir_subnormals.cpp (its own image, TAP_DSP_ALLOW_SUBNORMALS), the compile-fail "iir" set, the bare-metal runner for the second image, the header count re-pinned at 8. The four-path stage by 4 does not ship: measured on this machine it does not beat the two half-bands it would replace by R3's 10 % on the M33, the M55 and Hexagon (I12; the record is rational/tools/spikes/iir/ iirb_fourpath/). The floating near-linear stage at transparent and divisor 1 holds a zero-input limit cycle at about four times the smallest normal under flush-to-zero, so I6's exactly zero state does not hold there: pinned as an honest limit pending the maintainer's decision. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016GKzq1VSdcMYCRMhddiMaf
rational/tools/spikes/iir/iirb_fourpath/: the probes, the draft of iir_stage.h they measured (with the four-path stage by 4 that the measurement kept out of the release), and the counts on the M33, the M55 and Hexagon. Against the two half-bands it replaces (economy, streaming instructions), going down: float +10.7 / +9.2 / -19.5 %, Q15 +14.6 / -10.1 / -24.1 %; going up: float +2.1 / -1.2 / -7.7 %, Q15 -14.7 / -5.0 / -10.7 %. No format, direction and placement clears R3's 10 % on every target, so it does not ship. Not part of any build. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016GKzq1VSdcMYCRMhddiMaf
…IR-b) clang-tidy's readability-identifier-naming: the typed tests' `using S = TypeParam;` and the helpers' sample aliases are `sample`, the golden runner's ratio alias `direction`. No test changes what it checks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016GKzq1VSdcMYCRMhddiMaf
…ook (IIR-b) - docs/IIR_PLAN.md v10: IIR-a recorded as landed (tap/DspTap#68) with its findings; I3, I6, I8, I13, I14 and the names decided with the maintainer's answers; IIR-b's results, the four-path measurement (2.4, I12: it does not ship) and the near-linear transparent stage's limit cycle under flush-to-zero as open question 19. - PLAN.md: D20 (IIR stages are a stage type of their own, not a profile and not an engine), cited by section 2's line. - rational/PLAN.md: the charter (section 1) and R2 amended, R21-R25, the layout, the v0.21 row and the IIR-b record in section 6. - rational/CLAUDE.md: the charter constraints (R1-R25, the _by aliases, the recursive stages); the root CLAUDE.md's rational sentence. - README.md: rational's row with each variant's profiles, the profile section's note that the variant is in the type; rational/README.md: the recursive stages, their numbers, the per-target flush-to-zero table and the honest limits. - docs/ROADMAP.md: section 8's deferral of the IIR pre-filter lifted, and section 10, Block IIR (IIR-0 to IIR-d). - book: Part VII's chapter on iir_stage.h. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016GKzq1VSdcMYCRMhddiMaf
…he saturation counted, the padding streamed (IIR-b) - make_iir_reference_vectors.py also writes each stage's direct-form group delay (scipy.signal.group_delay) at 0, half and all of its passband edge; iir_double.GroupDelayMatchesTheGoldenLeg holds group_delay_output_frames(f) to it (8.5e-11 frames at worst) and the stated deviation to bound it. The expected outputs are unchanged. - FullScaleDriveNeverWrapsInside checks that every output the double stage takes past full scale is the rail of its sign (69128 in Q15, 71343 in Q31), so saturation is at the output and never a wrap. - The flush tests stream the zero padding in blocks: whole, the double windows outgrew the M55 image's heap (std::bad_alloc on the leg). - The plans' Q31 headroom figure: 1.99 of full scale, as Q15's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016GKzq1VSdcMYCRMhddiMaf
The near-linear fixed-point window's rule as implemented (twice the sections' pole-radius decay), the limit cycle of the floating near-linear transparent stage at divisor 1 among the honest limits (the IIR plan's question 19), the measured headroom, Q15 floor and subnormal residue, and the tests' names as gtest reports them. Comments only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016GKzq1VSdcMYCRMhddiMaf
…IIR-b, A4) The recursive stages take the same four profile names at the same numbers; the table says so where the README's profile section already does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016GKzq1VSdcMYCRMhddiMaf
…R-b) Double on the M33 and float and double on Hexagon have no flush-to-zero control (tap/dsp/subnormals.h), so the fixture's bits reach nothing there and a floating state sticks at the subnormal residue. FlushEqualsZeroPaddingBitForBit, its chains and SilenceDecaysToExactZero hold those types to the residue (64 times the smallest subnormal through a chain) on those legs, and to an exactly zero state everywhere a bit governs the type, as DspTap's battery does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016GKzq1VSdcMYCRMhddiMaf
…t is summarized (IIR-b, I12) iir_chain.h, R21, the README, the book and the spike's README said the stage passed only on Hexagon or cost more on both Arm targets; it also passed in Q15 going up on the M33 and going down on the M55. What fails the bar is that no format and direction passes on all three targets. Comments and prose only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016GKzq1VSdcMYCRMhddiMaf
…(IIR-b) iir_double.EveryStageMeetsItsSpecAtEveryProfileAndDivisor runs 32 impulse responses through a 2049-point DTFT per band in double, which is software on Hexagon: it was still running after 20 minutes under qemu-hexagon, the job's budget. A host measurement, as the Arm legs' one-shot filter already treats it (bare_metal_main.cpp); every other recursive test runs on Hexagon. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016GKzq1VSdcMYCRMhddiMaf
Hosted GCC 13 and Clang 18 with -Werror, both builds, Debug; clang-tidy, clang-format, the vocabulary gate and the book; the M33, M55 and Hexagon batteries in both builds; the ratchet and the ceilings unchanged on every key. MSVC and AppleClang not run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016GKzq1VSdcMYCRMhddiMaf
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.
What this changes
IIR-b of
docs/IIR_PLAN.md:rationalgains recursive (IIR) half-band stages by 2 and their cascades, a stage type of their own beside the FIR stages (D20, R21–R25). The FIR stages, chains, matrix and C ABI are unchanged.iir_stage.h:basic_iir_stage<S, Ch, R, P>overiir_stage_base<S, R, P>(K12). R isup2/down2. P isiir_phase::nonlinear(the elliptic two-path allpass half-band) oriir_phase::near_linear(one path a pure delay, with an exact delay path).process,pull,flush,reset,validate,outputs_for,frames_needed,window_frames).nominal_latency_output_frames,latency_deviation_output_frames,group_delay_output_frames(f)), anddelay_path_output_frames()for the near-linear variant (I5).iir_converter<Ch, R>,iir_converter_near_linear<Ch, R>, and their_q15/_q31siblings.static_asserts whose messages say why.iir_chain.h:iir_down_by/iir_up_by<S, Ch, P, D>, D = 2, 4, 8 or 16, each stage atprofile::relaxed(d)(I13). The cascade deletes the inherited exact latency and gives its own composed delay path and window.v0.3.0(bd9617a, IIR-a: the recursive substrate (designs, tables, kernels per format, FTZ, chain nominal latency), 0.3.0 DspTap#68: IIR-a's substrate).TAP_SR_DSPTAP_MINIMUMis 0.3.0 in the three umbrella headers, and the root README's tested pairs gain the row for the unreleased 0.9.0.TAP_SR_VERSIONstays 0.8.0; 0.9.0 is IIR-d's.tools/reference/make_iir_reference_vectors.py: 64 stages throughscipy.signal.lfilter, committed vectors) and the batterytests/test_iir_stage.cpp;tests/test_iir_subnormals.cpp(TAP_DSP_ALLOW_SUBNORMALS, an executable of its own);rational.IirStage.RefusedShapesFailToCompileWithTheMessage);PLAN.md2 and D20),rational/PLAN.mdR21–R25 and its verification record, the roadmap's section 10, the book's new chapterbook/src/part7/iir.md, the READMEs' profile table, anddocs/IIR_PLAN.mdv10 (the decisions recorded, I12's verdict, question 19).rational/tools/spikes/iir/iirb_fourpath/: probes, the draft header they measured, and counts per target.Why
The IIR plan's second step (section 5). These are the stages the plan's remaining steps build on: IIR-c's guard band filter, and IIR-d's C ABI, notebooks, ratchet workloads and 0.9.0.
I12 only lets the four-path ↓4/↑4 ship where it measures more than 10 % fewer instructions than the two half-bands it replaces. On the shipping machine over DspTap's kernels, streaming at
economy(the other two 70 dB profiles are within 0.01 %):No format and direction clears 10 % on all three targets. IIR-0's kernels unrolled their fixed section counts; DspTap's are generic, which costs the in-order Arm cores. So R is
up2/down2only, and every cascade is half-bands.Verification
Each number is measured by the named test (asserted there against its bound or stated tolerance):
iir_stage_test.MatchesTheDirectFormGoldenLegiir_fixed_test.OutputsAreBitPinnedGroupDelayMatchesTheGoldenLegEveryStageMeetsItsSpecAtEveryProfileAndDivisortransparent)AliasingAndImagingMeasuredBySineFitstap::dsp::subband_deltatransparent; one frame off T stays above −40 dBRoundTripCancelsToTheProfilesThresholdeconomy, ↓2NominalLatencyAndGroupDelayMatchTheImpulseResponseeconomy, MACs per output by 2 / 4 / 8 / 16down_by4…down_by16: 43 / 71 / 143)IirChain.CascadesCostTheRelaxedRowFullScaleDriveNeverWrapsInside,Q15FloorIsTheOutputsOwnRounding,FixedPointSilenceIsExactlyZeroAfterTheWindowiir_subnormals.WithoutFlushToZeroTheResidueIsBoundedWhere it ran:
-Werroron all three engines, 407 of 407 (my rebuild of the pushed head); Clang 18 with-Werrorand-Wshadow-all, and GCC without exceptions or RTTI, all passing; a Debug build of rational's battery, 209 of 209, the precondition's death test included.ci.yml(in soft double it ran past the job's 20 minutes); the Arm one-shot filter excludes it too.Notes for the reviewer
submodules/dsptap084f2f6 (v0.2.0) → bd9617a (v0.3.0). Besides the new headers, DspTap 0.3.0 changes only comments inkaiser.handnyquist.h, and addschain.hmembers that no FIR workload instantiates.transparent, divisor 1 (order 19), holds a zero-input limit cycle under flush-to-zero at 3.7–4.1× the smallest normal, in float and double, from 12–20 of 39 noise starts. It is the mechanism IIR-a found in the Chebyshev II.iir_up_by<…, near_linear, 8>attransparent).iir_stage.h.docs/IIR_PLAN.mdquestion 19: keep the limit, commit a draining design in DspTap, or don't offer that stage in floating point.pull()banks the second output of a pair when a call asks for an odd count.states()accessor exists for the tests.Generated by Claude Code