Skip to content

Enable dynamic lock acquisition for ObjectFIFO acquire/release in cores#3308

Merged
andrej merged 9 commits into
Xilinx:mainfrom
andrej:objfifo-locks-dynamic
Jul 13, 2026
Merged

Enable dynamic lock acquisition for ObjectFIFO acquire/release in cores#3308
andrej merged 9 commits into
Xilinx:mainfrom
andrej:objfifo-locks-dynamic

Conversation

@andrej

@andrej andrej commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

The --dynamic-objFifos option -- now the default -- so far made the buffer selection dynamic in the ObjectFIFO. This means the lowering injects some code into the IR which resolves which buffer to read from/write to at runtime instead of reasoning about this at compile-time and hard-coding the buffers.

This PR does the same for locks, allowing acquiring and releasing objects within arbitrary control flow paths, while a small runtime component keeps track of the number of objects that the core holds. This means we keep a runtime-computed value for the lock acquire/release counts in a register or in memory on the core.

To enable this, we have to refactor the IR to use SSA values for lock counts rather than static attributes -- this is the reason this PR touches many tests. Existing passes that rely on constant values for lock acquire/release emit arith.constant (or trace the SSA value back to a defining arith.constant and error if the value is not constant).

@stephenneuendorffer

Copy link
Copy Markdown
Collaborator

I'm glad to see this Andrej, it's a big improvement on code size!

@hunhoffe

Copy link
Copy Markdown
Collaborator

Out of curiosity, does this address either of the two recently opened issues?

@andrej

andrej commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator Author

Out of curiosity, does this address either of the two recently opened issues?

@hunhoffe I think #3298, which builds on top of this, will address #3281. Not sure about #3283.

@andrej andrej force-pushed the objfifo-locks-dynamic branch from 9a94506 to 671d0ef Compare July 10, 2026 21:47

@andrej andrej left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a custom parser that allows immediate values in the IR instead of forcing arith.constant everywhere to reduce the size of the diff / having to rewrite all tehse tests?

Comment thread include/aie/Dialect/AIE/IR/AIEOps.td Outdated
Comment thread lib/Dialect/AIE/IR/AIEDialect.cpp Outdated
Comment thread lib/Dialect/AIE/IR/AIEDialect.cpp Outdated
Comment thread lib/Dialect/AIE/IR/AIEDialect.cpp Outdated
Comment thread lib/Dialect/AIE/Transforms/AIEObjectFifoStatefulTransform.cpp Outdated
Comment thread lib/Dialect/AIE/Transforms/AIEObjectFifoStatefulTransform.cpp Outdated
Comment thread lib/Dialect/AIE/Transforms/AIEObjectFifoStatefulTransform.cpp Outdated
@andrej andrej marked this pull request as ready for review July 11, 2026 01:17
Copilot AI review requested due to automatic review settings July 11, 2026 01:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review this pull request because it exceeds the maximum number of files (300). Try reducing the number of changed files and requesting a review from Copilot again.

@hunhoffe hunhoffe left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! This is a good time to do this type of change, since we're already doing a lot of type conversions to SSA

Worker(
conv1x1_fn,
fn_args=[wts_buf_00.cons(), of_act_l3l2.cons(), of_act_2_3_5.prod(), conv1],
stack_size=0x1000,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting! Are you sure the changes to this design are necessary? I'm surprised it was passing before this!

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, they definitely are. This was hard to debug, along with another missized buffer. Keep in mind we are now keeping lock count bookkeeping data in memory. If that gets overridden by a buffer override, it causes the whole design to misbehave/timeout. Previously, it might just have overridden other data which might have passed some of our fuzzy output tests.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch then!

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-locks-dynamic branch from 5578f86 to 25ca535 Compare July 13, 2026 15:06
@andrej andrej enabled auto-merge July 13, 2026 15:28
@andrej andrej disabled auto-merge July 13, 2026 15:37
@andrej andrej enabled auto-merge July 13, 2026 15:39
@andrej andrej added this pull request to the merge queue Jul 13, 2026
Merged via the queue into Xilinx:main with commit 696ba5a Jul 13, 2026
65 checks passed
@andrej andrej deleted the objfifo-locks-dynamic branch July 13, 2026 16:53
hunhoffe added a commit that referenced this pull request Jul 13, 2026
Integrates PR #3308 (dynamic lock acquisition for ObjectFIFO):
- All test files: use_lock uses new SSA i32 value operand form (arith.constant + %c)
- All test files: dma_bd retains this PR's SSA operand format (offset=/len=/sizes=/strides=)
- bad_bd_assignments.mlir: includes #3308's new nextBdId overflow test
- dynamic_cyclostatic_* test files removed (deleted upstream by #3308)
- New dma_channel_pinning/ tests and dynamic_runtime_lock_* tests from #3308

Co-Authored-By: Claude <noreply@anthropic.com>
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.

4 participants