Skip to content
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

[AIE2] Fix VMOV instruction itinerary #239

Merged
merged 2 commits into from
Jan 2, 2025
Merged

Conversation

krishnamtibrewala
Copy link
Collaborator

Changes done in this PR were identified by @konstantinschwarz for fixing the DIFF issue in FullyConnect_aie2_bf16

ISSUE : In a specific case the compiler was assuming that VMOV has a latency of 2, i.e. it can still use the old value of $wlX when written from $qX reg, but since the DST reg was of $wlX type which uses the bypass path and overwrites the value one cycle earlier, leading to wrong value being read.

ItinRegClassPair<II_VMOV_W_WML_WMH,[OperandRegClass<0, eWL>, OperandRegClass<1, eWH>]>] in {
ItinRegClassPair<II_VMOV_W_WML_WMH,[OperandRegClass<0, eWL>, OperandRegClass<1, eWH>]>,
ItinRegClassPair<II_VMOV_W_WML_Q, [OperandRegClass<0, eWL>, OperandRegClass<1, mQQm>]>,
ItinRegClassPair<II_VMOV_W_WMH_Q, [OperandRegClass<0, eWH>, OperandRegClass<1, mQQm>]>] in {
def VMOV_mv_w : AIE2_mv_w_inst_mv< (outs OP_mMvAMWQDst:$dst), (ins OP_mMvAMWQSrc:$src),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you think of an easy way to check that the II_VMOV_W itinerary is never used by the postmisched? Doing so can result in problems like the one you describe. Maybe in getSchedClass we should assert if we fallback to the default itinerary because none of the operands matched?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

is that specific for II_VMOV_W or for all the reg-based itinerary ?

If its specific to II_VMOV_W itinerary I can update the tablegen flow, where in an extra field if marked with an instruction will introduce an assert. Also doing this specifically for postmisched will be tricky since we do not have any info in the newly autogenerated getSchedClass function.

Doing it for all is easy but will require adding lot of itinerary manually for MOV instructions since we use conservative itinerary in cases when we are writing to single register like SP, LR , LE .... and so on.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should aim to have "fully-covering" reg-based itineraries actually. But yes, I don't know how much work that might be to actually make all of our itineraries complete. I think it's fine for now.

@krishnamtibrewala krishnamtibrewala force-pushed the aie2-fix-FC_aie2_bf16 branch 2 times, most recently from 1023fdc to c94d501 Compare December 3, 2024 18:21
ItinRegClassPair<II_VMOV_W_WML_WMH,[OperandRegClass<0, eWL>, OperandRegClass<1, eWH>]>] in {
ItinRegClassPair<II_VMOV_W_WML_WMH,[OperandRegClass<0, eWL>, OperandRegClass<1, eWH>]>,
ItinRegClassPair<II_VMOV_W_WML_Q, [OperandRegClass<0, eWL>, OperandRegClass<1, mQQm>]>,
ItinRegClassPair<II_VMOV_W_WMH_Q, [OperandRegClass<0, eWH>, OperandRegClass<1, mQQm>]>] in {
Copy link
Collaborator

Choose a reason for hiding this comment

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

What about VMOV from Q to WL? I assume the output can use the MOV bypass then. Do we need new II_VMOV_W_Q_WML and II_VMOV_W_Q_WMH itineraries?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As per the ISA, Move slot bypass are only used when we are reading from either a X or WL register.

Copy link
Collaborator

@gbossu gbossu Dec 9, 2024

Choose a reason for hiding this comment

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

What I meant is that

Below, the bypass should be taken

    $wl1 = VMOV_mv_w $q0
    $q1= VMOV_mv_w $wl1

But not here:

    $hl1 = VMOV_mv_w $q0
    $q1= VMOV_mv_w $wh1

However, I'm not sure that will be the case due to how we define the itineraries. In any case, it is worth testing :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Fixed in the second commit

@gbossu gbossu force-pushed the aie2-fix-FC_aie2_bf16 branch from c94d501 to e1a7618 Compare December 12, 2024 16:31
Copy link
Collaborator

@andcarminati andcarminati left a comment

Choose a reason for hiding this comment

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

LGTM.

@gbossu gbossu merged commit 9d60f53 into aie-public Jan 2, 2025
8 checks passed
@gbossu gbossu deleted the aie2-fix-FC_aie2_bf16 branch January 2, 2025 09:13
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.

3 participants