-
Notifications
You must be signed in to change notification settings - Fork 247
Align SPV_INTEL_joint_matrix implementation to the spec #3468
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
base: main
Are you sure you want to change the base?
Align SPV_INTEL_joint_matrix implementation to the spec #3468
Conversation
Spec: intel/llvm#12497 Change summary: * added Packed matrix layout to support Intel VNNI instructions. * remove `JointMatrixGetElementCoord` in favor of the same cooperative matrix instruction. * support new Cooperative Matrix Operands to specify component type interpretation for tf32 and bfloat16 types.
| if (CoopOperands & | ||
| internal:: | ||
| CooperativeMatrixOperandsMatrixAAndBBFloat16ComponentsINTELMask || | ||
| CoopOperands & | ||
| internal:: | ||
| CooperativeMatrixOperandsMatrixCBFloat16ComponentsINTELMask || | ||
| CoopOperands & | ||
| internal:: | ||
| CooperativeMatrixOperandsMatrixResultBFloat16ComponentsINTELMask) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if (CoopOperands & | |
| internal:: | |
| CooperativeMatrixOperandsMatrixAAndBBFloat16ComponentsINTELMask || | |
| CoopOperands & | |
| internal:: | |
| CooperativeMatrixOperandsMatrixCBFloat16ComponentsINTELMask || | |
| CoopOperands & | |
| internal:: | |
| CooperativeMatrixOperandsMatrixResultBFloat16ComponentsINTELMask) { | |
| constexpr auto BF16Masks = | |
| internal::CooperativeMatrixOperandsMatrixAAndBBFloat16ComponentsINTELMask | | |
| internal::CooperativeMatrixOperandsMatrixCBFloat16ComponentsINTELMask | | |
| internal::CooperativeMatrixOperandsMatrixResultBFloat16ComponentsINTELMask; | |
| if (CoopOperands & BF16Masks) { |
YuriPlyakhin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Provided one nit comment above. Also, a question: should we first merge intel/llvm#12497 before merging translator changes?
Shortly - we should not. |
There is no such requirement. Most important thing - the spec is public. |
| typedef SPIRVInstTemplate<SPIRVJointMatrixINTELWorkItemInst, \ | ||
| internal::Op##x##INTEL, __VA_ARGS__> \ | ||
| SPIRV##x##INTEL; | ||
| _SPIRV_OP(JointMatrixGetElementCoord, true, 5) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To double check, what instruction is used in SYCL headers right now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, then I'd suggest to first replace the joint matrix version to cooperative matrix version in the headers and see if anything fails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created a draft PR: intel/llvm#20855
| ; RUN: llvm-as < %s -o %t.bc | ||
| ; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_KHR_cooperative_matrix,+SPV_INTEL_joint_matrix -o %t.spv | ||
| ; RUN: llvm-spirv %t.spv -to-text -o %t.spt | ||
| ; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have a spirv-val check? Or is not prepared yet?
| ; CHECK-SPIRV-DAG: Extension "SPV_KHR_cooperative_matrix" | ||
| ; CHECK-SPIRV-DAG: Extension "SPV_INTEL_joint_matrix" | ||
| ; CHECK-SPIRV-DAG: Capability CooperativeMatrixBFloat16ComponentTypeINTEL | ||
| ; 64 stays for MatrixAAndBBFloat16ComponentsINTEL (0x40) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also test 0x80 and 0x100? I don't see them tested now.
Spec: intel/llvm#12497
Change summary:
JointMatrixGetElementCoordin favor of the same cooperative matrix instruction.