Skip to content

Make ObjectFIFO fully dynamic -- remove custom unrolling logic, and add new unrolling pass#3298

Draft
andrej wants to merge 10 commits into
Xilinx:mainfrom
andrej:objfifo-dynamic
Draft

Make ObjectFIFO fully dynamic -- remove custom unrolling logic, and add new unrolling pass#3298
andrej wants to merge 10 commits into
Xilinx:mainfrom
andrej:objfifo-dynamic

Conversation

@andrej

@andrej andrej commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Work in progress! Below description is aspirational:

Builds on #3308. Isolated Diff.

The PR removes the existing custom unrolling logic from the stateful transform pass. This means this pass now always emits dynamic code, with aforementioned runtime bookkeeping.

Doing the bookkeeping at runtime might have a small performance impact. To counter this, I add a new unrolling pass after the ObjectFIFO transform. This pass reuses existing MLIR infrastructure to unroll the loops containing the dynamic code. After unrolling, the compiler can statically reason about the generated bookkeeping code and, in the common, simple cases, fold them back into fully constant lock acquire/release values. This erases the runtime overhead for the common case.

This sort of "roundabout" way of first emitting dynamic code, then unrolling this code and folding constants back where possible has the advantage of simplifying the passes, and supporting all control flow (code that can't be reasoned about statically just remains dynamic and takes the potential performance hit of a couple extra instruction the core).

This should drastically simplify the code, as the ObjectFIFO lowering pass no longer performs any static analysis of loops and conditionals, and it allows arbitrary control flow. The static implementation had to reject cases it couldn't reason about.

@andrej andrej force-pushed the objfifo-dynamic branch 2 times, most recently from 1b72f97 to e93a3a2 Compare July 9, 2026 21:21
@andrej andrej changed the title Make ObjectFIFO lock acquistion/release fully dynamic, remove custom unrolling logic, and add new unrolling pass Make ObjectFIFO fully dynamic -- remove custom unrolling logic, and add new unrolling pass Jul 9, 2026
@andrej andrej force-pushed the objfifo-dynamic branch 2 times, most recently from 38001a1 to 3199b9c Compare July 11, 2026 02:50
andrej and others added 9 commits July 13, 2026 09:06
Make aie.use_lock carry its lock count as an i32 SSA operand instead of
an optional integer attribute, and emit runtime-computed lock counts in
the dynamic (loop-preserving) objectFifo lowering via a per-(fifo,port)
"held" counter. Passes that need a compile-time constant read it back
through UseLockOp::getConstantValue().

The static loop-unrolling path (dynamic-objFifos=false) is left in place
and still emits compile-time constant lock counts, so static and dynamic
lock lowering coexist on this branch.

Compiler code only; the corresponding test updates follow in the next
commit.
Update lock-bearing goldens for the new i32 SSA aie.use_lock value form,
add dynamic_runtime_lock_* tests covering the runtime "held"-counter lock
bookkeeping, add a bad-input test for a non-constant use_lock value where
a constant is required, and drop the dynamic_cyclostatic_* goldens that
exercised the removed static peel/held-before-loop lock accounting.
Emit the per-(fifo,port) runtime held-element counters as single-element
memref.alloca (tagged aie.held_counter) so acquire/release bookkeeping is
plain load/store, then run mem2reg in-pass to promote them to SSA values.
Hard-error if any counter survives promotion. Regenerate the dynamic
objectFifo lock CHECK lines accordingly.
Co-authored-by: André Rösti <androsti@amd.com>
@andrej andrej force-pushed the objfifo-dynamic branch from 3199b9c to 0e2c6e3 Compare July 13, 2026 15:07
@andrej andrej force-pushed the objfifo-dynamic branch from 0e2c6e3 to 1fe393d Compare July 13, 2026 15:33
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