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

[AIE2P] Implemented VST.PACK combine #280

Merged
merged 1 commit into from
Jan 24, 2025
Merged

Conversation

katerynamuts
Copy link
Collaborator

No description provided.

CombOpIntrinsicID != Intrinsic::aie2p_pack_I1024_I4_I8)
return {};

assert((getLoadStoreSize(MemOp) == 256) && "Unexpected STS.SRS size");
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: VST.PACK


auto Opcode = TII.getMvSclMultiSlotPseudoOpcode();
MIB.setInstr(*NewInstr);
MIB.buildInstr(Opcode, {AIE2P::crPackSize}, {}).addImm((unsigned)Is8Bit);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, this crPackSize usage is very subtle in the documentation.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

true

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not the only place were we have to set a control register. Can we create a function for this in AIEBaseInstructionSelector.cpp, as we did with setUnsetCtrlRegister?

// Selects the size of the Pack instructions
// 0 – Destination is 4 bits
// 1 – Destination is 8 bits
bool Is8Bit = cast<GIntrinsic>(PackOp)->getIntrinsicID() ==
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: const.

; CHECK-NEXT: $packsign0 = MOV_scalar_imm11_pseudo 0
; CHECK-NEXT: [[COPY3:%[0-9]+]]:edj = COPY $dj0
; CHECK-NEXT: $crpacksize = MOV_scalar_imm11_pseudo 1
; CHECK-NEXT: $packsign0 = COPY [[COPY2]]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Curious: We have two packSign registers in AIE2p? I assume both are addressible, and here this is just an arbitrary choice to use packsign0 for the dynamic case?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, we have two packSign registers in AIE2p, packSign0 and packSign1. We have the same situation for vaddSign, unpackSign, upsSign, srsSign. In all cases for the dynamic case we just use the instruction with the xxxSign0.

gbossu
gbossu previously approved these changes Jan 20, 2025
Copy link
Collaborator

@gbossu gbossu left a comment

Choose a reason for hiding this comment

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

LGTM, I couldn't spot something wrong. I have checked about half of the tests, and trust the rest are correct as well. Up to you if you want to seek another review from AIE2p core team :)
Before merging, maybe have a QoR run to check those combines are used in practice and do not introduce new failures.

@katerynamuts katerynamuts force-pushed the kmuts.vst_pack branch 3 times, most recently from 117c802 to f2e1b63 Compare January 21, 2025 09:46
@mludevid mludevid self-requested a review January 22, 2025 08:58
Copy link
Collaborator

@mludevid mludevid left a comment

Choose a reason for hiding this comment

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

Please go through all test files and fix the types and sizes of all vectors involved.

  • aie2p_pack_I512_I8_I16: the input vector should be <32 x s16> and the output one <32 x s8>
  • aie2p_pack_I512_I4_I8: the input vector should be <64 x s8> and the output one <64 x s4>
  • aie2p_pack_I1024_I8_I16: the input vector should be <64 x s16> and the output one <64 x s8>
  • aie2p_pack_I1024_I4_I8: the input vector should be <128 x s8> and the output one <128 x s4>

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 update the header of this file to 2024-2025?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please update this header as well: 2023-2025

Comment on lines 2575 to 2576
if (CombOp.getOpcode() != AIE2P::G_INTRINSIC_W_SIDE_EFFECTS)
return false;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This check is duplicated, we also check this in getCombinedOpcodePACK. I would prefer to just keep it in getCombinedOpcodePACK.

Comment on lines 2602 to 2604
assert((MemOpLoadStoreSize == 256 &&
(SrcRegSize == 512 || SrcRegSize == 1024)) &&
"Unexpected VST.PACK size");
Copy link
Collaborator

Choose a reason for hiding this comment

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

In AIE2P the store size can be 512 bits if the source register size is 1024. I would suggest updating the assert to:

assert((MemOpLoadStoreSize == 256 && SrcRegSize == 512) || (MemOpLoadStoreSize == 512 && SrcRegSize == 1024))

CombOpIntrinsicID != Intrinsic::aie2p_pack_I1024_I4_I8)
return {};

assert((getLoadStoreSize(MemOp) == 256) && "Unexpected VST.PACK size");
Copy link
Collaborator

Choose a reason for hiding this comment

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

As mentioned in another comment the memory size can either be 256 or 512 in AIE2P.


auto Opcode = TII.getMvSclMultiSlotPseudoOpcode();
MIB.setInstr(*NewInstr);
MIB.buildInstr(Opcode, {AIE2P::crPackSize}, {}).addImm((unsigned)Is8Bit);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not the only place were we have to set a control register. Can we create a function for this in AIEBaseInstructionSelector.cpp, as we did with setUnsetCtrlRegister?

@katerynamuts katerynamuts merged commit 44fec18 into aie-public Jan 24, 2025
8 checks passed
@katerynamuts katerynamuts deleted the kmuts.vst_pack branch January 24, 2025 16:47
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