Skip to content

[Matrix] Confusing encoding of RowMajor / ColMajor layout #7928

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

Closed
masahi opened this issue Jan 5, 2023 · 4 comments
Closed

[Matrix] Confusing encoding of RowMajor / ColMajor layout #7928

masahi opened this issue Jan 5, 2023 · 4 comments
Assignees
Labels
bug Something isn't working confirmed

Comments

@masahi
Copy link

masahi commented Jan 5, 2023

Hi, SPV_INTEL_joint_matrix.asciidoc#matrix-layout defines the numerical encoding of RowMajor / ColMajor matrix layout. But in

RowMajor = 0,
ColumnMajor = 1,
, these values are swapped. So if I use matrix_layout::row_major in my sycl program, I get 0 as the encoding of the layout.

On the IGC side, there are two conflicting definitions of this encoding:
https://github.com/intel/intel-graphics-compiler/blob/4eb6e950f5a617dadf1055253e4120afa57b7433/IGC/AdaptorOCL/SPIRV/libSPIRV/SPIRVType.h#L717-L718
https://github.com/intel/intel-graphics-compiler/blob/a8afe42bd544defeacb0ef88f79c40432b5f82b4/IGC/Compiler/Optimizer/OpenCLPasses/JointMatrixFuncsResolutionPass.cpp#L82-L83

So can I get a clarification of this situation?

Off topic, but I'd also like to know when SPV_INTEL_joint_matrix will become available in the official SPIRV tool chain. I've been updating a home-grown SPIRV code generator (in TVM) to support this extension, and not being able to use the validator has been painful.

@masahi masahi added the bug Something isn't working label Jan 5, 2023
@MrSidims MrSidims self-assigned this Jan 11, 2023
@MrSidims
Copy link
Contributor

FYI @dkhaldi @yubingex007-a11y @mbelicki

@masahi thanks for the report! It seems like a bug in our implementation, though not sure whether it would possible to swap enum values without breaking ABI, so probably the spec will be aligned.

Regarding IGC: the first link is a fork of https://github.com/KhronosGroup/SPIRV-LLVM-Translator , basically what matters for the translation is that what value is passed through it, how to interpret this value is up to IGC BE (the second link) and there enum matches the one from SYCL headers. So even if it's still quite incorrect I don't expect seeing functional and performance issues on GPU related to this bug.

Same for Intel CPU, as far as I see the order is the same as in the headers and not as in SPIR-V spec.

@yubingex007-a11y @mbelicki please correct if I'm missing something.

Off topic, but I'd also like to know when SPV_INTEL_joint_matrix will become available in the official SPIRV tool chain.

I can't tell exactly when, but we acknowledge this problem (it's not unique for matrix extension, several others also have it) and are trying to solve it as soon as possible. There is also an Khronos internal discussion about cooperative/joint matrix extension, it's under IP so can't share the detail, but if you have access you can try to find this discussion yourself.

@MrSidims
Copy link
Contributor

MrSidims commented Jan 11, 2023

After some discussion we consider it as the specification bug - the intention always was to make the enumeration like in the implementation, not sure how different enumeration appeared in the spec. I've updated #5944 to solidify this (though this very PR probably won't ever be merged) and will update our internal next-iteration spec (hope it will be public soon, after this we plan to upstream the changes to SPIR-V Headers and hence Tools). The SPIR-V Translator will be updated as well (just naming of variables and enum members).

Thanks again for the report!

@MrSidims
Copy link
Contributor

MrSidims commented Feb 1, 2023

@masahi not 100% final, but a much improved spec can be found here: #8175 . It also addresses the issue.

@masahi
Copy link
Author

masahi commented May 2, 2023

Closing since #8175 was merged. Thanks! @MrSidims

@masahi masahi closed this as completed May 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working confirmed
Projects
None yet
Development

No branches or pull requests

2 participants