Repository navigation
perf(wave): fastest unrolled-naive 8/16-lane transpose + equivalence tests - #2532
Conversation
…ivalence tests (#2524) Goal: fastest possible wave3/wave8 8-lane and 16-lane bit transposes, no SIMD. Empirically benchmarked candidates on the ESP32-P4 (RV32) with a fair same-build A/B (all FORCE_INLINE + O3), 768 calls/frame: - 16-lane: unrolled naive 6595us vs two-pass (two 8x8 via u32) 10524us -> naive 1.6x faster - 8-lane: unrolled naive 3336us vs Hacker's-Delight u32 8x8 4680us -> naive 1.4x faster So the fully-unrolled naive bit-by-bit transpose is fastest for BOTH on the in-order RV32 (and on x86): the compiler schedules the independent shift/or ops better than a latency-bound delta-swap chain. The two-pass 4->8->16 decomposition was implemented and proven bit-correct but regressed, so it was not adopted (third time a structured bit-trick lost to the naive; cf u64 SWAR). Changes: - wave8/wave3 transpose_8: switch from the u32 HD primitive to the unrolled naive (~1.4x faster on RV32). - wave8/wave3 transpose_16: keep the unrolled naive (the two-pass regressed). - Add host unit tests (tests/fl/channels/wave3.cpp + wave8.cpp) asserting the production transposes are bit-identical to a ground-truth naive across edge + random inputs. Refs #2524
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughWave3 and Wave8 bit-matrix transpose functions were reimplemented from Hacker's Delight and SWAR-style approaches to fully-unrolled, macro-driven bit-by-bit construction. Output semantics remain unchanged. Comprehensive randomized test coverage validates correctness against naive reference implementations. ChangesWave Transpose Optimization
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related issues
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
transpose_8: switched from the u32 Hacker's-Delight 8×8 primitive to the unrolled naive (~1.4× faster on RV32).transpose_16: kept the unrolled naive (a two-pass "two 8×8 via u32" decomposition was implemented + bit-verified but ran 1.6× slower on RV32, so it was rejected).Why
Fair same-build A/B on ESP32-P4 (RV32), all FORCE_INLINE + O3, 768 calls/frame:
The naive's bit-extracts are independent (compiler/pipeline parallelizes them); the HD/two-pass delta-swap is a latency-bound dependency chain that stalls on an in-order core. Same conclusion on x86. Investigation + data: #2524.
Test plan
bash test wave8(known-answer + round-trip + new equivalence tests) — passbash test wave3(new equivalence test) — passbash test parlio_driver(wave3 transpose coverage) — passbash lint --cpp— cleanRefs #2524
Summary by CodeRabbit
Refactor
Tests