Skip to content

[AIE2P] Fix scheduling model to add missing ItinRegClass pairs #521

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: aie-public
Choose a base branch
from

Conversation

khallouh
Copy link
Collaborator

@khallouh khallouh commented Jul 9, 2025

We dynamically switch the itinerary data of the instruction based on the register class of the its operands. If for a certain class, no special itinerary is specified, the default instruction itinerary is used, which is more conservative and may lack certain bypasses. This can result in incorrect schedules due to the use of negative latencies.
This PR fixes the scheduling model to add ItinRegClass pairs for register classes that were missing.
The bug was found with VMOV between a fifo store register (e.g. sfl) and a vector register (e.g. x0) where a bypass should have been specified for the vector register operand as VMOV instructions use the Move Slot Bypass for vector inputs and outputs but not for others (accumulator/fifo).

MLLIB results remain unchanged both on a functional and QoR level.
Update: The new itineraries were not used, QoR actually differs for some kernels (See comment below)

@@ -64,13 +68,14 @@ def DN_RM_PORT : FuncUnit;
def DN_WM_PORT : FuncUnit;
def DONE_FU : FuncUnit;
def EVENT_UPS_OF : FuncUnit;
def FIFO_EXTRA_RD_PORT : FuncUnit;
def FIFO_EXTRA_WR_PORT : FuncUnit;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The fix in the generator introduces a few more resources with new potential conflicts. The number of resources is no longer an issue with #507 being merged.

def TM_AD : FuncUnit;
def UPS__H__A : FuncUnit;
def UPS__H__K : FuncUnit;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

UPS__H__K was previously removed manually to respect the maximum number of resources, which was possible because UPS__H__A modelled the exact same conflicts. We get UPS__H__K back now after regenerating the file.

InstrItinData<II_VMOV_alu_mv_mv_x_eXo_eBMLL, [SimpleCycle<DM_RM_L0_PORT>], [/*dst*/2, /*src*/1], [/*dst*/MV_Bypass, /*src*/NoBypass]>,
InstrItinData<II_VMOV_alu_mv_mv_x_eXo_eBMLH, [SimpleCycle<DM_RM_L0_PORT>], [/*dst*/2, /*src*/1], [/*dst*/MV_Bypass, /*src*/NoBypass]>,
InstrItinData<II_VMOV_alu_mv_mv_x_eXo_mStFifoh, [PrefixCycle<FIFO_HL_RA_PORT>, SimpleCycle<ST_FIFO_RD_PORT>], [/*dst*/2, /*src*/1], [/*dst*/MV_Bypass, /*src*/NoBypass]>,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This line illustrates the fix. Note the use of MV_Bypass for eXo destination operand

Copy link
Collaborator

@martien-de-jong martien-de-jong left a comment

Choose a reason for hiding this comment

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

Makes sense to me, but I'm leaving approval to nextgen people.

def FIFO_HL_RA_PORT : FuncUnit;
def FIFO_HL_WA_PORT : FuncUnit;
def FIFO_STS__ADVANCE_FIFO_R : FuncUnit;
def LCKREQ : FuncUnit;
def LD_FIFO_RA_PORT : FuncUnit;
def LD_FIFO_WA_PORT : FuncUnit;
def LXC : FuncUnit;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This LXC resource was already gone in the generated file before my fix regarding ItinRegClass pairs. It may be some previous fix in the generator which was not transferred to Peano.

@@ -1,10 +1,10 @@
//===-AIE2PGroupedResourcesGenSchedule.td -----------------------------*- tablegen -*-===//
//===-AIE2PGenSchedule_groupedResources.td -----------------------------*- tablegen -*-===//
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: shouldn't the file name also change?

Copy link
Collaborator

@konstantinschwarz konstantinschwarz left a comment

Choose a reason for hiding this comment

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

This is only the scheduling model change, but we also need to make use of the new itineraries in AIE2PGenInstrInfo.td

@khallouh
Copy link
Collaborator Author

This is only the scheduling model change, but we also need to make use of the new itineraries in AIE2PGenInstrInfo.td

Indeed, I have updated accordingly and now we see somewhat different QoR:
On Core_Compute_Inst_Count: only improvements, up to 1.41% IMPR
On Core_PMSize: Some improvements (up to 1.13% IMPR) and some regressions (up to 1.52% REGR) with average diff being +0.02%

; CHECK-NEXT: mova dc1, #0; movx r1, #4; mov dn1, dn0
; CHECK-NEXT: movs p1, p0; add.nc lc, r1, #-3
; CHECK-NEXT: mova r1, #4; mov dn1, dn0
; CHECK-NEXT: mova dc1, #0; movs p1, p0; add.nc lc, r1, #-3
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We now avoid the virtual conflict we had on DC_WM_PORT between mova dc1, #0 and add.nc lc, r1, #-3

; CHECK-NEXT: mov p6, sp
; CHECK-NEXT: padda [p6], m0; mov p7, sp
; CHECK-NEXT: lda m1, [p6, #0]; movxm m0, #-1108
; CHECK-NEXT: mova dc4, #0; mov p6, sp
Copy link
Collaborator Author

@khallouh khallouh Jul 23, 2025

Choose a reason for hiding this comment

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

And here we avoid the virtual conflict we had on DC_WM_PORT between mova dc4, #0 and mov p6, sp

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