Skip to content

perf: add branchless masked-pin software SPI writes for CI13XX #5029

Closed

Description

@zackees

Context

Discovery at 94dab9c for #5024, two source investigation rounds, no builds. CI1302/CI1303/CI1306 register FastPin through src/platforms/fastpin.h:40-44; src/platforms/spi_output_template.h:64-66 falls back to shared software SPI. src/platforms/ci13xx/fastpin_ci13xx.h:20-35,58-60 proves each pin has its own PL061-style masked address: one store changes only that pin. Its hi/lo values are 0xff/0. src/platforms/shared/spi_bitbang/bitbang_pin.h:33-44 currently defaults to a data-dependent branch and marks atomic writes false. Generic bulk paths can additionally select precomputed register writes (generic_software_spi.h:289-300).

Proposal

Specialize CI13XX software data writes to store the selected masked value without a data-dependent branch and consistently use that operation through production scalar and bulk entry points. Keep timing/clock ownership in shared SPI. This masked per-pin address must not be mistaken for a whole-port snapshot or an ESP-style set/clear pair.

Acceptance criteria

  • First produce RED evidence from actual software SPI scalar and bulk APIs, then GREEN production disassembly proving one data-pin store without a bit-dependent branch or port read. Exercise all 256 values and every bit, back-to-back bytes, start bits, adjustment callbacks and final clock idle.
  • Trace unrelated pin preservation with concurrent updates and ensure the masked data address/value is correct for PA/PB/PC/PD. Same bank pins still have distinct per-pin addresses: do not enable whole-port two-store streaming.
  • Compile real CI1302, CI1303 and CI1306 configurations with their upstream Arduino core. Include default vs USE_EXTERNAL_CRYSTAL_OSC, common pins 2/3/13/14/20, CI1306 extended PD pins 22/23/25/26, and rejection of absent 24/27 and crystal-reserved 0/1. Report missing board-inventory/toolchain coverage explicitly; host shims alone are insufficient.
  • Preserve timing and forced-software-pin fallback. Establish GPIO timing using vendor evidence; physical throughput claims require real-board measurements via the existing AutoResearch/fbuild workflow.
  • Restore the old branch-producing data operation after implementation; the focused code-generation gate must fail and return GREEN after restoration. Changing trait flags or ledger metadata without using the behavior must fail.

Decisions

Open questions

Confirm the supported CI13XX toolchain/board targets and silicon bus timing before implementation. No physical speedup was measured. Next step: a focused real production code-generation repro.

Activity

  1. added
    sanitized
    on Nov 5, 2026
  2. zackees commented on Nov 6, 2026

    @zackees
    MemberAuthor

    Blocked, not started. Real CI13xx builds need fbuild 2.5.52 (native CI1306 support from FastLED/fbuild#1914, release prepared in FastLED/fbuild#1920). PyPI and GitHub still show 2.5.51 as the latest, so these acceptance builds cannot run yet, and FastLED has no ci13xx board entry until the floor is raised. Skipping ahead in #5024 until that release exists.

  3. zackees commented on Nov 22, 2026

    @zackees
    MemberAuthor

    Closing with an accepted limitation, the same pattern as #5047.

    This is a performance improvement for CI13XX with no reported user problem behind it. The fbuild 2.5.52 blocker is gone (#5293), but:

    • ci/boards.py has no CI13XX board entry, so no CI build can show the codegen change;
    • no CI13XX hardware is available to measure the waveform or gain.

    Writing a branchless masked-pin path without either would mean adding unverifiable code for a target nobody builds. If a CI13XX board entry or a user report appears, reopen with that as the production path. The shared software-SPI gating work continues in #5031.

  4. moved this from Triage to Done in FastLED Trackeron Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    sanitized

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions