Skip to content

Keep the render reserve at the highest edge rates - #83

Merged
simonjohansson merged 1 commit into
mainfrom
reserve-edge-rates
Oct 22, 2026
Merged

simonjohansson merged 1 commit into
mainfrom
reserve-edge-rates

Conversation

@simonjohansson

Copy link
Copy Markdown
Owner

Resolves the cost part of #74. The device check stays open there.

Summary

  • Compute each edge's fraction exactly with one 16-bit quotient digit (Knuth's algorithm D: ff1, one divu.l, at most two corrections), and drop the reciprocal cache. Under FM, every edge missed that cache.
  • Skip the step taps at a triangle's corner (step 0), and the edges of a silent line voice.
  • Unroll the EMAC taps routine, and load the next pair between the last MAC and the first movclr, which removes a 4-cycle stall.

Output is unchanged, so no tolerances or alias limits are affected.

Cost (mise run cost, worst cycles a block, one-instance budget 50,030)

Scenario main this PR
most edges (Analog on) 76,966 (154%) 47,706 (95%)
high narrow pulses (Analog on) 24,357 19,858
saw feedback FM (Analog on) 20,194 19,116
one saw (Analog off) 5,711 4,655

All 13 scenarios got cheaper.

Verification

  • mise run cost: worst case is 95% of the one-instance budget, inside the 10% reserve
  • mise run cost:equivalence: assembly matches C in every sample and state; the mutation is detected
  • mise run test, mise run test:oscillators, mise run test:modulation pass
  • Host comparison against main: bit-identical output and state over 6,000 random banks (16.9M samples, both Analog settings, 20 kHz and 12.5 kHz edge cases, silent voices); fraction matches 64-bit division over 200M random inputs
  • mise run build:digitakt builds and lints; no 64-bit or clz helpers are imported
  • Device check of the worst-case workload: needs device testing

🤖 Generated with Claude Code

Three tri/saw combinations at the 20 kHz clamp with deep oscillator 3
feedback needed 76,966 cycles a block, 154% of the one-instance budget.
Every modulated edge missed the cached reciprocal and recomputed it
with two hardware divisions and a 16-step shift-and-subtract loop.

Compute each edge's fraction directly with one quotient digit of
Knuth's algorithm D, and drop the reciprocal cache, which now costs
more than it saves. Skip the step taps at a triangle's corner and the
edges of a silent line voice, where they add nothing. Unroll the EMAC
taps and move the next pair's load ahead of the first accumulator read,
which removes a stall.

The worst case is now 47,706 cycles, 95% of the budget. The output is
bit-identical: the assembly matches C, and the C matches main over
6,000 random banks in both Analog settings.

#74

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@simonjohansson
simonjohansson merged commit cb1eefc into main Oct 22, 2026
4 checks passed
@simonjohansson
simonjohansson deleted the reserve-edge-rates branch October 22, 2026 21:16
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