Repository navigation
feat(esp32-p4): PIE (xesppie) SIMD backend Tier-1 ops (#2536) - #2538
Conversation
Route the revision-stable load/store + bitwise ops in fl::simd through
ESP32-P4 PIE inline asm (esp.vld/vst.128.ip, esp.andq/orq/xorq/notq) on
RISC-V, mirroring the existing Xtensa-S3 PIE backend; everything else
keeps the scalar fallback. Gated on __riscv_xesppie && !FL_IS_CLANG.
esp.vld/vst.128.ip require their base address register to be in the RVC
compressed set (x8-x15), so pointers are pinned to a0/a1/a2 via local
register variables. A plain "r" constraint lets GCC pick an illegal
register (a6/a7/t0/...) and the assembler rejects it ("illegal
operands"); the asm is centralized in pie_*_128 primitives.
Also: CLAUDE.md note to route on-device tests through AutoResearch.ino
rather than new example sketches.
Validated: assembles under the ESP32-P4 GCC toolchain (PlatformIO build),
device boots and setup() completes with the PIE SIMD self-tests running
(ops execute without faulting on a v1.3 chip); host scalar tests + lint
pass. On-device bit-equivalence readout is pending the P4 serial/RPC
infra fix (testSimd RPC currently blocked by a UART0-vs-USB-JTAG routing
mismatch, unrelated to the SIMD ops).
Co-Authored-By: Claude Opus 4.7 <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR adds test execution guidelines and implements PIE (packed in-element) acceleration for ESP32-P4 SIMD operations. A new compile-time feature gate enables 128-bit inline-assembly helper primitives that optimize bitwise and aligned copy operations for u8x16 and u32x4 SIMD types. ChangesTest Execution Guideline
ESP32-P4 PIE SIMD Optimization
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
…2539) * perf(wave8): byte-indexed expansion LUT (#2526) — 1.66x on ESP32-P4 Adds a 256x8 byte-indexed expansion LUT (Wave8ByteExpansionLut, 2 KB) and a single-lookup expansion primitive (wave8_expand_byte) that replaces the two nibble lookups in the hot PARLIO encode path. Same bit-exact output, ~half the per-byte index work — which is the bottleneck because expansion is instruction-issue-bound on the in-order RV32 core, not memory-bandwidth-bound. Integration: - New Wave8ByteExpansionLut type and buildWave8ByteExpansionLUT(nibble) builder. - detail::wave8_expand_byte(b, byteLut, *out): one indexed 8-byte copy. - Byte-LUT overloads of wave8Transpose_2/4/8/16; the PARLIO engine now holds mWave8ByteLut alongside mWave8Lut and routes all 5 hot expansion call sites through it (single-lane + 2/4/8/16-lane multi-lane). - Host test buildWave8ByteExpansionLUT_matches_nibble_path verifies bit-exact equivalence across all 256 input bytes. Measured on a real ESP32-P4 (revision v1.3) via a boot-time micro-bench in AutoResearch.ino (output via esp_rom_printf -> USB-Serial-JTAG console to sidestep the testSimd RPC's UART0 routing block; see #2536/#2538): iters=30000 (= 480,000 expansions per measurement) nibble_us=350170 byte_us=210419 batched_us=198682 frame_equiv (768 byte-positions): nibble=8964us byte=5386us batched=5086us speedup vs nibble: byte=1.66x batched=1.76x At expansion ~55% of encode, the 1.66x expansion speedup predicts ~1.28x on full encode_us — matching the prediction posted on #2526. Co-Authored-By: Claude Opus 4.7 <[email protected]> * refactor(autoresearch): wave8 expansion bench is RPC-driven + adds transpose16 timing Addresses review feedback on PR #2539: - Boot-time call removed by default; behind -DFL_BENCH_WAVE8_AT_BOOT=1 only. - Registers wave8ExpandBenchmark RPC handler (returns JSON via the RPC server). - Split into a pure measureWave8Expand() compute function + an optional esp_rom_printf print helper; the RPC path serializes the struct directly. - Adds full per-byte-position production timing (wave8Transpose_16 with both LUTs), not just isolated expansion — this is what the engine actually pays in the hot loop x 768 byte-positions/frame. Measured on ESP32-P4 v1.3 (boot-time bridge until #2541 routing fix): expand_only_us nibble=350142 byte=210155 batched=206528 transpose16_us nibble=530115 byte=344128 frame_equiv_us (768) expand_nibble=8963 expand_byte=5379 t16_nibble=13570 t16_byte=8809 speedup_x100 expand=166 batched=169 transpose16=154 So the **production per-byte-position hot loop is 1.54x faster** with the byte-LUT (4761 us/frame saved), and **isolated expansion is 1.66x faster**. Real encode-side measurement, not the prior 1.28x extrapolation. Follow-ups filed: #2540 (FL_PRINT vs esp_rom_printf), #2541 (testSimd RPC routing root cause). Co-Authored-By: Claude Opus 4.7 <[email protected]> --------- Co-authored-by: Claude Opus 4.7 <[email protected]>
Summary
Implements Phase 1 of #2536: an ESP32-P4 PIE (
xesppie) backend forfl::simd. The revision-stable Tier-1 ops now route through PIE inline asm on the P4 (RISC-V), mirroring the existing Xtensa-S3 PIE backend (simd_xtensa.hpp); everything else keeps the scalar fallback. Public API unchanged.PIE-backed ops (in
src/platforms/esp/32/simd_riscv.hpp):and/or/xor/andnotforu8x16andu32x4(esp.andq/orq/xorq/notq)esp.vld.128.ip/esp.vst.128.ip)Gated on
defined(__riscv_xesppie) && !defined(FL_IS_CLANG)(PIE asm is GCC-only).Key fix: RVC register constraint
esp.vld.128.ip/esp.vst.128.iprequire their base address register to be in the RVC compressed set (x8–x15). A plain"r"inline-asm constraint lets GCC pick an illegal register (a6/a7/t0/...), and the assembler rejects it:The asm is centralized in
pie_and_128/pie_or_128/pie_xor_128/pie_andnot_128/pie_copy_128, each pinning pointers toa0/a1/a2via local register variables. Verified against the ESP32-P4 binutils (onlys0,s1,a0–a5accepted as the base register).Validation
setup()completes with the AutoResearch PIE SIMD self-tests running (runSimdTestsat boot) — the ops execute without faulting on a v1.3 chip.tests/fl/math/simd.cpp) +bash lintpass.bash autoresearch esp32p4 --simd) is pending the P4 serial/RPC infra fix: thetestSimdRPC is currently blocked by a UART0-vs-USB-JTAG routing mismatch (CDC On Boot: 0), a transport-layer issue unrelated to the SIMD ops. fbuild also currently produces non-booting P4 images (use--no-fbuild/ PlatformIO).Notes
AutoResearch.inorather than new example sketches.Refs #2536 #2535
Summary by CodeRabbit
Documentation
Performance