Skip to content

[AIE2P] Implement lock no_fence scheduling semantics#856

Open
katerynamuts wants to merge 2 commits into
aie-publicfrom
kmuts.aie2p.semaphores
Open

[AIE2P] Implement lock no_fence scheduling semantics#856
katerynamuts wants to merge 2 commits into
aie-publicfrom
kmuts.aie2p.semaphores

Conversation

@katerynamuts
Copy link
Copy Markdown
Collaborator

@katerynamuts katerynamuts commented Mar 18, 2026

The AIE2P spec defines two variants of the acquire/release lock instruction depending on context:

  • guarded: used when memory operations are in-flight before the lock. Enforces a minimum gap between the preceding memory op and any
    subsequent one.
  • no_fence: used when no memory is in-flight before the lock. Omits all memory lock token constraints, allowing subsequent memory ops to be scheduled immediately (0 cycles gap).

Previously the scheduler always applied the guarded latency forward from any lock to subsequent memory, matching the guarded variant regardless of context.
This patch implements no_fence semantics for AIE2P by:

  1. Adding a virtual hasLockNoFenceSemantics() hook to AIEBaseInstrInfo (default: false), overridden to return true in AIE2PInstrInfo.
  2. In LockDelays::apply, skipping the forward ACQ/REL->MEM latency when the target supports no_fence semantics.
  3. In AIERegMemEventTracker::getSafeOperandsDistanceFromBottom, skipping the forward lock-to-mem distance for the same reason.
  4. The MEM->ACQ/REL direction (predecessor latencies) is unchanged.

The fix is gated on hasLockNoFenceSemantics() and does not affect AIE2, or AIE2PS.
Update acqrel-scheduling.mir CHECK lines to reflect no_fence behavior.

Add acqrel-scheduling.mir with scheduling tests covering memory
(store/load vs ACQ/REL/DONE), scalar streams (SS/MS), cascade streams
(SCD/MCD), and lock sequences (ACQ/ACQ, ACQ/REL, REL/ACQ, REL/REL).

CHECK lines reflect the existing guarded-only scheduler behavior, before
lock no_fence semantics are implemented.
The AIE2P spec defines two variants of the acquire/release lock
instruction depending on context:
- guarded: used when memory operations are in-flight before the lock.
  Enforces a minimum gap between the preceding memory op and any
  subsequent one.
- no_fence: used when no memory is in-flight before the lock. Omits
  all memory lock token constraints, allowing subsequent memory ops to
  be scheduled immediately (0 cycles gap).
Previously the scheduler always applied the guarded latency forward from
any lock to subsequent memory, matching the guarded variant regardless
of context.
This patch implements no_fence semantics for AIE2P by:
1. Adding a virtual hasLockNoFenceSemantics() hook to AIEBaseInstrInfo
   (default: false), overridden to return true in AIE2PInstrInfo.
2. In LockDelays::apply, skipping the forward ACQ/REL->MEM latency
   when the target supports no_fence semantics.
3. In AIERegMemEventTracker::getSafeOperandsDistanceFromBottom, skipping
   the forward lock-to-mem distance for the same reason.
The MEM->ACQ/REL direction (predecessor latencies) is unchanged.
The fix is gated on hasLockNoFenceSemantics() and does not affect
AIE1, AIE2, or AIE2PS.
Update acqrel-scheduling.mir CHECK lines to reflect no_fence behavior.
@katerynamuts katerynamuts force-pushed the kmuts.aie2p.semaphores branch from 2f2b0ed to 1c17bf7 Compare March 18, 2026 14:48
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